Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
alanorozco committed Dec 3, 2021
1 parent bff8fe3 commit e7eeb8c
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions build-system/compile/generate/test/shared-bento-symbols.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const dedent = require('dedent');
const test = require('ava');
const {getExportedSymbols} = require('../shared-bento-symbols');

test('getExportedSymbols', (t) => {
t.deepEqual(
getExportedSymbols(
dedent(`
export const foo = 'foo';
export function bar() {}
export class Baz {}
export {qux} from './qux';
`)
),
['foo', 'bar', 'Baz', 'qux']
);
});

test('getExportedSymbols fails with export *', (t) => {
t.throws(() => getExportedSymbols("export * from './qux';"), {
message: /export */,
});
});

test('getExportedSymbols fails with export default', (t) => {
t.throws(() => getExportedSymbols("export default 'foo';"), {
message: /export default/,
});
});

test('getExportedSymbols fails with export from default', (t) => {
t.throws(() => getExportedSymbols("export foo from 'foo';"), {
message: /export from a default import/,
});
});

test('getExportedSymbols fails with exported namespace', (t) => {
t.throws(() => getExportedSymbols("export * as foo from 'foo';"), {
message: /export a namespace/,
});
});

test('getExportedSymbols fails with exported x as y', (t) => {
t.throws(() => getExportedSymbols("export {x as y} from 'x';"), {
message: /should match local name/,
});
});

0 comments on commit e7eeb8c

Please sign in to comment.