babel-plugin-tester
Advanced tools
Comparing version 6.2.1 to 6.3.0
@@ -803,3 +803,51 @@ "use strict"; | ||
})); | ||
test('appends to root plugins array', | ||
/*#__PURE__*/ | ||
_asyncToGenerator(function* () { | ||
var optionRootFoo = jest.fn(); | ||
var optionFoo = jest.fn(); | ||
var optionBar = jest.fn(); | ||
var pluginWithOptions = jest.fn(function () { | ||
return { | ||
visitor: { | ||
Program(programPath, state) { | ||
if (state.opts.rootFoo === 'rootBar') { | ||
optionRootFoo(); | ||
} | ||
if (state.opts.foo === 'bar') { | ||
optionFoo(); | ||
} | ||
if (state.opts.bar === 'baz') { | ||
optionBar(); | ||
} | ||
} | ||
} | ||
}; | ||
}); | ||
var programVisitor = jest.fn(); | ||
var otherPlugin = function otherPlugin() { | ||
return { | ||
visitor: { | ||
Program: programVisitor | ||
} | ||
}; | ||
}; | ||
yield runPluginTester(getOptions({ | ||
plugin: pluginWithOptions, | ||
fixtures: getFixturePath('fixtures'), | ||
babelOptions: { | ||
plugins: [otherPlugin] | ||
} | ||
})); | ||
expect(optionRootFoo).toHaveBeenCalledTimes(8); | ||
expect(optionFoo).toHaveBeenCalledTimes(2); | ||
expect(optionBar).toHaveBeenCalledTimes(1); | ||
expect(programVisitor).toHaveBeenCalledTimes(9); | ||
})); | ||
function getOptions(overrides) { | ||
@@ -806,0 +854,0 @@ return _objectSpread({ |
@@ -11,3 +11,3 @@ "use strict"; | ||
var _lodash = _interopRequireDefault(require("lodash.merge")); | ||
var _lodash = _interopRequireDefault(require("lodash.mergewith")); | ||
@@ -45,2 +45,10 @@ var _invariant = _interopRequireDefault(require("invariant")); | ||
function mergeCustomizer(objValue, srcValue) { | ||
if (Array.isArray(objValue)) { | ||
return objValue.concat(srcValue); | ||
} | ||
return undefined; | ||
} | ||
function pluginTester() { | ||
@@ -86,3 +94,3 @@ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var testerConfig = (0, _lodash.default)({}, fullDefaultConfig, rest); | ||
var testerConfig = (0, _lodash.default)({}, fullDefaultConfig, rest, mergeCustomizer); | ||
describe(describeBlockTitle, function () { | ||
@@ -94,18 +102,18 @@ testAsArray.forEach(function (testConfig) { | ||
var _merge = (0, _lodash.default)({}, testerConfig, toTestConfig(testConfig)), | ||
skip = _merge.skip, | ||
only = _merge.only, | ||
title = _merge.title, | ||
code = _merge.code, | ||
babelOptions = _merge.babelOptions, | ||
output = _merge.output, | ||
snapshot = _merge.snapshot, | ||
error = _merge.error, | ||
_merge$setup = _merge.setup, | ||
setup = _merge$setup === void 0 ? noop : _merge$setup, | ||
teardown = _merge.teardown, | ||
_merge$formatResult = _merge.formatResult, | ||
formatResult = _merge$formatResult === void 0 ? function (r) { | ||
var _mergeWith = (0, _lodash.default)({}, testerConfig, toTestConfig(testConfig), mergeCustomizer), | ||
skip = _mergeWith.skip, | ||
only = _mergeWith.only, | ||
title = _mergeWith.title, | ||
code = _mergeWith.code, | ||
babelOptions = _mergeWith.babelOptions, | ||
output = _mergeWith.output, | ||
snapshot = _mergeWith.snapshot, | ||
error = _mergeWith.error, | ||
_mergeWith$setup = _mergeWith.setup, | ||
setup = _mergeWith$setup === void 0 ? noop : _mergeWith$setup, | ||
teardown = _mergeWith.teardown, | ||
_mergeWith$formatResu = _mergeWith.formatResult, | ||
formatResult = _mergeWith$formatResu === void 0 ? function (r) { | ||
return r; | ||
} : _merge$formatResult; | ||
} : _mergeWith$formatResu; | ||
@@ -237,3 +245,3 @@ (0, _assert.default)(!skip && !only || skip !== only, 'Cannot enable both skip and only on a test'); | ||
output: (0, _stripIndent.default)(output).trim() | ||
} : {})); | ||
} : {}), mergeCustomizer); | ||
} | ||
@@ -293,3 +301,3 @@ } | ||
var _merge2 = (0, _lodash.default)({}, fullDefaultConfig, { | ||
var _mergeWith2 = (0, _lodash.default)({}, fullDefaultConfig, { | ||
babelOptions: { | ||
@@ -301,4 +309,4 @@ plugins: [[plugin, _objectSpread({}, rootFixtureOptions, pluginOptions, fixturePluginOptions)]], | ||
} | ||
}, rest), | ||
babelOptions = _merge2.babelOptions; | ||
}, rest, mergeCustomizer), | ||
babelOptions = _mergeWith2.babelOptions; | ||
@@ -305,0 +313,0 @@ var actual = formatResult(babel.transformFileSync(codePath, babelOptions).code.trim()); |
@@ -1,1 +0,1 @@ | ||
{"name":"babel-plugin-tester","version":"6.2.1","description":"Utilities for testing babel plugins","main":"dist/index.js","engines":{"node":"> 4","npm":"> 3"},"scripts":{"add-contributor":"kcd-scripts contributors add","build":"kcd-scripts build","lint":"kcd-scripts lint","test":"kcd-scripts test","test:update":"npm test -- --updateSnapshot --coverage","validate":"kcd-scripts validate","precommit":"kcd-scripts pre-commit"},"files":["dist"],"keywords":[],"author":"Kent C. Dodds <kent@doddsfamily.us> (http://kentcdodds.com/)","license":"MIT","dependencies":{"common-tags":"^1.4.0","invariant":"^2.2.2","lodash.merge":"^4.6.0","path-exists":"^3.0.0","strip-indent":"^2.0.0"},"devDependencies":{"@babel/core":"^7.2.0","@babel/plugin-proposal-async-generator-functions":"^7.2.0","@babel/plugin-transform-async-to-generator":"^7.2.0","@babel/preset-env":"^7.2.0","kcd-scripts":"^0.49.0"},"peerDependencies":{"@babel/core":"^7.0.0"},"eslintConfig":{"extends":"./node_modules/kcd-scripts/eslint.js","rules":{"max-lines":0,"max-lines-per-function":0,"prefer-object-spread":0,"no-useless-catch":0,"babel/camelcase":0,"babel/valid-typeof":0,"babel/no-unused-expressions":0,"babel/quotes":0,"jest/prefer-todo":0}},"eslintIgnore":["node_modules","coverage","dist","fixtures"],"babel":{"presets":[["@babel/preset-env",{"targets":{"node":"4.5"},"exclude":["transform-regenerator"]}]],"plugins":["@babel/plugin-transform-async-to-generator","@babel/plugin-proposal-async-generator-functions","@babel/plugin-proposal-object-rest-spread"]},"prettier":{"printWidth":80,"bracketSpacing":false,"semi":false,"singleQuote":true,"trailingComma":"all"},"repository":{"type":"git","url":"https://github.com/babel-utils/babel-plugin-tester.git"},"bugs":{"url":"https://github.com/babel-utils/babel-plugin-tester/issues"},"homepage":"https://github.com/babel-utils/babel-plugin-tester#readme"} | ||
{"name":"babel-plugin-tester","version":"6.3.0","description":"Utilities for testing babel plugins","main":"dist/index.js","engines":{"node":"> 4","npm":"> 3"},"scripts":{"add-contributor":"kcd-scripts contributors add","build":"kcd-scripts build","lint":"kcd-scripts lint","test":"kcd-scripts test","test:update":"npm test -- --updateSnapshot --coverage","validate":"kcd-scripts validate","precommit":"kcd-scripts pre-commit"},"files":["dist"],"keywords":[],"author":"Kent C. Dodds <kent@doddsfamily.us> (http://kentcdodds.com/)","license":"MIT","dependencies":{"common-tags":"^1.4.0","invariant":"^2.2.2","lodash.mergewith":"^4.6.0","path-exists":"^3.0.0","strip-indent":"^2.0.0"},"devDependencies":{"@babel/core":"^7.2.0","@babel/plugin-proposal-async-generator-functions":"^7.2.0","@babel/plugin-transform-async-to-generator":"^7.2.0","@babel/preset-env":"^7.2.0","kcd-scripts":"^0.49.0"},"peerDependencies":{"@babel/core":"^7.0.0"},"eslintConfig":{"extends":"./node_modules/kcd-scripts/eslint.js","rules":{"max-lines":0,"max-lines-per-function":0,"prefer-object-spread":0,"no-useless-catch":0,"babel/camelcase":0,"babel/valid-typeof":0,"babel/no-unused-expressions":0,"babel/quotes":0,"jest/prefer-todo":0}},"eslintIgnore":["node_modules","coverage","dist","fixtures"],"babel":{"presets":[["@babel/preset-env",{"targets":{"node":"4.5"},"exclude":["transform-regenerator"]}]],"plugins":["@babel/plugin-transform-async-to-generator","@babel/plugin-proposal-async-generator-functions","@babel/plugin-proposal-object-rest-spread"]},"prettier":{"printWidth":80,"bracketSpacing":false,"semi":false,"singleQuote":true,"trailingComma":"all"},"repository":{"type":"git","url":"https://github.com/babel-utils/babel-plugin-tester.git"},"bugs":{"url":"https://github.com/babel-utils/babel-plugin-tester/issues"},"homepage":"https://github.com/babel-utils/babel-plugin-tester#readme"} |
@@ -335,3 +335,3 @@ # babel-plugin-tester | ||
// these will be `lodash.merge`d with the test objects | ||
// these will be `lodash.mergeWith`d with the test objects | ||
// below are the defaults: | ||
@@ -473,2 +473,3 @@ babelOptions: { | ||
| [<img src="https://avatars0.githubusercontent.com/u/3842800?v=4" width="100px;" alt="Kristoffer K."/><br /><sub><b>Kristoffer K.</b></sub>](https://github.com/merceyz)<br />[💻](https://github.com/babel-utils/babel-plugin-tester/commits?author=merceyz "Code") | | ||
<!-- ALL-CONTRIBUTORS-LIST:END --> | ||
@@ -515,3 +516,3 @@ | ||
[all-contributors]: https://github.com/kentcdodds/all-contributors | ||
[lodash.merge]: https://lodash.com/docs/4.17.4#merge | ||
[lodash.mergewith]: https://lodash.com/docs/4.17.4#mergeWith | ||
[ruletester]: http://eslint.org/docs/developer-guide/working-with-rules#rule-unit-tests | ||
@@ -518,0 +519,0 @@ [@thejameskyle]: https://github.com/thejameskyle |
66218
1229
519
+ Addedlodash.mergewith@^4.6.0
+ Addedlodash.mergewith@4.6.2(transitive)
- Removedlodash.merge@^4.6.0
- Removedlodash.merge@4.6.2(transitive)