Skip to content

Commit

Permalink
fix a bunch of tests that were failing
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffshaver committed Feb 24, 2019
1 parent bdc05aa commit a477df1
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 15 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"watch": "cross-env NODE_PATH=./src mocha --watch --compilers js:babel-register --recursive tests/src",
"pretest": "linklocal",
"posttest": "eslint ./src",
"testpath": "cross-env BABEL_ENV=test NODE_PATH=./src nyc -s mocha -R dot -t 5s",
"test": "cross-env BABEL_ENV=test NODE_PATH=./src nyc -s mocha -R dot --recursive tests/src -t 5s",
"test-compiled": "npm run prepublish && NODE_PATH=./lib mocha --compilers js:babel-register --recursive tests/src",
"test-all": "npm test && for resolver in ./resolvers/*; do cd $resolver && npm test && cd ../..; done",
Expand Down
6 changes: 3 additions & 3 deletions tests/src/rules/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ ruleTester.run('export', rule, {
test({ code: 'export var [ foo, bar ] = array;' }),
test({ code: 'export var { foo, bar } = object;' }),
test({ code: 'export var [ foo, bar ] = array;' }),
test({ code: 'export { foo, foo as bar }' }),
test({ code: 'export { bar }; export * from "./export-all"' }),
test({ code: 'let foo; export { foo, foo as bar }' }),
test({ code: 'let bar; export { bar }; export * from "./export-all"' }),
test({ code: 'export * from "./export-all"' }),
test({ code: 'export * from "./does-not-exist"' }),

Expand Down Expand Up @@ -62,7 +62,7 @@ ruleTester.run('export', rule, {
// errors: ['Parsing error: Duplicate export \'foo\''],
// }),
test({
code: 'export { foo }; export * from "./export-all"',
code: 'let foo; export { foo }; export * from "./export-all"',
errors: ['Multiple exports of name \'foo\'.',
'Multiple exports of name \'foo\'.'],
}),
Expand Down
8 changes: 4 additions & 4 deletions tests/src/rules/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ ruleTester.run('extensions', rule, {
test({
code: [
'export { foo } from "./foo.js"',
'export { bar }',
'let bar; export { bar }',
].join('\n'),
options: [ 'always' ],
}),
test({
code: [
'export { foo } from "./foo"',
'export { bar }',
'let bar; export { bar }',
].join('\n'),
options: [ 'never' ],
}),
Expand Down Expand Up @@ -334,7 +334,7 @@ ruleTester.run('extensions', rule, {
test({
code: [
'export { foo } from "./foo"',
'export { bar }',
'let bar; export { bar }',
].join('\n'),
options: [ 'always' ],
errors: [
Expand All @@ -348,7 +348,7 @@ ruleTester.run('extensions', rule, {
test({
code: [
'export { foo } from "./foo.js"',
'export { bar }',
'let bar; export { bar }',
].join('\n'),
options: [ 'never' ],
errors: [
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/named.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ ruleTester.run('named', rule, {
}),

// regression tests
test({ code: 'export { foo as bar }'}),
test({ code: 'let foo; export { foo as bar }'}),

// destructured exports
test({ code: 'import { destructuredProp } from "./named-exports"' }),
Expand Down
5 changes: 3 additions & 2 deletions tests/src/rules/no-default-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ruleTester.run('no-default-export', rule, {
`,
}),
test({
code: `export { foo, bar }`,
code: `let foo, bar; export { foo, bar }`,
}),
test({
code: `export const { foo, bar } = item;`,
Expand All @@ -42,6 +42,7 @@ ruleTester.run('no-default-export', rule, {
}),
test({
code: `
let item;
export const foo = item;
export { item };
`,
Expand Down Expand Up @@ -102,7 +103,7 @@ ruleTester.run('no-default-export', rule, {
}],
}),
test({
code: 'export { foo as default }',
code: 'let foo; export { foo as default }',
errors: [{
ruleId: 'ExportNamedDeclaration',
message: 'Do not alias `foo` as `default`. Just export `foo` itself ' +
Expand Down
5 changes: 3 additions & 2 deletions tests/src/rules/no-named-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ruleTester.run('no-named-export', rule, {
code: 'export default function bar() {};',
}),
test({
code: 'export { foo as default }',
code: 'let foo; export { foo as default }',
}),
test({
code: 'export default from "foo.js"',
Expand Down Expand Up @@ -82,7 +82,7 @@ ruleTester.run('no-named-export', rule, {
}],
}),
test({
code: `export { foo, bar }`,
code: `let foo, bar; export { foo, bar }`,
errors: [{
ruleId: 'ExportNamedDeclaration',
message: 'Named exports are not allowed.',
Expand Down Expand Up @@ -111,6 +111,7 @@ ruleTester.run('no-named-export', rule, {
}),
test({
code: `
let item;
export const foo = item;
export { item };
`,
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-unresolved.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function runResolverTests(resolver) {

rest({ code: 'export { foo } from "./bar"' }),
rest({ code: 'export * from "./bar"' }),
rest({ code: 'export { foo }' }),
rest({ code: 'let foo; export { foo }' }),

// stage 1 proposal for export symmetry,
rest({ code: 'export * as bar from "./bar"'
Expand Down
3 changes: 3 additions & 0 deletions tests/src/rules/prefer-default-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ ruleTester.run('prefer-default-export', rule, {
}),
test({
code: `
let foo, bar;
export { foo, bar }`,
}),
test({
Expand All @@ -44,11 +45,13 @@ ruleTester.run('prefer-default-export', rule, {
}),
test({
code: `
let item;
export const foo = item;
export { item };`,
}),
test({
code: `
let foo;
export { foo as default }`,
}),
test({
Expand Down
4 changes: 2 additions & 2 deletions tests/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export const SYNTAX_CASES = [
test({ code: 'const { x, y, ...z } = bar', parser: 'babel-eslint' }),

// all the exports
test({ code: 'export { x }' }),
test({ code: 'export { x as y }' }),
test({ code: 'let x; export { x }' }),
test({ code: 'let x; export { x as y }' }),

// not sure about these since they reference a file
// test({ code: 'export { x } from "./y.js"'}),
Expand Down

0 comments on commit a477df1

Please sign in to comment.