-
Notifications
You must be signed in to change notification settings - Fork 615
Fix/js types #2594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fix/js types #2594
Changes from all commits
4056c83
929152e
37c2870
1d5a634
234e8e2
f8c3579
3a7eb4c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,42 @@ | ||
| import { expect, test, describe } from "bun:test"; | ||
| import { describe, expect, test } from "bun:test"; | ||
|
|
||
| describe("D2 CJS Integration", () => { | ||
| test("can require and use CJS build", async () => { | ||
| test("can require main entry point without error", () => { | ||
| expect(() => { | ||
| const module = require("../../dist/node-cjs/index.js"); | ||
| expect(module).toBeDefined(); | ||
| expect(module.D2).toBeDefined(); | ||
| expect(typeof module.D2).toBe("function"); | ||
| }).not.toThrow(); | ||
| }); | ||
|
|
||
| test("worker module file exists", () => { | ||
| const fs = require("fs"); | ||
| const path = require("path"); | ||
| const workerPath = path.resolve(__dirname, "../../dist/node-cjs/worker.js"); | ||
| expect(fs.existsSync(workerPath)).toBe(true); | ||
| }); | ||
|
|
||
| test("exported D2 class is constructable", () => { | ||
| const { D2 } = require("../../dist/node-cjs/index.js"); | ||
| expect(() => new D2()).not.toThrow(); | ||
| }); | ||
|
|
||
| test("module exports match expected structure", () => { | ||
| const module = require("../../dist/node-cjs/index.js"); | ||
| expect(module).toHaveProperty("D2"); | ||
| expect(typeof module.D2).toBe("function"); | ||
| }); | ||
|
|
||
| test("can access both named and default exports", () => { | ||
| const module = require("../../dist/node-cjs/index.js"); | ||
| const { D2 } = require("../../dist/node-cjs/index.js"); | ||
|
|
||
| expect(module.D2).toBe(D2); | ||
| expect(module.D2).toBeDefined(); | ||
| }); | ||
|
|
||
| test("can compile a diagram", async () => { | ||
|
Comment on lines
+4
to
+39
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this seems to have redundancy. how many of these are actually necessary (was failing before) if the "can compile a diagram" test was passing?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (same reply to the esm test changes) |
||
| const { D2 } = require("../../dist/node-cjs/index.js"); | ||
| const d2 = new D2(); | ||
| const result = await d2.compile("x -> y"); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these tests are still importing from the whole path, is there a way to test that it matches what the module/main path is defined as? e.g. require(d2js) and it resolves to the right one. otherwise it looks like there's no tests that exercise the change for module/main export paths.