Skip to content

Commit

Permalink
test(babel-plugin-espower): bring comprehensive testsuite back
Browse files Browse the repository at this point in the history
  • Loading branch information
twada committed Oct 31, 2015
1 parent ad3e3f8 commit d1b3361
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 68 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
},
"devDependencies": {
"babel-core": "^6.0.10",
"babel-preset-es2015": "^6.0.0",
"mocha": "^2.2.4"
},
"directories": {
Expand Down Expand Up @@ -51,6 +52,6 @@
"url": "http://github.com/power-assert-js/babel-plugin-espower.git"
},
"scripts": {
"test": "mocha"
"test": "mocha --timeout 7000"
}
}
8 changes: 4 additions & 4 deletions test/fixtures/ArrayExpression/expected.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
'use strict';

assert(assert._expr(assert._capt([assert._capt(foo, 'arguments/0/elements/0'), assert._capt(bar, 'arguments/0/elements/1')], 'arguments/0'), {
content: 'assert([foo,bar])',
content: 'assert([foo, bar])',
filepath: 'test/fixtures/ArrayExpression/fixture.js',
line: 3
}));

assert(assert._expr(assert._capt(assert._capt(typeof assert._capt([assert._capt([assert._capt(assert._capt(foo, 'arguments/0/left/argument/elements/0/elements/0/object').bar, 'arguments/0/left/argument/elements/0/elements/0'), assert._capt(baz(assert._capt(moo, 'arguments/0/left/argument/elements/0/elements/1/arguments/0')), 'arguments/0/left/argument/elements/0/elements/1')], 'arguments/0/left/argument/elements/0'), assert._capt(+assert._capt(fourStr, 'arguments/0/left/argument/elements/1/argument'), 'arguments/0/left/argument/elements/1')], 'arguments/0/left/argument'), 'arguments/0/left') === 'number', 'arguments/0'), {
content: 'assert(typeof [[foo.bar,baz(moo)],+fourStr] === \'number\')',
content: 'assert(typeof [[foo.bar, baz(moo)], +fourStr] === \'number\')',
filepath: 'test/fixtures/ArrayExpression/fixture.js',
line: 5
}));

assert.notDeepEqual(assert._expr(assert._capt([assert._capt(foo, 'arguments/0/elements/0'), assert._capt(bar, 'arguments/0/elements/1')], 'arguments/0'), {
content: 'assert.notDeepEqual([foo,bar], [hoge,fuga,piyo])',
content: 'assert.notDeepEqual([foo, bar], [hoge, fuga, piyo])',
filepath: 'test/fixtures/ArrayExpression/fixture.js',
line: 7
}), assert._expr(assert._capt([assert._capt(hoge, 'arguments/1/elements/0'), assert._capt(fuga, 'arguments/1/elements/1'), assert._capt(piyo, 'arguments/1/elements/2')], 'arguments/1'), {
content: 'assert.notDeepEqual([foo,bar], [hoge,fuga,piyo])',
content: 'assert.notDeepEqual([foo, bar], [hoge, fuga, piyo])',
filepath: 'test/fixtures/ArrayExpression/fixture.js',
line: 7
}));
2 changes: 1 addition & 1 deletion test/fixtures/FunctionExpression/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ assert(function (a, b) {
assert(assert._expr(assert._capt(assert._capt(baz, 'arguments/0/left') === assert._capt((function (a, b) {
return a + b;
})(assert._capt(foo, 'arguments/0/right/arguments/0'), assert._capt(bar, 'arguments/0/right/arguments/1')), 'arguments/0/right'), 'arguments/0'), {
content: 'assert(baz === function (a, b) {return a + b;}(foo, bar))',
content: 'assert(baz === (function (a, b) { return a + b; })(foo, bar))',
filepath: 'test/fixtures/FunctionExpression/fixture.js',
line: 5
}));
13 changes: 0 additions & 13 deletions test/fixtures/babel6/expected.js

This file was deleted.

5 changes: 0 additions & 5 deletions test/fixtures/babel6/fixture.js

This file was deleted.

85 changes: 41 additions & 44 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function testTransform (fixtureName, extraOptions) {
var fixtureFilepath = path.resolve(__dirname, 'fixtures', fixtureName, 'fixture.js');
var expectedFilepath = path.resolve(__dirname, 'fixtures', fixtureName, 'expected.js');
var result = babel.transformFileSync(fixtureFilepath, extend({
presets: ['es2015'],
plugins: ['../index']
}, extraOptions));
var actual = result.code;
Expand All @@ -18,48 +19,44 @@ function testTransform (fixtureName, extraOptions) {
});
}

describe('babel6 challenge', function () {
testTransform('babel6');
describe('babel-plugin-espower', function () {
testTransform('NonTarget');
testTransform('Literal');
testTransform('Identifier');
testTransform('BinaryExpression');
testTransform('UnaryExpression');
testTransform('LogicalExpression');
testTransform('MemberExpression');
testTransform('CallExpression');
testTransform('AssignmentExpression');
testTransform('ArrayExpression');
testTransform('UpdateExpression');
testTransform('ConditionalExpression');
testTransform('ObjectExpression');
testTransform('NewExpression');
testTransform('FunctionExpression');
testTransform('TemplateLiteral');
testTransform('TaggedTemplateExpression');
testTransform('ArrowFunctionExpression');
testTransform('ClassExpression');
testTransform('SpreadElement');
testTransform('Property');
testTransform('inputSourceMap', {
plugins: [
createEspowerPlugin(babel, {
sourceRoot: "/absolute/"
})
]
});
testTransform('customPatterns', {
plugins: [
createEspowerPlugin(babel, {
patterns: [
'assert.isNull(object, [message])',
'assert.same(actual, expected, [message])',
'assert.near(actual, expected, delta, [message])'
]
})
]
});
});

// describe('babel-plugin-espower', function () {
// testTransform('NonTarget');
// testTransform('Literal');
// testTransform('Identifier');
// testTransform('BinaryExpression');
// testTransform('UnaryExpression');
// testTransform('LogicalExpression');
// testTransform('MemberExpression');
// testTransform('CallExpression');
// testTransform('AssignmentExpression');
// testTransform('ArrayExpression');
// testTransform('UpdateExpression');
// testTransform('ConditionalExpression');
// testTransform('ObjectExpression');
// testTransform('NewExpression');
// testTransform('FunctionExpression');
// testTransform('TemplateLiteral');
// testTransform('TaggedTemplateExpression');
// testTransform('ArrowFunctionExpression');
// testTransform('ClassExpression');
// testTransform('SpreadElement');
// testTransform('Property');
// testTransform('inputSourceMap', {
// plugins: [
// createEspowerPlugin(babel, {
// sourceRoot: "/absolute/"
// })
// ]
// });
// testTransform('customPatterns', {
// plugins: [
// createEspowerPlugin(babel, {
// patterns: [
// 'assert.isNull(object, [message])',
// 'assert.same(actual, expected, [message])',
// 'assert.near(actual, expected, delta, [message])'
// ]
// })
// ]
// });
// });

0 comments on commit d1b3361

Please sign in to comment.