mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-01-12 17:12:59 +08:00
add tests for named-asset-imports plugin (#5575)
* 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
This commit is contained in:
committed by
Ian Sutherland
parent
6311bac13e
commit
337541b452
50
packages/babel-plugin-named-asset-import/index.test.js
Normal file
50
packages/babel-plugin-named-asset-import/index.test.js
Normal file
@@ -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";',
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -13,5 +13,12 @@
|
||||
],
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-plugin-tester": "^5.5.1",
|
||||
"jest": "^23.6.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jest"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 ../..
|
||||
|
||||
Reference in New Issue
Block a user