Skip to content

Commit debbfd5

Browse files
committed
test(espower): bring comprehensive testsuite back
1 parent 2dd35a5 commit debbfd5

File tree

6 files changed

+48
-68
lines changed

6 files changed

+48
-68
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
},
2020
"devDependencies": {
2121
"babel-core": "^6.0.10",
22+
"babel-preset-es2015": "^6.0.0",
2223
"mocha": "^2.2.4"
2324
},
2425
"directories": {
@@ -51,6 +52,6 @@
5152
"url": "http://github.com/power-assert-js/babel-plugin-espower.git"
5253
},
5354
"scripts": {
54-
"test": "mocha"
55+
"test": "mocha --timeout 7000"
5556
}
5657
}
+4-4
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
'use strict';
22

33
assert(assert._expr(assert._capt([assert._capt(foo, 'arguments/0/elements/0'), assert._capt(bar, 'arguments/0/elements/1')], 'arguments/0'), {
4-
content: 'assert([foo,bar])',
4+
content: 'assert([foo, bar])',
55
filepath: 'test/fixtures/ArrayExpression/fixture.js',
66
line: 3
77
}));
88

99
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'), {
10-
content: 'assert(typeof [[foo.bar,baz(moo)],+fourStr] === \'number\')',
10+
content: 'assert(typeof [[foo.bar, baz(moo)], +fourStr] === \'number\')',
1111
filepath: 'test/fixtures/ArrayExpression/fixture.js',
1212
line: 5
1313
}));
1414

1515
assert.notDeepEqual(assert._expr(assert._capt([assert._capt(foo, 'arguments/0/elements/0'), assert._capt(bar, 'arguments/0/elements/1')], 'arguments/0'), {
16-
content: 'assert.notDeepEqual([foo,bar], [hoge,fuga,piyo])',
16+
content: 'assert.notDeepEqual([foo, bar], [hoge, fuga, piyo])',
1717
filepath: 'test/fixtures/ArrayExpression/fixture.js',
1818
line: 7
1919
}), 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'), {
20-
content: 'assert.notDeepEqual([foo,bar], [hoge,fuga,piyo])',
20+
content: 'assert.notDeepEqual([foo, bar], [hoge, fuga, piyo])',
2121
filepath: 'test/fixtures/ArrayExpression/fixture.js',
2222
line: 7
2323
}));

test/fixtures/FunctionExpression/expected.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ assert(function (a, b) {
77
assert(assert._expr(assert._capt(assert._capt(baz, 'arguments/0/left') === assert._capt((function (a, b) {
88
return a + b;
99
})(assert._capt(foo, 'arguments/0/right/arguments/0'), assert._capt(bar, 'arguments/0/right/arguments/1')), 'arguments/0/right'), 'arguments/0'), {
10-
content: 'assert(baz === function (a, b) {return a + b;}(foo, bar))',
10+
content: 'assert(baz === (function (a, b) { return a + b; })(foo, bar))',
1111
filepath: 'test/fixtures/FunctionExpression/fixture.js',
1212
line: 5
1313
}));

test/fixtures/babel6/expected.js

-13
This file was deleted.

test/fixtures/babel6/fixture.js

-5
This file was deleted.

test/test.js

+41-44
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ function testTransform (fixtureName, extraOptions) {
1010
var fixtureFilepath = path.resolve(__dirname, 'fixtures', fixtureName, 'fixture.js');
1111
var expectedFilepath = path.resolve(__dirname, 'fixtures', fixtureName, 'expected.js');
1212
var result = babel.transformFileSync(fixtureFilepath, extend({
13+
presets: ['es2015'],
1314
plugins: ['../index']
1415
}, extraOptions));
1516
var actual = result.code;
@@ -18,48 +19,44 @@ function testTransform (fixtureName, extraOptions) {
1819
});
1920
}
2021

21-
describe('babel6 challenge', function () {
22-
testTransform('babel6');
22+
describe('babel-plugin-espower', function () {
23+
testTransform('NonTarget');
24+
testTransform('Literal');
25+
testTransform('Identifier');
26+
testTransform('BinaryExpression');
27+
testTransform('UnaryExpression');
28+
testTransform('LogicalExpression');
29+
testTransform('MemberExpression');
30+
testTransform('CallExpression');
31+
testTransform('AssignmentExpression');
32+
testTransform('ArrayExpression');
33+
testTransform('UpdateExpression');
34+
testTransform('ConditionalExpression');
35+
testTransform('ObjectExpression');
36+
testTransform('NewExpression');
37+
testTransform('FunctionExpression');
38+
testTransform('TemplateLiteral');
39+
testTransform('TaggedTemplateExpression');
40+
testTransform('ArrowFunctionExpression');
41+
testTransform('ClassExpression');
42+
testTransform('SpreadElement');
43+
testTransform('Property');
44+
testTransform('inputSourceMap', {
45+
plugins: [
46+
createEspowerPlugin(babel, {
47+
sourceRoot: "/absolute/"
48+
})
49+
]
50+
});
51+
testTransform('customPatterns', {
52+
plugins: [
53+
createEspowerPlugin(babel, {
54+
patterns: [
55+
'assert.isNull(object, [message])',
56+
'assert.same(actual, expected, [message])',
57+
'assert.near(actual, expected, delta, [message])'
58+
]
59+
})
60+
]
61+
});
2362
});
24-
25-
// describe('babel-plugin-espower', function () {
26-
// testTransform('NonTarget');
27-
// testTransform('Literal');
28-
// testTransform('Identifier');
29-
// testTransform('BinaryExpression');
30-
// testTransform('UnaryExpression');
31-
// testTransform('LogicalExpression');
32-
// testTransform('MemberExpression');
33-
// testTransform('CallExpression');
34-
// testTransform('AssignmentExpression');
35-
// testTransform('ArrayExpression');
36-
// testTransform('UpdateExpression');
37-
// testTransform('ConditionalExpression');
38-
// testTransform('ObjectExpression');
39-
// testTransform('NewExpression');
40-
// testTransform('FunctionExpression');
41-
// testTransform('TemplateLiteral');
42-
// testTransform('TaggedTemplateExpression');
43-
// testTransform('ArrowFunctionExpression');
44-
// testTransform('ClassExpression');
45-
// testTransform('SpreadElement');
46-
// testTransform('Property');
47-
// testTransform('inputSourceMap', {
48-
// plugins: [
49-
// createEspowerPlugin(babel, {
50-
// sourceRoot: "/absolute/"
51-
// })
52-
// ]
53-
// });
54-
// testTransform('customPatterns', {
55-
// plugins: [
56-
// createEspowerPlugin(babel, {
57-
// patterns: [
58-
// 'assert.isNull(object, [message])',
59-
// 'assert.same(actual, expected, [message])',
60-
// 'assert.near(actual, expected, delta, [message])'
61-
// ]
62-
// })
63-
// ]
64-
// });
65-
// });

0 commit comments

Comments
 (0)