Skip to content

Commit

Permalink
added tests for power assert not throwing on experimental syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuno Campos committed Jun 4, 2016
1 parent fc837f7 commit a217782
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
"update-notifier": "^0.7.0"
},
"devDependencies": {
"babel-preset-react": "^6.5.0",
"cli-table2": "^0.2.0",
"coveralls": "^2.11.4",
"delay": "^1.3.0",
Expand Down
18 changes: 16 additions & 2 deletions test/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -650,9 +650,13 @@ function generateTests(prefix, apiCreator) {
});

test(prefix + 'power-assert support', function (t) {
t.plan(3);
t.plan(5);

var api = apiCreator();
var api = apiCreator({
babelConfig: {
presets: ['react', 'es2015', 'stage-2']
}
});

api.run([path.join(__dirname, 'fixture/power-assert.js')])
.then(function (result) {
Expand All @@ -667,6 +671,16 @@ function generateTests(prefix, apiCreator) {
result.errors[1].error.message,
/with message\s+t\.true\(a === 'foo', 'with message'\)\s*\n\s+\|\s*\n\s+"bar"/m
);

t.match(
result.errors[2].error.message,
/t\.true\(o === \{ ...o \}\)\s*\n\s+\|\s*\n\s+Object\{\}/m
);

t.match(
result.errors[3].error.message,
/t\.true\(<div \/> === <span \/>\)/m
)
});
});

Expand Down
12 changes: 12 additions & 0 deletions test/fixture/power-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,15 @@ test.serial(t => {

t.true(a === 'foo', 'with message');
});

test.serial(t => {
const o = {};

t.true(o === {...o});
});

test.serial(t => {
const React = { createElement: function(type) { return type } }

t.true(<div /> === <span />);
});

0 comments on commit a217782

Please sign in to comment.