Skip to content

Commit

Permalink
chore: fix comments in test file
Browse files Browse the repository at this point in the history
  • Loading branch information
rpgeeganage committed May 30, 2019
1 parent 0a2e418 commit 4591923
Show file tree
Hide file tree
Showing 2 changed files with 138 additions and 2 deletions.
56 changes: 56 additions & 0 deletions test/globalErr.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,62 @@ describe('globalErr', function () {
});
});

it('should pass operator if possible during plain object comparison', function () {
var val1 = {
propVal1: 'val1'
};

var val2 = {
propVal2: 'val2'
};

err(function () {
expect(val1).to.equal(val2);
}, {
message: "expected { propVal1: 'val1' } to equal { propVal2: 'val2' }"
, expected: val2
, actual: val1
, operator: 'deepStrictEqual'
});

err(function () {
expect(val1).to.not.equal(val1);
}, {
message: "expected { propVal1: 'val1' } to not equal { propVal1: 'val1' }"
, expected: val1
, actual: val1
, operator: 'notDeepStrictEqual'
});
});

it('should pass operator if possible during function comparison', function () {
function f1 () {
this.propF1 = 'propF1';
}

function f2 () {
this.propF2 = 'propF2';
}

err(function () {
expect(f1).to.equal(f2);
}, {
message: "expected [Function: f1] to equal [Function: f2]"
, expected: f2
, actual: f1
, operator: 'deepStrictEqual'
});

err(function () {
expect(f1).to.not.equal(f1);
}, {
message: "expected [Function: f1] to not equal [Function: f1]"
, expected: f1
, actual: f1
, operator: 'notDeepStrictEqual'
});
});

it('should pass operator if possible during object comparison', function () {
var val1 = [
'string1'
Expand Down
84 changes: 82 additions & 2 deletions test/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,47 @@ describe('utilities', function () {
});
});

it('Must return notDeepStrictEqual if "expected" is a string and assertion is for equal', function() {
it('Must return deepStrictEqual if "expected" is a function and assertion is for equal', function() {
chai.use(function(_chai, _) {
function expected () {
this.prop = 'prop';
}

var obj = {};
_.flag(obj, 'negate', false);

expect(
_.getOperator(obj, [
null,
'expect #{this} deep equal to #{exp}',
'expect #{this} not deep equal to #{exp}',
expected
])
).to.equal('deepStrictEqual');
});
});

it('Must return deepStrictEqual if "expected" is an array and assertion is for equal', function() {
chai.use(function(_chai, _) {
var expected = [
'item 1'
];

var obj = {};
_.flag(obj, 'negate', false);

expect(
_.getOperator(obj, [
null,
'expect #{this} deep equal to #{exp}',
'expect #{this} not deep equal to #{exp}',
expected
])
).to.equal('deepStrictEqual');
});
});

it('Must return strictEqual if "expected" is a string and assertion is for equal', function() {
chai.use(function(_chai, _) {
var expected = 'someString';

Expand Down Expand Up @@ -1407,7 +1447,47 @@ describe('utilities', function () {
});
});

it('Must return notDeepStrictEqual if "expected" is a string and assertion is for inequality', function() {
it('Must return notDeepStrictEqual if "expected" is a function and assertion is for inequality', function() {
chai.use(function(_chai, _) {
function expected () {
this.prop = 'prop';
}

var obj = {};
_.flag(obj, 'negate', true);

expect(
_.getOperator(obj, [
null,
'expect #{this} deep equal to #{exp}',
'expect #{this} not deep equal to #{exp}',
expected
])
).to.equal('notDeepStrictEqual');
});
});

it('Must return notDeepStrictEqual if "expected" is an array and assertion is for inequality', function() {
chai.use(function(_chai, _) {
var expected = [
'item 1'
];

var obj = {};
_.flag(obj, 'negate', true);

expect(
_.getOperator(obj, [
null,
'expect #{this} deep equal to #{exp}',
'expect #{this} not deep equal to #{exp}',
expected
])
).to.equal('notDeepStrictEqual');
});
});

it('Must return notStrictEqual if "expected" is a string and assertion is for inequality', function() {
chai.use(function(_chai, _) {
var expected = 'someString';

Expand Down

0 comments on commit 4591923

Please sign in to comment.