Skip to content

Commit

Permalink
add tests for named-asset-imports plugin (#5575)
Browse files Browse the repository at this point in the history
* add tests for named-asset-imports plugin

* add ticketFormats store/saga

* change import to require on test file to avoid using babel when running tests

* remove all babel dependencies as not needed more for running tests

* update tests and rename file to index.test.js

* remove npmignore as it is whitelisted in package.json

* add babel-plugin-named-asset-import tests to e2e
  • Loading branch information
NShahri authored and iansu committed Oct 31, 2018
1 parent 6311bac commit 337541b
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
50 changes: 50 additions & 0 deletions packages/babel-plugin-named-asset-import/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const pluginTester = require('babel-plugin-tester');
const namedAssetImport = require('./index');

pluginTester({
plugin: namedAssetImport,
pluginOptions: {
loaderMap: {
svg: {
ReactComponent: '@svgr/webpack?-prettier,-svgo![path]',
},
},
},
pluginName: 'named-asset-import',
snapshot: false,
tests: {
defaultImport: {
code: 'import logo from "logo";',
output: 'import logo from "logo";',
},
namedImport: {
code: 'import { logo } from "logo";',
output: 'import { logo } from "logo";',
},
namedImportRenamed: {
code: 'import { Url as logo1 } from "logo";',
output: 'import { Url as logo1 } from "logo";',
},
svgDefaultImport: {
code: 'import logo from "logo.svg";',
output: 'import logo from "logo.svg";',
},
svgNamedImport: {
code: 'import { logo } from "logo.svg";',
output: 'import { logo } from "logo.svg";',
},
svgReactComponentNamedImport: {
code: 'import { ReactComponent as logo } from "logo.svg";',
output:
'import { ReactComponent as logo } from "@svgr/webpack?-prettier,-svgo!logo.svg";',
},
svgMultipleImport: {
code:
'import logo, { logoUrl , ReactComponent as Logo } from "logo.svg";',
output:
'import logo from "logo.svg";\n' +
'import { logoUrl } from "logo.svg";\n' +
'import { ReactComponent as Logo } from "@svgr/webpack?-prettier,-svgo!logo.svg";',
},
},
});
7 changes: 7 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,12 @@
],
"peerDependencies": {
"@babel/core": "^7.1.0"
},
"devDependencies": {
"babel-plugin-tester": "^5.5.1",
"jest": "^23.6.0"
},
"scripts": {
"test": "jest"
}
}
4 changes: 4 additions & 0 deletions tasks/e2e-simple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ cd packages/react-dev-utils/
yarn test
cd ../..

cd packages/babel-plugin-named-asset-import/
yarn test
cd ../..

cd packages/confusing-browser-globals/
yarn test
cd ../..
Expand Down

0 comments on commit 337541b

Please sign in to comment.