babel-plugin-tester
Advanced tools
Comparing version 5.3.0 to 5.4.0
@@ -243,45 +243,60 @@ 'use strict'; | ||
function testFixtures(_ref3) { | ||
var plugin = _ref3.plugin, | ||
pluginOptions = _ref3.pluginOptions, | ||
describeBlockTitle = _ref3.title, | ||
fixtures = _ref3.fixtures, | ||
fixtureOutputName = _ref3.fixtureOutputName, | ||
filename = _ref3.filename, | ||
babel = _ref3.babel, | ||
rest = _objectWithoutProperties(_ref3, ['plugin', 'pluginOptions', 'title', 'fixtures', 'fixtureOutputName', 'filename', 'babel']); | ||
var createFixtureTests = function createFixtureTests(fixturesDir, options) { | ||
_fs2.default.readdirSync(fixturesDir).forEach(function (caseName) { | ||
var fixtureDir = _path2.default.join(fixturesDir, caseName); | ||
var codePath = _path2.default.join(fixtureDir, 'code.js'); | ||
var blockTitle = caseName.split('-').join(' '); | ||
describe(`${describeBlockTitle} fixtures`, function () { | ||
var fixturesDir = getPath(filename, fixtures); | ||
_fs2.default.readdirSync(fixturesDir).forEach(function (caseName) { | ||
it(caseName.split('-').join(' '), function () { | ||
var fixtureDir = _path2.default.join(fixturesDir, caseName); | ||
var codePath = _path2.default.join(fixtureDir, 'code.js'); | ||
var babelRcPath = _path2.default.join(fixtureDir, '.babelrc'); | ||
if (!_pathExists2.default.sync(codePath)) { | ||
describe(blockTitle, function () { | ||
createFixtureTests(fixtureDir, options); | ||
}); | ||
return; | ||
} | ||
var _merge2 = (0, _lodash2.default)({}, fullDefaultConfig, { | ||
babelOptions: { | ||
plugins: [[plugin, pluginOptions]], | ||
// if they have a babelrc, then we'll let them use that | ||
// otherwise, we'll just use our simple config | ||
babelrc: _pathExists2.default.sync(babelRcPath) | ||
} | ||
}, rest), | ||
babelOptions = _merge2.babelOptions; | ||
it(blockTitle, function () { | ||
var plugin = options.plugin, | ||
pluginOptions = options.pluginOptions, | ||
fixtureOutputName = options.fixtureOutputName, | ||
babel = options.babel, | ||
rest = _objectWithoutProperties(options, ['plugin', 'pluginOptions', 'fixtureOutputName', 'babel']); | ||
var actual = babel.transformFileSync(codePath, babelOptions).code.trim(); | ||
var babelRcPath = _path2.default.join(fixtureDir, '.babelrc'); | ||
var outputPath = _path2.default.join(fixtureDir, `${fixtureOutputName}.js`); | ||
if (!_fs2.default.existsSync(outputPath)) { | ||
_fs2.default.writeFileSync(outputPath, actual); | ||
return; | ||
var _merge2 = (0, _lodash2.default)({}, fullDefaultConfig, { | ||
babelOptions: { | ||
plugins: [[plugin, pluginOptions]], | ||
// if they have a babelrc, then we'll let them use that | ||
// otherwise, we'll just use our simple config | ||
babelrc: _pathExists2.default.sync(babelRcPath) | ||
} | ||
}, rest), | ||
babelOptions = _merge2.babelOptions; | ||
var output = _fs2.default.readFileSync(outputPath, 'utf8').trim(); | ||
var actual = babel.transformFileSync(codePath, babelOptions).code.trim(); | ||
_assert2.default.equal(actual, output, 'actual output does not match output.js'); | ||
}); | ||
var outputPath = _path2.default.join(fixtureDir, `${fixtureOutputName}.js`); | ||
if (!_fs2.default.existsSync(outputPath)) { | ||
_fs2.default.writeFileSync(outputPath, actual); | ||
return; | ||
} | ||
var output = _fs2.default.readFileSync(outputPath, 'utf8').trim(); | ||
_assert2.default.equal(actual, output, 'actual output does not match output.js'); | ||
}); | ||
}); | ||
}; | ||
function testFixtures(_ref3) { | ||
var describeBlockTitle = _ref3.title, | ||
fixtures = _ref3.fixtures, | ||
filename = _ref3.filename, | ||
rest = _objectWithoutProperties(_ref3, ['title', 'fixtures', 'filename']); | ||
describe(`${describeBlockTitle} fixtures`, function () { | ||
var fixturesDir = getPath(filename, fixtures); | ||
createFixtureTests(fixturesDir, rest); | ||
}); | ||
} | ||
@@ -288,0 +303,0 @@ |
@@ -1,1 +0,1 @@ | ||
{"name":"babel-plugin-tester","version":"5.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 precommit"},"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":"^6.25.0","babel-plugin-syntax-trailing-function-commas":"^6.22.0","babel-plugin-transform-async-generator-functions":"^6.24.1","babel-plugin-transform-async-to-generator":"^6.24.1","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-preset-env":"^1.5.2","kcd-scripts":"^0.16.3"},"peerDependencies":{"babel-core":"^6.0.0 || ^7.0.0-alpha || ^7.0.0-beta || ^7.0.0"},"eslintConfig":{"extends":"./node_modules/kcd-scripts/eslint.js","rules":{"max-lines":0}},"eslintIgnore":["node_modules","coverage","dist","fixtures"],"babel":{"presets":[["env",{"targets":{"node":"4.5"},"exclude":["transform-regenerator"]}]],"plugins":["babel-plugin-syntax-trailing-function-commas","transform-async-to-generator","transform-async-generator-functions","transform-object-rest-spread"]},"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":"5.4.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 precommit"},"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":"^6.25.0","babel-plugin-syntax-trailing-function-commas":"^6.22.0","babel-plugin-transform-async-generator-functions":"^6.24.1","babel-plugin-transform-async-to-generator":"^6.24.1","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-preset-env":"^1.5.2","kcd-scripts":"^0.16.3"},"peerDependencies":{"babel-core":"^6.0.0 || ^7.0.0-alpha || ^7.0.0-beta || ^7.0.0"},"eslintConfig":{"extends":"./node_modules/kcd-scripts/eslint.js","rules":{"max-lines":0}},"eslintIgnore":["node_modules","coverage","dist","fixtures"],"babel":{"presets":[["env",{"targets":{"node":"4.5"},"exclude":["transform-regenerator"]}]],"plugins":["babel-plugin-syntax-trailing-function-commas","transform-async-to-generator","transform-async-generator-functions","transform-object-rest-spread"]},"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"} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32526
312