Skip to content

Commit 1cc90b6

Browse files
committed
test(harden): add cjs(entrypoint) & negative test
1 parent 2c47417 commit 1cc90b6

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Errors Loader Error 1`] = `"Cannot read property 'version' of undefined"`;
4+
5+
exports[`Errors Validation Error 1`] = `
6+
"binaryen-loader
7+
8+
Options Validation Error
9+
10+
options['useRelativePath'] is an invalid additional property
11+
"
12+
`;

test/cjs.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import loader from '../src';
2+
import CJSLoader from '../src/cjs';
3+
4+
describe('CJS', () => {
5+
it('should export loader', () => {
6+
expect(CJSLoader).toEqual(loader);
7+
});
8+
9+
it('should export `raw` flag', () => {
10+
expect(CJSLoader.raw).toEqual(false);
11+
});
12+
});

test/error.test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import loader from '../src';
2+
3+
describe('Errors', () => {
4+
test('Loader Error', () => {
5+
const err = () => loader.call();
6+
7+
expect(err).toThrow();
8+
expect(err).toThrowErrorMatchingSnapshot();
9+
});
10+
11+
test('Validation Error', () => {
12+
const err = () =>
13+
loader.call({
14+
query: { useRelativePath: 1 },
15+
emitFile: true,
16+
});
17+
18+
expect(err).toThrow();
19+
expect(err).toThrowErrorMatchingSnapshot();
20+
});
21+
});

0 commit comments

Comments
 (0)