Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions test/es6.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ import check from './utils.js';
const testSuite = suite('module-types');

testSuite('detects es6 imports', () => {
assert.ok(check('import {foo, bar} from "mylib";', isES6Import, true));
assert.ok(check('import * as foo from "mod.js";', isES6Import, true));
assert.ok(check('import "mylib2";', isES6Import, true));
assert.ok(check('import foo from "mod.js";', isES6Import, true));
assert.ok(check('import("foo");', isES6Import, true));
assert.ok(check('import {foo, bar} from "mylib";', isES6Import));
assert.ok(check('import * as foo from "mod.js";', isES6Import));
assert.ok(check('import "mylib2";', isES6Import));
assert.ok(check('import foo from "mod.js";', isES6Import));
assert.ok(check('import("foo");', isES6Import));
});

testSuite('detects es6 exports', () => {
assert.ok(check('export default 123;', isES6Export, true));
assert.ok(check('export {foo, bar}; function foo() {} function bar() {}', isES6Export, true));
assert.ok(check('export { D as default }; class D {}', isES6Export, true));
assert.ok(check('export function inc() { counter++; }', isES6Export, true));
assert.ok(check('export * from "mod";', isES6Export, true));
assert.ok(check('export default 123;', isES6Export));
assert.ok(check('export {foo, bar}; function foo() {} function bar() {}', isES6Export));
assert.ok(check('export { D as default }; class D {}', isES6Export));
assert.ok(check('export function inc() { counter++; }', isES6Export));
assert.ok(check('export * from "mod";', isES6Export));
});

testSuite('detects dynamic imports', () => {
assert.ok(check('import("./bar");', isDynamicImport, true));
assert.ok(check('function foo() { import("./bar"); }', isDynamicImport, true));
assert.ok(check('import("./bar");', isDynamicImport));
assert.ok(check('function foo() { import("./bar"); }', isDynamicImport));
});

testSuite.run();
2 changes: 1 addition & 1 deletion test/is-require.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ testSuite('detects top-level (i.e., top of file) require function calls', () =>

testSuite('does not fail on es6', () => {
assert.not.throws(() => {
check('import require from "mylib"; \nrequire();', isTopLevelRequire, true);
check('import require from "mylib"; \nrequire();', isTopLevelRequire);
});
});

Expand Down
4 changes: 2 additions & 2 deletions test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import Walker from 'node-source-walk';

// Checks whether or not the checker succeeds on
// a node in the AST of the given source code
function check(code, checker, harmony) {
const walker = new Walker({ esprimaHarmony: Boolean(harmony) });
function check(code, checker) {
const walker = new Walker();
let found = false;

walker.walk(code, node => {
Expand Down