Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@
"avatar_url": "https://avatars.githubusercontent.com/u/43491324?v=4",
"profile": "https://github.com/ChristianSama",
"contributions": [
"doc"
"doc",
"code",
"test"
]
}
],
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center"><a href="https://github.com/alejo0o"><img src="https://avatars.githubusercontent.com/u/60680371?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Alejandro Vivanco</b></sub></a><br /><a href="https://github.com/stackbuilders/assertive-ts/commits?author=alejo0o" title="Code">💻</a> <a href="https://github.com/stackbuilders/assertive-ts/commits?author=alejo0o" title="Tests">⚠️</a></td>
<td align="center"><a href="https://github.com/dalejo96"><img src="https://avatars.githubusercontent.com/u/77456654?v=4?s=100" width="100px;" alt=""/><br /><sub><b>David Villamarin</b></sub></a><br /><a href="https://github.com/stackbuilders/assertive-ts/commits?author=dalejo96" title="Code">💻</a> <a href="https://github.com/stackbuilders/assertive-ts/commits?author=dalejo96" title="Tests">⚠️</a></td>
<td align="center"><a href="https://github.com/Alex0jk"><img src="https://avatars.githubusercontent.com/u/22301755?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Alexander Mejía</b></sub></a><br /><a href="https://github.com/stackbuilders/assertive-ts/commits?author=Alex0jk" title="Code">💻</a> <a href="https://github.com/stackbuilders/assertive-ts/commits?author=Alex0jk" title="Tests">⚠️</a></td>
<td align="center"><a href="https://github.com/ChristianSama"><img src="https://avatars.githubusercontent.com/u/43491324?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Christian Samaniego</b></sub></a><br /><a href="https://github.com/stackbuilders/assertive-ts/commits?author=ChristianSama" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/ChristianSama"><img src="https://avatars.githubusercontent.com/u/43491324?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Christian Samaniego</b></sub></a><br /><a href="https://github.com/stackbuilders/assertive-ts/commits?author=ChristianSama" title="Documentation">📖</a> <a href="https://github.com/stackbuilders/assertive-ts/commits?author=ChristianSama" title="Code">💻</a> <a href="https://github.com/stackbuilders/assertive-ts/commits?author=ChristianSama" title="Tests">⚠️</a></td>
</tr>
</table>

Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
20 changes: 10 additions & 10 deletions src/lib/DateAssertion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ export class DateAssertion extends Assertion<Date> {
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({
Expand All @@ -93,11 +93,11 @@ export class DateAssertion extends Assertion<Date> {
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({
Expand All @@ -116,11 +116,11 @@ export class DateAssertion extends Assertion<Date> {
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({
Expand All @@ -139,11 +139,11 @@ export class DateAssertion extends Assertion<Date> {
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({
Expand All @@ -162,11 +162,11 @@ export class DateAssertion extends Assertion<Date> {
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({
Expand Down
27 changes: 17 additions & 10 deletions test/lib/DateAssertion.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import dedent from "@cometlib/dedent";
import assert, { AssertionError } from "assert";

import { DateAssertion } from "../../src/lib/DateAssertion";
Expand Down Expand Up @@ -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
});
});
Expand All @@ -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);
Expand All @@ -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
});
});
Expand All @@ -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);
Expand All @@ -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
});
});
Expand All @@ -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(
Expand All @@ -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
});
});
Expand All @@ -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);
Expand All @@ -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
});
});
Expand All @@ -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);
Expand Down
Loading