| 
									
										
										
										
											2022-01-27 14:51:21 +01:00
										 |  |  | describe("basic behavior", () => { | 
					
						
							| 
									
										
										
										
											2025-01-20 11:43:41 -05:00
										 |  |  |     test("can import json modules (with import function)", () => { | 
					
						
							| 
									
										
										
										
											2022-01-27 14:51:21 +01:00
										 |  |  |         let passed = false; | 
					
						
							|  |  |  |         let error = null; | 
					
						
							|  |  |  |         let result = null; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-20 12:07:29 -05:00
										 |  |  |         import("./json-module.json", { with: { type: "json" } }) | 
					
						
							| 
									
										
										
										
											2022-01-27 14:51:21 +01:00
										 |  |  |             .then(jsonObj => { | 
					
						
							|  |  |  |                 passed = true; | 
					
						
							|  |  |  |                 result = jsonObj; | 
					
						
							|  |  |  |             }) | 
					
						
							|  |  |  |             .catch(err => { | 
					
						
							|  |  |  |                 error = err; | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         runQueuedPromiseJobs(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (error) throw error; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         console.log(JSON.stringify(result)); | 
					
						
							|  |  |  |         expect(passed).toBeTrue(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         expect(result).not.toBeNull(); | 
					
						
							|  |  |  |         expect(result).not.toBeUndefined(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         const jsonResult = result.default; | 
					
						
							|  |  |  |         expect(jsonResult).not.toBeNull(); | 
					
						
							|  |  |  |         expect(jsonResult).not.toBeUndefined(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         expect(jsonResult).toHaveProperty("value", "value"); | 
					
						
							|  |  |  |         expect(jsonResult).toHaveProperty("array", [1, 2, 3]); | 
					
						
							|  |  |  |         expect(jsonResult).toHaveProperty("map", { innerValue: "innerValue" }); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2025-01-20 11:43:41 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     test("can import json modules (with import statement)", () => { | 
					
						
							|  |  |  |         let passed = false; | 
					
						
							|  |  |  |         let error = null; | 
					
						
							|  |  |  |         let result = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         import("./json-module.mjs") | 
					
						
							|  |  |  |             .then(jsonObj => { | 
					
						
							|  |  |  |                 passed = true; | 
					
						
							|  |  |  |                 result = jsonObj; | 
					
						
							|  |  |  |             }) | 
					
						
							|  |  |  |             .catch(err => { | 
					
						
							|  |  |  |                 error = err; | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         runQueuedPromiseJobs(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (error) throw error; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         console.log(JSON.stringify(result)); | 
					
						
							|  |  |  |         expect(passed).toBeTrue(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         expect(result).not.toBeNull(); | 
					
						
							|  |  |  |         expect(result).not.toBeUndefined(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         const jsonResult = result.default; | 
					
						
							|  |  |  |         expect(jsonResult).not.toBeNull(); | 
					
						
							|  |  |  |         expect(jsonResult).not.toBeUndefined(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         expect(jsonResult).toHaveProperty("value", "value"); | 
					
						
							|  |  |  |         expect(jsonResult).toHaveProperty("array", [1, 2, 3]); | 
					
						
							|  |  |  |         expect(jsonResult).toHaveProperty("map", { innerValue: "innerValue" }); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2022-01-27 14:51:21 +01:00
										 |  |  | }); |