Skip to content

Commit

Permalink
More tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
twada committed Dec 22, 2013
1 parent 82971d7 commit b8af83d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/empower_option_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,12 @@ suite('assert function empowerment', function () {
});
suite('returned assert', function () {
sharedTestsForEmpowerFunctionReturnValue();
test('works as assert function', function () {
var empoweredAssert = this.empoweredAssert;
assert.throws(function () {
empoweredAssert(false, 'empoweredAssert');
}, /FakeAssert: assertion failed. empoweredAssert/);
});
test('is also a function', function () {
assert.ok(typeof this.empoweredAssert, 'function');
});
Expand Down
23 changes: 23 additions & 0 deletions test/empower_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,26 @@ var empower = require('../lib/empower'),
};


suite('assertion method with one argument', function () {
var baseAssert = require('assert'),
assert = empower(baseAssert, fakeFormatter);

test('Identifier', function () {
var falsy = 0;
try {
eval(weave('assert(falsy);'));
assert.ok(false, 'AssertionError should be thrown');
} catch (e) {
baseAssert.equal(e.name, 'AssertionError');
baseAssert.equal(e.message, [
'/path/to/some_test.js',
'assert(falsy);'
].join('\n'));
}
});
});


suite('assertion method with two arguments', function () {
var baseAssert = require('assert'),
assert = empower(baseAssert, fakeFormatter);
Expand All @@ -16,6 +36,7 @@ suite('assertion method with two arguments', function () {
var foo = 'foo', bar = 'bar';
try {
eval(weave('assert.equal(foo, bar);'));
assert.ok(false, 'AssertionError should be thrown');
} catch (e) {
baseAssert.equal(e.name, 'AssertionError');
baseAssert.equal(e.message, [
Expand All @@ -29,6 +50,7 @@ suite('assertion method with two arguments', function () {
var bar = 'bar';
try {
eval(weave('assert.equal("foo", bar);'));
assert.ok(false, 'AssertionError should be thrown');
} catch (e) {
baseAssert.equal(e.name, 'AssertionError');
baseAssert.equal(e.message, [
Expand All @@ -42,6 +64,7 @@ suite('assertion method with two arguments', function () {
var foo = 'foo';
try {
eval(weave('assert.equal(foo, "bar");'));
assert.ok(false, 'AssertionError should be thrown');
} catch (e) {
baseAssert.equal(e.name, 'AssertionError');
baseAssert.equal(e.message, [
Expand Down

0 comments on commit b8af83d

Please sign in to comment.