Skip to content

Commit

Permalink
test: import jest-extended testsuite
Browse files Browse the repository at this point in the history
  • Loading branch information
ChALkeR committed Sep 4, 2024
1 parent c266fb1 commit 7483e39
Show file tree
Hide file tree
Showing 147 changed files with 5,384 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/jest-extended/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017-present Matt Phillips <[email protected]> (mattphillips.io)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
7 changes: 7 additions & 0 deletions tests/jest-extended/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# jest-extended repo tests

A subtree of the upstream jest-extended repo, snapshotted from:

<https://github.com/jest-community/jest-extended/tree/c8a31132cf2ccdfc1373d948d7ec299aea7fdfb9> (tag: `v4.0.2`)

When updating, use the same commit or update the link and incorporate the changes
1 change: 1 addition & 0 deletions tests/jest-extended/examples/typescript/all/src/add.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const add = (a: number, b: number): number => a + b;
38 changes: 38 additions & 0 deletions tests/jest-extended/examples/typescript/all/test/add.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// eslint-disable-next-line import/no-unresolved
import { add } from '../src/add.js';

describe('add', () => {
test('Commutative Law of Addition', () => {
expect(add(1, 2)).toBe(add(2, 1));
});

test('adding two integers returns an integer', () => {
expect(add(1, 100)).toBeInteger();
});

test('positive numbers remain positive', () => {
expect(add(1, 1)).toBePositive();
});

test('negative numbers remain negative', () => {
expect(add(-1, -1)).toBeNegative();
});

test('adding two even numbers does not give an odd number', () => {
expect(add(1, 3)).not.toBeOdd();
});

test('adding two odd numbers gives an even number', () => {
expect(add(1, 3)).toBeEven();
});

test('array equal another array regardless of the order', () => {
expect([1, 3]).toIncludeSameMembers([3, 1]);
});

test('array property equal another array regardless of the order', () => {
expect({ array: [1, 3] }).toEqual({
array: expect.toIncludeSameMembers([3, 1]),
});
});
});
12 changes: 12 additions & 0 deletions tests/jest-extended/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"type": "module",
"jest": {
"snapshotFormat": {
"escapeString": false,
"printBasicPrototype": false
},
"snapshotSerializers": [
"jest-serializer-ansi-escapes"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`.fail fails with message 1`] = `"This shouldn't fail!"`;

exports[`.fail fails without message 1`] = `"fails by .fail() assertion"`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`.not.pass does not pass, has no message 1`] = `"passes by .pass() assertion"`;

exports[`.not.pass does not.pass, has no message 1`] = `"This should not pass!"`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`.not.toBeAfter fails when given a later date 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).not.toBeAfter()</intensity>
Expected date to be after <red>2018-06-01T22:00:00.000Z</color> but received:
<red>2018-06-02T22:00:00.000Z</color>"
`;

exports[`.toBeAfter fails when given an earlier date 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).toBeAfter()</intensity>
Expected date to be after <red>2018-06-02T22:00:00.000Z</color> but received:
<red>2018-06-01T22:00:00.000Z</color>"
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`.not.toBeAfterOrEqualTo fails when given a later date 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).not.toBeAfterOrEqualTo()</intensity>
Expected date to be after or equal to <red>2019-09-01T22:00:00.000Z</color> but received:
<red>2019-09-10T22:00:00.000Z</color>"
`;

exports[`.not.toBeAfterOrEqualTo fails when given an equal date 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).not.toBeAfterOrEqualTo()</intensity>
Expected date to be after or equal to <red>2019-09-01T22:00:00.000Z</color> but received:
<red>2019-09-01T22:00:00.000Z</color>"
`;

exports[`.toBeAfterOrEqualTo fails when given an earlier date 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).toBeAfterOrEqualTo()</intensity>
Expected date to be after or equal to <red>2019-09-10T22:00:00.000Z</color> but received:
<red>2019-09-01T22:00:00.000Z</color>"
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`.not.toBeArray fails when given an array 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).not.toBeArray()</intensity>
Expected value to not be an array received:
<red>[]</color>"
`;

