-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bff8fe3
commit e7eeb8c
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
build-system/compile/generate/test/shared-bento-symbols.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/, | ||
}); | ||
}); |