json-modules.js 995 B

12345678910111213141516171819202122232425262728293031323334
  1. describe("basic behavior", () => {
  2. test("can import json modules", () => {
  3. let passed = false;
  4. let error = null;
  5. let result = null;
  6. import("./json-module.json", { assert: { type: "json" } })
  7. .then(jsonObj => {
  8. passed = true;
  9. result = jsonObj;
  10. })
  11. .catch(err => {
  12. error = err;
  13. });
  14. runQueuedPromiseJobs();
  15. if (error) throw error;
  16. console.log(JSON.stringify(result));
  17. expect(passed).toBeTrue();
  18. expect(result).not.toBeNull();
  19. expect(result).not.toBeUndefined();
  20. const jsonResult = result.default;
  21. expect(jsonResult).not.toBeNull();
  22. expect(jsonResult).not.toBeUndefined();
  23. expect(jsonResult).toHaveProperty("value", "value");
  24. expect(jsonResult).toHaveProperty("array", [1, 2, 3]);
  25. expect(jsonResult).toHaveProperty("map", { innerValue: "innerValue" });
  26. });
  27. });