diff --git a/package.json b/package.json index cd40956..37a4636 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ }, "devDependencies": { "babel-core": "^6.0.10", + "babel-preset-es2015": "^6.0.0", "mocha": "^2.2.4" }, "directories": { @@ -51,6 +52,6 @@ "url": "http://github.com/power-assert-js/babel-plugin-espower.git" }, "scripts": { - "test": "mocha" + "test": "mocha --timeout 7000" } } diff --git a/test/fixtures/ArrayExpression/expected.js b/test/fixtures/ArrayExpression/expected.js index f0a2a05..1573538 100644 --- a/test/fixtures/ArrayExpression/expected.js +++ b/test/fixtures/ArrayExpression/expected.js @@ -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 })); diff --git a/test/fixtures/FunctionExpression/expected.js b/test/fixtures/FunctionExpression/expected.js index 9facf34..92a3b79 100644 --- a/test/fixtures/FunctionExpression/expected.js +++ b/test/fixtures/FunctionExpression/expected.js @@ -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 })); diff --git a/test/fixtures/babel6/expected.js b/test/fixtures/babel6/expected.js deleted file mode 100644 index 9bb5e75..0000000 --- a/test/fixtures/babel6/expected.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -assert(assert._expr(assert._capt(falsyStr, 'arguments/0'), { - content: 'assert(falsyStr)', - filepath: 'test/fixtures/babel6/fixture.js', - line: 3 -})); - -assert(assert._expr(assert._capt(falsyStr, 'arguments/0'), { - content: 'assert(falsyStr, messageStr)', - filepath: 'test/fixtures/babel6/fixture.js', - line: 5 -}), messageStr); diff --git a/test/fixtures/babel6/fixture.js b/test/fixtures/babel6/fixture.js deleted file mode 100644 index 19cc388..0000000 --- a/test/fixtures/babel6/fixture.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -assert(falsyStr); - -assert(falsyStr, messageStr); diff --git a/test/test.js b/test/test.js index 2b1eafc..d631225 100644 --- a/test/test.js +++ b/test/test.js @@ -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; @@ -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])' -// ] -// }) -// ] -// }); -// });