Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tests for named-asset-imports plugin #5575

Merged
merged 8 commits into from
Oct 31, 2018
3 changes: 3 additions & 0 deletions packages/babel-plugin-named-asset-import/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-env"]
NShahri marked this conversation as resolved.
Show resolved Hide resolved
}
2 changes: 2 additions & 0 deletions packages/babel-plugin-named-asset-import/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.spec.js
NShahri marked this conversation as resolved.
Show resolved Hide resolved
.babelrc
38 changes: 38 additions & 0 deletions packages/babel-plugin-named-asset-import/index.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import pluginTester from 'babel-plugin-tester';
import namedAssetImport from './index';

pluginTester({
plugin: namedAssetImport,
pluginOptions: {
loaderMap: {
svg: {
ReactComponent: '@svgr/webpack?-prettier,-svgo![path]',
},
},
},
pluginName: 'named-asset-import',
snapshot: false,
tests: {
defaultImport: {
code: 'import foo from "foo";',
NShahri marked this conversation as resolved.
Show resolved Hide resolved
output: 'import foo from "foo";',
},
namedImport: {
code: 'import { foo } from "foo";',
output: 'import { foo } from "foo";',
},
namedImportRenamed: {
code: 'import { foo as foo1 } from "foo.svg";',
output: 'import { foo as foo1 } from "foo.svg";',
},
svgNamedImport: {
code: 'import { Url as foo1 } from "foo.svg";',
output: 'import { Url as foo1 } from "foo.svg";',
},
svgReactComponentNamedImport: {
code: 'import { ReactComponent as foo1 } from "foo.svg";',
output:
'import { ReactComponent as foo1 } from "@svgr/webpack?-prettier,-svgo!foo.svg";',
},
},
});
11 changes: 11 additions & 0 deletions packages/babel-plugin-named-asset-import/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,16 @@
],
"peerDependencies": {
"@babel/core": "^7.1.0"
},
"devDependencies": {
"@babel/preset-env": "^7.1.0",
NShahri marked this conversation as resolved.
Show resolved Hide resolved
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^23.6.0",
NShahri marked this conversation as resolved.
Show resolved Hide resolved
"babel-plugin-tester": "^5.5.1",
"jest": "^23.6.0",
"regenerator-runtime": "^0.12.1"
},
"scripts": {
"test": "jest"
}
}