diff --git a/.all-contributorsrc b/.all-contributorsrc index 0eecb975..42807f23 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -70,7 +70,9 @@ "avatar_url": "https://avatars.githubusercontent.com/u/43491324?v=4", "profile": "https://github.com/ChristianSama", "contributions": [ - "doc" + "doc", + "code", + "test" ] } ], diff --git a/README.md b/README.md index 2b50cf54..1c56b158 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Alejandro Vivanco

💻 ⚠️
David Villamarin

💻 ⚠️
Alexander Mejía

💻 ⚠️ -
Christian Samaniego

📖 +
Christian Samaniego

📖 💻 ⚠️ diff --git a/package.json b/package.json index f42a4f7a..8cae79d9 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,9 @@ "lint": "tslint -c tslint.json \"!(build|dist)/**/*.ts\"", "test": "cross-env NODE_ENV=test TS_NODE_TRANSPILE_ONLY=true mocha" }, + "dependencies": { + "@cometlib/dedent": "^0.8.0-es.10" + }, "devDependencies": { "@types/mocha": "^9.1.0", "@types/node": "^17.0.15", diff --git a/src/lib/DateAssertion.ts b/src/lib/DateAssertion.ts index 3c4b4ecd..a41e4f96 100644 --- a/src/lib/DateAssertion.ts +++ b/src/lib/DateAssertion.ts @@ -69,11 +69,11 @@ export class DateAssertion extends Assertion { const error = new AssertionError({ actual: this.actual, expected: options, - message: `Expected <${this.actual}> to be equal to <${optionsAsDate}>` + message: `Expected <${this.actual.toISOString()}> to be equal to <${optionsAsDate.toISOString()}>` }); const invertedError = new AssertionError({ actual: this.actual, - message: `Expected <${this.actual}> NOT to be equal to <${optionsAsDate}>` + message: `Expected <${this.actual.toISOString()}> NOT to be equal to <${optionsAsDate.toISOString()}>` }); return this.execute({ @@ -93,11 +93,11 @@ export class DateAssertion extends Assertion { const error = new AssertionError({ actual: this.actual, expected: date, - message: `Expected <${this.actual}> to be before <${date}>` + message: `Expected <${this.actual.toISOString()}> to be before <${date.toISOString()}>` }); const invertedError = new AssertionError({ actual: this.actual, - message: `Expected <${this.actual}> NOT to be before <${date}>` + message: `Expected <${this.actual.toISOString()}> NOT to be before <${date.toISOString()}>` }); return this.execute({ @@ -116,11 +116,11 @@ export class DateAssertion extends Assertion { public toBeBeforeOrEqual(date: Date): this { const error = new AssertionError({ actual: this.actual, - message: `Expected <${this.actual}> to be before or equal to <${date}>` + message: `Expected <${this.actual.toISOString()}> to be before or equal to <${date.toISOString()}>` }); const invertedError = new AssertionError({ actual: this.actual, - message: `Expected <${this.actual}> NOT to be before or equal to <${date}>` + message: `Expected <${this.actual.toISOString()}> NOT to be before or equal to <${date.toISOString()}>` }); return this.execute({ @@ -139,11 +139,11 @@ export class DateAssertion extends Assertion { public toBeAfter(date: Date): this { const error = new AssertionError({ actual: this.actual, - message: `Expected <${this.actual}> to be after <${date}>` + message: `Expected <${this.actual.toISOString()}> to be after <${date.toISOString()}>` }); const invertedError = new AssertionError({ actual: this.actual, - message: `Expected <${this.actual}> NOT to be after <${date}>` + message: `Expected <${this.actual.toISOString()}> NOT to be after <${date.toISOString()}>` }); return this.execute({ @@ -162,11 +162,11 @@ export class DateAssertion extends Assertion { public toBeAfterOrEqual(date: Date): this { const error = new AssertionError({ actual: this.actual, - message: `Expected <${this.actual}> to be after or equal to <${date}>` + message: `Expected <${this.actual.toISOString()}> to be after or equal to <${date.toISOString()}>` }); const invertedError = new AssertionError({ actual: this.actual, - message: `Expected <${this.actual}> NOT to be after or equal to <${date}>` + message: `Expected <${this.actual.toISOString()}> NOT to be after or equal to <${date.toISOString()}>` }); return this.execute({ diff --git a/test/lib/DateAssertion.test.ts b/test/lib/DateAssertion.test.ts index fa9a43ea..a21606c6 100644 --- a/test/lib/DateAssertion.test.ts +++ b/test/lib/DateAssertion.test.ts @@ -1,3 +1,4 @@ +import dedent from "@cometlib/dedent"; import assert, { AssertionError } from "assert"; import { DateAssertion } from "../../src/lib/DateAssertion"; @@ -46,7 +47,7 @@ describe("[Unit] DateAssertion.test.ts", () => { const test = new DateAssertion(actualDate); assert.deepStrictEqual(test.toMatchDateParts(options), test); assert.throws(() => test.not.toMatchDateParts(options), { - message: `Expected <${actualDate}> NOT to be equal to <${dateOptionsToDate(options)}>`, + message: `Expected <${actualDate.toISOString()}> NOT to be equal to <${dateOptionsToDate(options).toISOString()}>`, name: AssertionError.name }); }); @@ -66,7 +67,10 @@ describe("[Unit] DateAssertion.test.ts", () => { }; const test = new DateAssertion(actualDate); assert.throws(() => test.toMatchDateParts(options), { - message: `Expected <${actualDate}> to be equal to <${dateOptionsToDate(options)}>`, + message: dedent` + Expected <${actualDate.toISOString()}> to be equal to \ + <${dateOptionsToDate(options).toISOString()}> + `, name: AssertionError.name }); assert.deepStrictEqual(test.not.toMatchDateParts(options), test); @@ -82,7 +86,7 @@ describe("[Unit] DateAssertion.test.ts", () => { const test = new DateAssertion(actualDate); assert.deepStrictEqual(test.toBeBefore(passedDate), test); assert.throws(() => test.not.toBeBefore(passedDate), { - message: `Expected <${actualDate}> NOT to be before <${passedDate}>`, + message: `Expected <${actualDate.toISOString()}> NOT to be before <${passedDate.toISOString()}>`, name: AssertionError.name }); }); @@ -94,7 +98,7 @@ describe("[Unit] DateAssertion.test.ts", () => { const passedDate = new Date(2021, 1, 1); const test = new DateAssertion(actualDate); assert.throws(() => test.toBeBefore(passedDate), { - message: `Expected <${actualDate}> to be before <${passedDate}>`, + message: `Expected <${actualDate.toISOString()}> to be before <${passedDate.toISOString()}>`, name: AssertionError.name }); assert.deepStrictEqual(test.not.toBeBefore(passedDate), test); @@ -110,7 +114,10 @@ describe("[Unit] DateAssertion.test.ts", () => { const test = new DateAssertion(actualDate); assert.deepStrictEqual(test.toBeBeforeOrEqual(passedDate), test); assert.throws(() => test.not.toBeBeforeOrEqual(passedDate), { - message: `Expected <${actualDate}> NOT to be before or equal to <${passedDate}>`, + message: dedent` + Expected <${actualDate.toISOString()}> \ + NOT to be before or equal to <${passedDate.toISOString()}> + `, name: AssertionError.name }); }); @@ -123,7 +130,7 @@ describe("[Unit] DateAssertion.test.ts", () => { const passedDate = new Date(2021, 1, 1); const test = new DateAssertion(actualDate); assert.throws(() => test.toBeBeforeOrEqual(passedDate), { - message: `Expected <${actualDate}> to be before or equal to <${passedDate}>`, + message: `Expected <${actualDate.toISOString()}> to be before or equal to <${passedDate.toISOString()}>`, name: AssertionError.name }); assert.deepStrictEqual( @@ -143,7 +150,7 @@ describe("[Unit] DateAssertion.test.ts", () => { const test = new DateAssertion(actualDate); assert.deepStrictEqual(test.toBeAfter(passedDate), test); assert.throws(() => test.not.toBeAfter(passedDate), { - message: `Expected <${actualDate}> NOT to be after <${passedDate}>`, + message: `Expected <${actualDate.toISOString()}> NOT to be after <${passedDate.toISOString()}>`, name: AssertionError.name }); }); @@ -155,7 +162,7 @@ describe("[Unit] DateAssertion.test.ts", () => { const passedDate = new Date(2021, 2, 1); const test = new DateAssertion(actualDate); assert.throws(() => test.toBeAfter(passedDate), { - message: `Expected <${actualDate}> to be after <${passedDate}>`, + message: `Expected <${actualDate.toISOString()}> to be after <${passedDate.toISOString()}>`, name: AssertionError.name }); assert.deepStrictEqual(test.not.toBeAfter(passedDate), test); @@ -171,7 +178,7 @@ describe("[Unit] DateAssertion.test.ts", () => { const test = new DateAssertion(actualDate); assert.deepStrictEqual(test.toBeAfterOrEqual(passedDate), test); assert.throws(() => test.not.toBeAfterOrEqual(passedDate), { - message: `Expected <${actualDate}> NOT to be after or equal to <${passedDate}>`, + message: `Expected <${actualDate.toISOString()}> NOT to be after or equal to <${passedDate.toISOString()}>`, name: AssertionError.name }); }); @@ -183,7 +190,7 @@ describe("[Unit] DateAssertion.test.ts", () => { const passedDate = new Date(2021, 2, 1); const test = new DateAssertion(actualDate); assert.throws(() => test.toBeAfterOrEqual(passedDate), { - message: `Expected <${actualDate}> to be after or equal to <${passedDate}>`, + message: `Expected <${actualDate.toISOString()}> to be after or equal to <${passedDate.toISOString()}>`, name: AssertionError.name }); assert.deepStrictEqual(test.not.toBeAfterOrEqual(passedDate), test); diff --git a/yarn.lock b/yarn.lock index 3518720f..19ee2297 100644 --- a/yarn.lock +++ b/yarn.lock @@ -32,7 +32,7 @@ __metadata: languageName: node linkType: hard -"@babel/runtime@npm:^7.14.6, @babel/runtime@npm:^7.7.6": +"@babel/runtime@npm:^7.14.6, @babel/runtime@npm:^7.7.2, @babel/runtime@npm:^7.7.6": version: 7.18.6 resolution: "@babel/runtime@npm:7.18.6" dependencies: @@ -41,6 +41,15 @@ __metadata: languageName: node linkType: hard +"@cometlib/dedent@npm:^0.8.0-es.10": + version: 0.8.0-es.10 + resolution: "@cometlib/dedent@npm:0.8.0-es.10" + dependencies: + babel-plugin-macros: ^2.8.0 + checksum: e411800737686031007a4a35a69fc7b0d0a5985136bb781a9d70291e46714595f4ae9fa7a85eac35aa450b9a56a3858534039fe196278ad0ee509fdbe621b326 + languageName: node + linkType: hard + "@cspotcode/source-map-consumer@npm:0.8.0": version: 0.8.0 resolution: "@cspotcode/source-map-consumer@npm:0.8.0" @@ -169,6 +178,13 @@ __metadata: languageName: node linkType: hard +"@types/parse-json@npm:^4.0.0": + version: 4.0.0 + resolution: "@types/parse-json@npm:4.0.0" + checksum: fd6bce2b674b6efc3db4c7c3d336bd70c90838e8439de639b909ce22f3720d21344f52427f1d9e57b265fcb7f6c018699b99e5e0c208a1a4823014269a6bf35b + languageName: node + linkType: hard + "@types/sinon@npm:^10.0.11": version: 10.0.11 resolution: "@types/sinon@npm:10.0.11" @@ -360,6 +376,7 @@ __metadata: version: 0.0.0-use.local resolution: "assertive-ts@workspace:." dependencies: + "@cometlib/dedent": ^0.8.0-es.10 "@types/mocha": ^9.1.0 "@types/node": ^17.0.15 "@types/sinon": ^10.0.11 @@ -380,6 +397,17 @@ __metadata: languageName: node linkType: hard +"babel-plugin-macros@npm:^2.8.0": + version: 2.8.0 + resolution: "babel-plugin-macros@npm:2.8.0" + dependencies: + "@babel/runtime": ^7.7.2 + cosmiconfig: ^6.0.0 + resolve: ^1.12.0 + checksum: 59b09a21cf3ae1e14186c1b021917d004b49b953824b24953a54c6502da79e8051d4ac31cfd4a0ae7f6ea5ddf1f7edd93df4895dd3c3982a5b2431859c2889ac + languageName: node + linkType: hard + "balanced-match@npm:^1.0.0": version: 1.0.2 resolution: "balanced-match@npm:1.0.2" @@ -453,6 +481,13 @@ __metadata: languageName: node linkType: hard +"callsites@npm:^3.0.0": + version: 3.1.0 + resolution: "callsites@npm:3.1.0" + checksum: 072d17b6abb459c2ba96598918b55868af677154bec7e73d222ef95a8fdb9bbf7dae96a8421085cdad8cd190d86653b5b6dc55a4484f2e5b2e27d5e0c3fc15b3 + languageName: node + linkType: hard + "camelcase@npm:^5.0.0": version: 5.3.1 resolution: "camelcase@npm:5.3.1" @@ -628,6 +663,19 @@ __metadata: languageName: node linkType: hard +"cosmiconfig@npm:^6.0.0": + version: 6.0.0 + resolution: "cosmiconfig@npm:6.0.0" + dependencies: + "@types/parse-json": ^4.0.0 + import-fresh: ^3.1.0 + parse-json: ^5.0.0 + path-type: ^4.0.0 + yaml: ^1.7.2 + checksum: 8eed7c854b91643ecb820767d0deb038b50780ecc3d53b0b19e03ed8aabed4ae77271198d1ae3d49c3b110867edf679f5faad924820a8d1774144a87cb6f98fc + languageName: node + linkType: hard + "create-require@npm:^1.1.0": version: 1.1.1 resolution: "create-require@npm:1.1.1" @@ -749,6 +797,15 @@ __metadata: languageName: node linkType: hard +"error-ex@npm:^1.3.1": + version: 1.3.2 + resolution: "error-ex@npm:1.3.2" + dependencies: + is-arrayish: ^0.2.1 + checksum: c1c2b8b65f9c91b0f9d75f0debaa7ec5b35c266c2cac5de412c1a6de86d4cbae04ae44e510378cb14d032d0645a36925d0186f8bb7367bcc629db256b743a001 + languageName: node + linkType: hard + "escalade@npm:^3.1.1": version: 3.1.1 resolution: "escalade@npm:3.1.1" @@ -1035,6 +1092,16 @@ __metadata: languageName: node linkType: hard +"import-fresh@npm:^3.1.0": + version: 3.3.0 + resolution: "import-fresh@npm:3.3.0" + dependencies: + parent-module: ^1.0.0 + resolve-from: ^4.0.0 + checksum: 2cacfad06e652b1edc50be650f7ec3be08c5e5a6f6d12d035c440a42a8cc028e60a5b99ca08a77ab4d6b1346da7d971915828f33cdab730d3d42f08242d09baa + languageName: node + linkType: hard + "imurmurhash@npm:^0.1.4": version: 0.1.4 resolution: "imurmurhash@npm:0.1.4" @@ -1101,6 +1168,13 @@ __metadata: languageName: node linkType: hard +"is-arrayish@npm:^0.2.1": + version: 0.2.1 + resolution: "is-arrayish@npm:0.2.1" + checksum: eef4417e3c10e60e2c810b6084942b3ead455af16c4509959a27e490e7aee87cfb3f38e01bbde92220b528a0ee1a18d52b787e1458ee86174d8c7f0e58cd488f + languageName: node + linkType: hard + "is-binary-path@npm:~2.1.0": version: 2.1.0 resolution: "is-binary-path@npm:2.1.0" @@ -1119,6 +1193,15 @@ __metadata: languageName: node linkType: hard +"is-core-module@npm:^2.9.0": + version: 2.9.0 + resolution: "is-core-module@npm:2.9.0" + dependencies: + has: ^1.0.3 + checksum: b27034318b4b462f1c8f1dfb1b32baecd651d891a4e2d1922135daeff4141dfced2b82b07aef83ef54275c4a3526aa38da859223664d0868ca24182badb784ce + languageName: node + linkType: hard + "is-extglob@npm:^2.1.1": version: 2.1.1 resolution: "is-extglob@npm:2.1.1" @@ -1225,6 +1308,13 @@ __metadata: languageName: node linkType: hard +"json-parse-even-better-errors@npm:^2.3.0": + version: 2.3.1 + resolution: "json-parse-even-better-errors@npm:2.3.1" + checksum: 798ed4cf3354a2d9ccd78e86d2169515a0097a5c133337807cdf7f1fc32e1391d207ccfc276518cc1d7d8d4db93288b8a50ba4293d212ad1336e52a8ec0a941f + languageName: node + linkType: hard + "just-extend@npm:^4.0.2": version: 4.2.1 resolution: "just-extend@npm:4.2.1" @@ -1232,6 +1322,13 @@ __metadata: languageName: node linkType: hard +"lines-and-columns@npm:^1.1.6": + version: 1.2.4 + resolution: "lines-and-columns@npm:1.2.4" + checksum: 0c37f9f7fa212b38912b7145e1cd16a5f3cd34d782441c3e6ca653485d326f58b3caccda66efce1c5812bde4961bbde3374fae4b0d11bf1226152337f3894aa5 + languageName: node + linkType: hard + "locate-path@npm:^5.0.0": version: 5.0.0 resolution: "locate-path@npm:5.0.0" @@ -1662,6 +1759,27 @@ __metadata: languageName: node linkType: hard +"parent-module@npm:^1.0.0": + version: 1.0.1 + resolution: "parent-module@npm:1.0.1" + dependencies: + callsites: ^3.0.0 + checksum: 6ba8b255145cae9470cf5551eb74be2d22281587af787a2626683a6c20fbb464978784661478dd2a3f1dad74d1e802d403e1b03c1a31fab310259eec8ac560ff + languageName: node + linkType: hard + +"parse-json@npm:^5.0.0": + version: 5.2.0 + resolution: "parse-json@npm:5.2.0" + dependencies: + "@babel/code-frame": ^7.0.0 + error-ex: ^1.3.1 + json-parse-even-better-errors: ^2.3.0 + lines-and-columns: ^1.1.6 + checksum: 62085b17d64da57f40f6afc2ac1f4d95def18c4323577e1eced571db75d9ab59b297d1d10582920f84b15985cbfc6b6d450ccbf317644cfa176f3ed982ad87e2 + languageName: node + linkType: hard + "path-exists@npm:^4.0.0": version: 4.0.0 resolution: "path-exists@npm:4.0.0" @@ -1699,6 +1817,13 @@ __metadata: languageName: node linkType: hard +"path-type@npm:^4.0.0": + version: 4.0.0 + resolution: "path-type@npm:4.0.0" + checksum: 5b1e2daa247062061325b8fdbfd1fb56dde0a448fb1455453276ea18c60685bdad23a445dc148cf87bc216be1573357509b7d4060494a6fd768c7efad833ee45 + languageName: node + linkType: hard + "pegjs@npm:^0.10.0": version: 0.10.0 resolution: "pegjs@npm:0.10.0" @@ -1789,6 +1914,26 @@ __metadata: languageName: node linkType: hard +"resolve-from@npm:^4.0.0": + version: 4.0.0 + resolution: "resolve-from@npm:4.0.0" + checksum: f4ba0b8494846a5066328ad33ef8ac173801a51739eb4d63408c847da9a2e1c1de1e6cbbf72699211f3d13f8fc1325648b169bd15eb7da35688e30a5fb0e4a7f + languageName: node + linkType: hard + +"resolve@npm:^1.12.0": + version: 1.22.1 + resolution: "resolve@npm:1.22.1" + dependencies: + is-core-module: ^2.9.0 + path-parse: ^1.0.7 + supports-preserve-symlinks-flag: ^1.0.0 + bin: + resolve: bin/resolve + checksum: 07af5fc1e81aa1d866cbc9e9460fbb67318a10fa3c4deadc35c3ad8a898ee9a71a86a65e4755ac3195e0ea0cfbe201eb323ebe655ce90526fd61917313a34e4e + languageName: node + linkType: hard + "resolve@npm:^1.3.2": version: 1.22.0 resolution: "resolve@npm:1.22.0" @@ -1802,6 +1947,19 @@ __metadata: languageName: node linkType: hard +"resolve@patch:resolve@^1.12.0#~builtin": + version: 1.22.1 + resolution: "resolve@patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=07638b" + dependencies: + is-core-module: ^2.9.0 + path-parse: ^1.0.7 + supports-preserve-symlinks-flag: ^1.0.0 + bin: + resolve: bin/resolve + checksum: 5656f4d0bedcf8eb52685c1abdf8fbe73a1603bb1160a24d716e27a57f6cecbe2432ff9c89c2bd57542c3a7b9d14b1882b73bfe2e9d7849c9a4c0b8b39f02b8b + languageName: node + linkType: hard + "resolve@patch:resolve@^1.3.2#~builtin": version: 1.22.0 resolution: "resolve@patch:resolve@npm%3A1.22.0#~builtin::version=1.22.0&hash=07638b" @@ -2353,6 +2511,13 @@ __metadata: languageName: node linkType: hard +"yaml@npm:^1.7.2": + version: 1.10.2 + resolution: "yaml@npm:1.10.2" + checksum: ce4ada136e8a78a0b08dc10b4b900936912d15de59905b2bf415b4d33c63df1d555d23acb2a41b23cf9fb5da41c256441afca3d6509de7247daa062fd2c5ea5f + languageName: node + linkType: hard + "yargs-parser@npm:20.2.4": version: 20.2.4 resolution: "yargs-parser@npm:20.2.4"