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:
		
							parent
							
								
									159e13c4e4
								
							
						
					
					
						commit
						88fdb482b0
					
				| @ -793,13 +793,6 @@ function utf8StringToString(str) { | |||||||
|   return unescape(encodeURIComponent(str)); |   return unescape(encodeURIComponent(str)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function isEmptyObj(obj) { |  | ||||||
|   for (const key in obj) { |  | ||||||
|     return false; |  | ||||||
|   } |  | ||||||
|   return true; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| function isBool(v) { | function isBool(v) { | ||||||
|   return typeof v === "boolean"; |   return typeof v === "boolean"; | ||||||
| } | } | ||||||
| @ -931,7 +924,6 @@ export { | |||||||
|   isArrayBuffer, |   isArrayBuffer, | ||||||
|   isArrayEqual, |   isArrayEqual, | ||||||
|   isBool, |   isBool, | ||||||
|   isEmptyObj, |  | ||||||
|   isNum, |   isNum, | ||||||
|   isString, |   isString, | ||||||
|   isSameOrigin, |   isSameOrigin, | ||||||
|  | |||||||
| @ -13,7 +13,7 @@ | |||||||
|  * limitations under the License. |  * limitations under the License. | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| import { isEmptyObj } from "../../src/shared/util.js"; | import { isEmptyObj } from "./test_utils.js"; | ||||||
| import { Metadata } from "../../src/display/metadata.js"; | import { Metadata } from "../../src/display/metadata.js"; | ||||||
| 
 | 
 | ||||||
| describe("metadata", function () { | describe("metadata", function () { | ||||||
|  | |||||||
| @ -175,6 +175,14 @@ function createIdFactory(pageIndex) { | |||||||
|   return page.idFactory; |   return page.idFactory; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | function isEmptyObj(obj) { | ||||||
|  |   assert( | ||||||
|  |     typeof obj === "object" && obj !== null, | ||||||
|  |     "isEmptyObj - invalid argument." | ||||||
|  |   ); | ||||||
|  |   return Object.keys(obj).length === 0; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| export { | export { | ||||||
|   DOMFileReaderFactory, |   DOMFileReaderFactory, | ||||||
|   NodeFileReaderFactory, |   NodeFileReaderFactory, | ||||||
| @ -184,4 +192,5 @@ export { | |||||||
|   buildGetDocumentParams, |   buildGetDocumentParams, | ||||||
|   TEST_PDFS_PATH, |   TEST_PDFS_PATH, | ||||||
|   createIdFactory, |   createIdFactory, | ||||||
|  |   isEmptyObj, | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -19,7 +19,6 @@ import { | |||||||
|   createValidAbsoluteUrl, |   createValidAbsoluteUrl, | ||||||
|   isArrayBuffer, |   isArrayBuffer, | ||||||
|   isBool, |   isBool, | ||||||
|   isEmptyObj, |  | ||||||
|   isNum, |   isNum, | ||||||
|   isSameOrigin, |   isSameOrigin, | ||||||
|   isString, |   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 () { |   describe("isNum", function () { | ||||||
|     it("handles numeric values", function () { |     it("handles numeric values", function () { | ||||||
|       expect(isNum(1)).toEqual(true); |       expect(isNum(1)).toEqual(true); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user