From 6f5ceacad2dbaa95fe9d7e3cd49a07f103766684 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Fri, 21 Jan 2022 17:37:30 +0100 Subject: [PATCH] fix(core): update --- package-lock.json | 7 +++---- package.json | 3 ++- test/test.ts | 5 +++++ ts/smartexpect.classes.assertion.ts | 9 +++++++++ ts/smartexpect.plugins.ts | 2 ++ 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 94bcabe..4bbcbf3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,8 @@ "dependencies": { "@pushrocks/smartdelay": "^2.0.13", "@pushrocks/smartpromise": "^3.1.6", - "chai": "^4.3.4" + "chai": "^4.3.4", + "fast-deep-equal": "^3.1.3" }, "devDependencies": { "@gitzone/tsbuild": "^2.1.25", @@ -7054,7 +7055,6 @@ "version": "3.1.3", "resolved": "https://verdaccio.lossless.one/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "dev": true, "license": "MIT" }, "node_modules/fast-glob": { @@ -21011,8 +21011,7 @@ "fast-deep-equal": { "version": "3.1.3", "resolved": "https://verdaccio.lossless.one/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "dev": true + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" }, "fast-glob": { "version": "2.2.7", diff --git a/package.json b/package.json index 90495a1..00cb37d 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,8 @@ "dependencies": { "@pushrocks/smartdelay": "^2.0.13", "@pushrocks/smartpromise": "^3.1.6", - "chai": "^4.3.4" + "chai": "^4.3.4", + "fast-deep-equal": "^3.1.3" }, "browserslist": [ "last 1 chrome versions" diff --git a/test/test.ts b/test/test.ts index be9c988..f1eeae7 100644 --- a/test/test.ts +++ b/test/test.ts @@ -17,4 +17,9 @@ tap.test('async tests', async (toolsArg) => { await smartexpect.expectAsync(deferred.promise).not.toBeTypeofBoolean(); }); +tap.test('should check equality', async () => { + smartexpect.expect('hithere').toEqual('hithere'); + smartexpect.expect('hithere').not.toEqual('hithere2'); +}) + tap.start(); diff --git a/ts/smartexpect.classes.assertion.ts b/ts/smartexpect.classes.assertion.ts index 60b6a14..e0a211e 100644 --- a/ts/smartexpect.classes.assertion.ts +++ b/ts/smartexpect.classes.assertion.ts @@ -91,4 +91,13 @@ export class Assertion { } }); } + + public toEqual(comparisonObject: any) { + return this.runCheck(() => { + const result = plugins.fastDeepEqual(this.baseReference, comparisonObject); + if (!result) { + throw new Error(`${this.baseReference} does not equal ${comparisonObject}`); + } + }); + } } diff --git a/ts/smartexpect.plugins.ts b/ts/smartexpect.plugins.ts index 766c2de..492ef9b 100644 --- a/ts/smartexpect.plugins.ts +++ b/ts/smartexpect.plugins.ts @@ -8,7 +8,9 @@ export { // third party scope import { expect } from 'chai'; +import fastDeepEqual from 'fast-deep-equal'; export { + fastDeepEqual, expect } \ No newline at end of file