Skip to content

Commit

Permalink
Add test for Option Parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroppy committed Feb 26, 2018
1 parent 971dac8 commit 81f3763
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
18 changes: 18 additions & 0 deletions __tests__/__snapshots__/upgradeConfig.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`convert comma separated presets/plugins into an array 1`] = `
Object {
"env": Object {
"development": Object {
"plugins": Array [
"babel-plugin-istanbul, transform-react-jsx-source, babel-plugin-transform-react-inline-elements",
],
},
},
"plugins": Array [
"babel-plugin-transform-function-bind, transform-class-properties",
],
"presets": Array [
"@babel/preset-env, @babel/preset-react",
],
}
`;

exports[`package that is removed 1`] = `
Object {
"plugins": Array [
Expand Down
5 changes: 5 additions & 0 deletions __tests__/upgradeConfig.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const path = require('path');
const upgradeConfig = require('../src/upgradeConfig');
const babelrcFixture = require('../fixtures/babelrc');
const optionParsingFixture = require('../fixtures/option-parsing');
const { readBabelRC } = require('../src');
const JSON5_PATH = path.resolve(__dirname, '../fixtures/babelrc.json5');

Expand Down Expand Up @@ -38,3 +39,7 @@ test('packages (json5)', async () => {
const json5Data = await readBabelRC(JSON5_PATH);
expect(upgradeConfig(json5Data)).toMatchSnapshot();
});

test('convert comma separated presets/plugins into an array', () => {
expect(upgradeConfig(optionParsingFixture)).toMatchSnapshot();
});
9 changes: 9 additions & 0 deletions fixtures/option-parsing.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"presets": "@babel/preset-env, @babel/preset-react",
"plugins": "babel-plugin-transform-function-bind, transform-class-properties",
"env": {
"development": {
"plugins": "babel-plugin-istanbul, transform-react-jsx-source, babel-plugin-transform-react-inline-elements"
}
}
}

0 comments on commit 81f3763

Please sign in to comment.