Skip to content

Commit 425db3f

Browse files
author
Eran Hammer
committed
Merge pull request #10 from cjihrig/reset-flags
Reset flags after each assertion
2 parents 6c43718 + 134a409 commit 425db3f

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

lib/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ internals.Assertion.prototype.assert = function (result, verb, actual, expected)
5757
delete internals.locations[this._location];
5858

5959
if (this._flags.not ? !result : result) {
60+
this._flags = {};
6061
return this;
6162
}
6263

test/index.js

+21
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,27 @@ describe('expect()', function () {
176176
done();
177177
});
178178

179+
it('resets flags between chained assertions', function (done) {
180+
181+
var exception = false;
182+
try {
183+
184+
Code.expect('abc').to.contain('a').and.to.not.contain('d');
185+
Code.expect('abc').to.not.contain('d').and.to.contain('a');
186+
Code.expect('abc').to.not.contain('d').and.to.not.contain('e');
187+
Code.expect('abc').to.contain('a').and.to.not.contain('d').and.to.contain('c').to.not.contain('f');
188+
Code.expect(function () {}).to.not.throw().and.to.be.a.function();
189+
Code.expect(10).to.not.be.about(8, 1).and.to.be.about(9, 1);
190+
Code.expect(10).to.be.about(9, 1).and.to.not.be.about(8, 1);
191+
}
192+
catch (err) {
193+
exception = err;
194+
}
195+
196+
Hoek.assert(!exception, exception);
197+
done();
198+
});
199+
179200
describe('assertion', function () {
180201

181202
describe('argument()', function () {

0 commit comments

Comments
 (0)