1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-21 23:58:07 +02:00

Move the isEmptyObj helper function from src/shared/util.js to test/unit/test_utils.js

Since this helper function is no longer used anywhere in the main code-base, but only in a couple of unit-tests, it's thus being moved to a more appropriate spot.

Finally, the implementation of `isEmptyObj` is also tweaked slightly by removing the manual loop.
This commit is contained in:
Jonas Jenwald 2020-06-09 16:48:03 +02:00
parent 159e13c4e4
commit 88fdb482b0
4 changed files with 10 additions and 20 deletions

View file

@ -13,7 +13,7 @@
* limitations under the License.
*/
import { isEmptyObj } from "../../src/shared/util.js";
import { isEmptyObj } from "./test_utils.js";
import { Metadata } from "../../src/display/metadata.js";
describe("metadata", function () {

View file

@ -175,6 +175,14 @@ function createIdFactory(pageIndex) {
return page.idFactory;
}
function isEmptyObj(obj) {
assert(
typeof obj === "object" && obj !== null,
"isEmptyObj - invalid argument."
);
return Object.keys(obj).length === 0;
}
export {
DOMFileReaderFactory,
NodeFileReaderFactory,
@ -184,4 +192,5 @@ export {
buildGetDocumentParams,
TEST_PDFS_PATH,
createIdFactory,
isEmptyObj,
};

View file

@ -19,7 +19,6 @@ import {
createValidAbsoluteUrl,
isArrayBuffer,
isBool,
isEmptyObj,
isNum,
isSameOrigin,
isString,
@ -89,16 +88,6 @@ describe("util", function () {
});
});
describe("isEmptyObj", function () {
it("handles empty objects", function () {
expect(isEmptyObj({})).toEqual(true);
});
it("handles non-empty objects", function () {
expect(isEmptyObj({ foo: "bar" })).toEqual(false);
});
});
describe("isNum", function () {
it("handles numeric values", function () {
expect(isNum(1)).toEqual(true);