Skip to content

Commit

Permalink
Remove new methods and properties after using them for test
Browse files Browse the repository at this point in the history
  • Loading branch information
vieiralucas committed Sep 15, 2016
1 parent 27f4265 commit c1d5a54
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion test/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ describe('utilities', function () {

var assert = expect('chai').to.be.tea;
expect(assert.__flags.tea).to.equal('chai');

delete chai.Assertion.prototype.tea;
});

it('addProperty returns a new assertion with flags copied over', function () {
Expand Down Expand Up @@ -482,6 +484,8 @@ describe('utilities', function () {

expect(expect([1, 2, 3]).be).to.be.an.instanceOf(assertionConstructor);
expect(expect([1, 2, 3]).thing).to.be.an.instanceOf(assertionConstructor);

delete chai.Assertion.prototype.thing;
});

it('addProperty returning result', function () {
Expand All @@ -496,7 +500,10 @@ describe('utilities', function () {

it('overwriteProperty', function () {
chai.use(function (_chai, _) {
expect(new chai.Assertion()).to.have.property('tea');
_chai.Assertion.addProperty('tea', function () {
_.flag(this, 'tea', 'chai');
});

_chai.Assertion.overwriteProperty('tea', function (_super) {
return function () {
var act = _.flag(this, 'object');
Expand All @@ -513,6 +520,8 @@ describe('utilities', function () {
expect(matcha.__flags.tea).to.equal('matcha');
var assert = expect('something').to.be.tea;
expect(assert.__flags.tea).to.equal('chai');

delete chai.Assertion.prototype.tea;
});

it('overwriteProperty returning result', function () {
Expand All @@ -525,6 +534,8 @@ describe('utilities', function () {
});

expect(expect('foo').result).to.equal('result');

delete chai.Assertion.prototype.result;
});

describe('overwriteProperty', function () {
Expand Down Expand Up @@ -847,6 +858,8 @@ describe('utilities', function () {
expect(obj).x.to.be.ok;
expect(obj).to.have.property('__x', 'X!');
})

delete chai.Assertion.prototype.x;
});

it('addChainableMethod should return a new assertion with flags copied over', function () {
Expand Down Expand Up @@ -897,6 +910,16 @@ describe('utilities', function () {

it('overwriteChainableMethod', function () {
chai.use(function (_chai, _) {
_chai.Assertion.addChainableMethod('x',
function () {
new chai.Assertion(this._obj).to.be.equal('x');
}
, function () {
this._obj = this._obj || {};
this._obj.__x = 'X!'
}
);

_chai.Assertion.overwriteChainableMethod('x',
function(_super) {
return function() {
Expand Down Expand Up @@ -934,6 +957,8 @@ describe('utilities', function () {
assertion.x()
}).to.throw(_chai.AssertionError);
});

delete chai.Assertion.prototype.x;
});

it('compareByInspect', function () {
Expand Down

0 comments on commit c1d5a54

Please sign in to comment.