Skip to content

Commit 184d7a6

Browse files
test(graph): cover getOwnExportInfo, which nothing in lib calls
1 parent 3e9d65e commit 184d7a6

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

‎test/unitCases/ExportsInfo.unittest.js‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,28 @@ describe("ExportsInfo", () => {
196196
expect(exportsInfo._hasInlinedExports).toBe(false);
197197
});
198198

199+
it("getOwnExportInfo creates an owned export info and reuses it", () => {
200+
const exportsInfo = new ExportsInfo();
201+
expect([...exportsInfo.ownedExports]).toHaveLength(0);
202+
203+
const created = exportsInfo.getOwnExportInfo("foo");
204+
205+
expect(created.name).toBe("foo");
206+
expect([...exportsInfo.ownedExports]).toEqual([created]);
207+
expect(exportsInfo.getOwnExportInfo("foo")).toBe(created);
208+
});
209+
210+
it("getOwnExportInfo owns the export a redirect would have answered", () => {
211+
const exportsInfo = new ExportsInfo();
212+
const redirectTarget = new ExportsInfo();
213+
exportsInfo.setRedirectNamedTo(redirectTarget);
214+
const redirected = redirectTarget.getExportInfo("foo");
215+
216+
// getExportInfo follows the redirect, getOwnExportInfo never does
217+
expect(exportsInfo.getExportInfo("foo")).toBe(redirected);
218+
expect(exportsInfo.getOwnExportInfo("foo")).not.toBe(redirected);
219+
});
220+
199221
it("_resetUsedExports does not wipe a redirect target owned by another module", () => {
200222
const exportsInfo = new ExportsInfo();
201223
const redirectTarget = new ExportsInfo();

0 commit comments

Comments
 (0)