Skip to content

Commit c6952ce

Browse files
authored
test: add unit test for json module export detection (#1452)
1 parent 3ce6ad9 commit c6952ce

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/unit/shared/utils/package-analysis.spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,27 @@ describe('detectModuleFormat', () => {
9191
// npm treats packages without type field as CommonJS
9292
expect(detectModuleFormat({})).toBe('cjs')
9393
})
94+
95+
it('detect dual from JSON exports', () => {
96+
expect(
97+
detectModuleFormat({
98+
main: 'test.json',
99+
exports: {
100+
'.': './test.json',
101+
},
102+
}),
103+
).toBe('dual')
104+
})
105+
106+
it('detect esm from JSON exports', () => {
107+
expect(
108+
detectModuleFormat({
109+
exports: {
110+
'.': './test.json',
111+
},
112+
}),
113+
).toBe('esm')
114+
})
94115
})
95116

96117
describe('detectTypesStatus', () => {

0 commit comments

Comments
 (0)