Merge pull request #26353 from FabianTe/fix/chai-assert-missing-method

Fix/chai assert missing method
This commit is contained in:
Mine Starks
2018-06-13 08:58:58 -07:00
committed by GitHub
2 changed files with 45 additions and 2 deletions

View File

@@ -1361,6 +1361,39 @@ suite('assert', () => {
assert.notDeepEqual(circularObject, secondCircularObject);
});
test('deepStrictEqual', () => {
assert.deepStrictEqual({tea: 'chai'}, {tea: 'chai'});
assert.throws(() => assert.deepStrictEqual({tea: 'chai'}, {tea: 'black'}));
const obja = Object.create({tea: 'chai'});
const objb = Object.create({tea: 'chai'});
assert.deepStrictEqual(obja, objb);
const obj1 = Object.create({tea: 'chai'});
const obj2 = Object.create({tea: 'black'});
assert.throws(() => assert.deepStrictEqual(obj1, obj2));
});
test('deepStrictEqual (ordering)', () => {
const a = {a: 'b', c: 'd'};
const b = {c: 'd', a: 'b'};
assert.deepStrictEqual(a, b);
});
test('deepStrictEqual (circular)', () => {
const circularObject: any = {};
const secondCircularObject: any = {};
circularObject.field = circularObject;
secondCircularObject.field = secondCircularObject;
assert.deepStrictEqual(circularObject, secondCircularObject);
secondCircularObject.field2 = secondCircularObject;
assert.deepStrictEqual(circularObject, secondCircularObject);
});
test('isNull', () => {
assert.isNull(null);
assert.isNull(undefined);

14
types/chai/index.d.ts vendored
View File

@@ -353,7 +353,7 @@ declare namespace Chai {
notStrictEqual<T>(actual: T, expected: T, message?: string): void;
/**
* Asserts that actual is deeply equal to expected.
* Asserts that actual is deeply equal (==) to expected.
*
* @type T Type of the objects.
* @param actual Actual value.
@@ -363,7 +363,7 @@ declare namespace Chai {
deepEqual<T>(actual: T, expected: T, message?: string): void;
/**
* Asserts that actual is not deeply equal to expected.
* Asserts that actual is not deeply equal (==) to expected.
*
* @type T Type of the objects.
* @param actual Actual value.
@@ -372,6 +372,16 @@ declare namespace Chai {
*/
notDeepEqual<T>(actual: T, expected: T, message?: string): void;
/**
* Asserts that actual is deeply strict equal (===) to expected.
*
* @type T Type of the objects.
* @param actual Actual value.
* @param expected Potential expected value.
* @param message Message to display on error.
*/
deepStrictEqual<T>(actual: T, expected: T, message?: string): void;
/**
* Asserts valueToCheck is strictly greater than (>) valueToBeAbove.
*