exports[`.toBeArray fails when not given an array 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).toBeArray()</intensity>
Expected value to be an array received:
<red>false</color>"
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`.not.toBeArrayOfSize fails when given an array of size 0 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).not.toBeArrayOfSize(</intensity><green>expected</color><dim>)</intensity>
Expected value to not be an array of size:
<green>0</color>
Received:
value: <red>[]</color>
length: <red>0</color>"
`;

exports[`.toBeArrayOfSize fails when given neither a parameter nor an array 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).toBeArrayOfSize(</intensity><green>expected</color><dim>)</intensity>
Expected value to be an array of size:
<green>undefined</color>
Received:
value: <red>[]</color>
length: <red>0</color>"
`;

exports[`.toBeArrayOfSize fails when given type of () => {} which is not an array 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).toBeArrayOfSize(</intensity><green>expected</color><dim>)</intensity>
Expected value to be an array of size:
<green>1</color>
Received:
value: <red>[Function anonymous]</color>
length: <red>0</color>"
`;

exports[`.toBeArrayOfSize fails when given type of {} which is not an array 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).toBeArrayOfSize(</intensity><green>expected</color><dim>)</intensity>
Expected value to be an array of size:
<green>1</color>
Received:
value: <red>{}</color>
length: <red>"Not Accessible"</color>"
`;

exports[`.toBeArrayOfSize fails when given type of 0 which is not an array 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).toBeArrayOfSize(</intensity><green>expected</color><dim>)</intensity>
Expected value to be an array of size:
<green>1</color>
Received:
value: <red>0</color>
length: <red>"Not Accessible"</color>"
`;

exports[`.toBeArrayOfSize fails when given type of NaN which is not an array 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).toBeArrayOfSize(</intensity><green>expected</color><dim>)</intensity>
Expected value to be an array of size:
<green>1</color>
Received:
value: <red>NaN</color>
length: <red>"Not Accessible"</color>"
`;

exports[`.toBeArrayOfSize fails when given type of false which is not an array 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).toBeArrayOfSize(</intensity><green>expected</color><dim>)</intensity>
Expected value to be an array of size:
<green>1</color>
Received:
value: <red>false</color>
length: <red>"Not Accessible"</color>"
`;

exports[`.toBeArrayOfSize fails when given type of null which is not an array 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).toBeArrayOfSize(</intensity><green>expected</color><dim>)</intensity>
Expected value to be an array of size:
<green>1</color>
Received:
value: <red>null</color>
length: <red>"Not Accessible"</color>"
`;

exports[`.toBeArrayOfSize fails when given type of true which is not an array 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).toBeArrayOfSize(</intensity><green>expected</color><dim>)</intensity>
Expected value to be an array of size:
<green>1</color>
Received:
value: <red>true</color>
length: <red>"Not Accessible"</color>"
`;

exports[`.toBeArrayOfSize fails when given type of undefined which is not an array 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).toBeArrayOfSize(</intensity><green>expected</color><dim>)</intensity>
Expected value to be an array of size:
<green>1</color>
Received:
value: <red>undefined</color>
length: <red>"Not Accessible"</color>"
`;

exports[`.toBeArrayOfSize fails when given type which is not an array 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).toBeArrayOfSize(</intensity><green>expected</color><dim>)</intensity>
Expected value to be an array of size:
<green>1</color>
Received:
value: <red>false</color>
length: <red>"Not Accessible"</color>"
`;

exports[`.toBeArrayOfSize fails when not given a parameter 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).toBeArrayOfSize(</intensity><green>expected</color><dim>)</intensity>
Expected value to be an array of size:
<green>undefined</color>
Received:
value: <red>[1]</color>
length: <red>1</color>"
`;

exports[`.toBeArrayOfSize fails when not given an array 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).toBeArrayOfSize(</intensity><green>expected</color><dim>)</intensity>
Expected value to be an array of size:
<green>5</color>
Received:
value: <red>undefined</color>
length: <red>"Not Accessible"</color>"
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`.not.toBeBefore fails when given an earlier date 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).not.toBeBefore()</intensity>
Expected date to be before <red>2018-06-02T22:00:00.000Z</color> but received:
<red>2018-06-01T22:00:00.000Z</color>"
`;

exports[`.toBeBefore fails when given a later date 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).toBeBefore()</intensity>
Expected date to be before <red>2018-06-01T22:00:00.000Z</color> but received:
<red>2018-06-02T22:00:00.000Z</color>"
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`.not.toBeBeforeOrEqualTo fails when given an earlier date 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).not.toBeBeforeOrEqualTo()</intensity>
Expected date to be before or equal to <red>2019-09-10T22:00:00.000Z</color> but received:
<red>2019-09-01T22:00:00.000Z</color>"
`;

exports[`.not.toBeBeforeOrEqualTo fails when given an equal date 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).not.toBeBeforeOrEqualTo()</intensity>
Expected date to be before or equal to <red>2019-09-01T22:00:00.000Z</color> but received:
<red>2019-09-01T22:00:00.000Z</color>"
`;

exports[`.toBeBeforeOrEqualTo fails when given a later date 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).toBeBeforeOrEqualTo()</intensity>
Expected date to be before or equal to <red>2019-09-01T22:00:00.000Z</color> but received:
<red>2019-09-10T22:00:00.000Z</color>"
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`.not.toBeBefore fails when date is in given range 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).not.toBeBetween()</intensity>
Expected date to be between <red>2019-09-01T22:00:00.000Z</color> and <red>2019-09-10T22:00:00.000Z</color> but received:
<red>2019-09-03T22:00:00.000Z</color>"
`;

exports[`.toBeBetween fails when date is not in given range 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).toBeBetween()</intensity>
Expected date to be between <red>2019-09-03T22:00:00.000Z</color> and <red>2019-09-10T22:00:00.000Z</color> but received:
<red>2019-09-01T22:00:00.000Z</color>"
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`.not.toBeBoolean fails when given a boolean 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).not.toBeBoolean()</intensity>
Expected value to not be of type boolean, received:
<red>true</color>"
`;

exports[`.not.toBeBoolean fails when given an object of type boolean 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).not.toBeBoolean()</intensity>
Expected value to not be of type boolean, received:
<red>{}</color>"
`;

exports[`.toBeBoolean fails when not given a boolean 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).toBeBoolean()</intensity>
Expected value to be of type boolean, received:
<red>1</color>"
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`.not.toBeDate fails when given a date 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).not.toBeDate()</intensity>
Expected value to not be a date received:
<red>2018-01-01T13:00:00.000Z</color>"
`;

exports[`.toBeDate fails when not given a date 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).toBeDate()</intensity>
Expected value to be a date received:
<red>false</color>"
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`.not.toBeDateString fails when given a date string 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).not.toBeDateString()</intensity>
Expected value to not be a date string received:
<red>"2018-01-01T13:00:00.000Z"</color>"
`;

exports[`.toBeDateString fails when not given a date string 1`] = `
"<dim>expect(</intensity><red>received</color><dim>).toBeDateString()</intensity>
Expected value to be a date string received:
<red>"not a date"</color>"
`;
Loading

0 comments on commit 7483e39

Please sign in to comment.