Skip to content

Commit 5e1b360

Browse files
committed
test(empower): add test for assertion with optional message argument
1 parent 8ffcc49 commit 5e1b360

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

test/empower_test.js

+35
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,41 @@ test('Bug reproduction. should not fail if argument is null Literal. ' + JSON.st
6464
});
6565

6666

67+
test('assertion with optional message argument. ' + JSON.stringify(option), function () {
68+
var falsy = 0;
69+
try {
70+
eval(weave('assert(falsy, "assertion message");'));
71+
assert.ok(false, 'AssertionError should be thrown');
72+
} catch (e) {
73+
baseAssert.equal(e.name, 'AssertionError');
74+
if (option.modifyMessageOnFail) {
75+
baseAssert.equal(e.message, [
76+
'assertion message /path/to/some_test.js',
77+
'assert(falsy, "assertion message")',
78+
'[{"value":0,"espath":"arguments/0"}]'
79+
].join('\n'));
80+
}
81+
if (option.saveContextOnFail) {
82+
baseAssert.deepEqual(e.powerAssertContext, {
83+
"source":{
84+
"content": "assert(falsy, \"assertion message\")",
85+
"filepath": "/path/to/some_test.js",
86+
"line": 1
87+
},
88+
"args":[
89+
{
90+
"value": 0,
91+
"events": [
92+
{"value":0,"espath":"arguments/0"}
93+
]
94+
}
95+
]
96+
});
97+
}
98+
}
99+
});
100+
101+
67102
test(JSON.stringify(option) + ' empowered function also acts like an assert function', function () {
68103
var falsy = 0;
69104
try {

0 commit comments

Comments
 (0)