@thisisagile/easy-test 15.8.4 → 15.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +379 -0
- package/dist/index.d.ts +379 -2
- package/dist/index.js +3 -19
- package/dist/index.mjs +3 -0
- package/package.json +3 -1
- package/src/matchers/Check.ts +18 -18
- package/src/matchers/HttpMatchers.ts +12 -13
- package/src/matchers/Match.ts +1 -2
- package/src/matchers/ResultMatchers.ts +3 -4
- package/src/matchers/toBeArrayOf.ts +1 -2
- package/src/matchers/toBeArrayOfWithLength.ts +1 -2
- package/src/matchers/toBeAt.ts +1 -2
- package/src/matchers/toBeExactlyAt.ts +1 -2
- package/src/matchers/toBeValid.ts +1 -2
- package/src/matchers/toFailMatcher.ts +2 -3
- package/src/matchers/toMatchExactJson.ts +1 -2
- package/src/matchers/toMatchException.ts +1 -2
- package/src/matchers/toMatchJson.ts +1 -2
- package/src/matchers/toMatchRoute.ts +1 -2
- package/src/matchers/toMatchText.ts +1 -2
- package/src/matchers/toPassMatcher.ts +3 -3
- package/src/mock/Mocks.ts +12 -16
- package/src/utils/Req.ts +9 -4
- package/dist/index.js.map +0 -1
- package/dist/matchers/Check.d.ts +0 -18
- package/dist/matchers/Check.js +0 -46
- package/dist/matchers/Check.js.map +0 -1
- package/dist/matchers/HttpMatchers.d.ts +0 -33
- package/dist/matchers/HttpMatchers.js +0 -52
- package/dist/matchers/HttpMatchers.js.map +0 -1
- package/dist/matchers/Match.d.ts +0 -13
- package/dist/matchers/Match.js +0 -36
- package/dist/matchers/Match.js.map +0 -1
- package/dist/matchers/ResultMatchers.d.ts +0 -15
- package/dist/matchers/ResultMatchers.js +0 -30
- package/dist/matchers/ResultMatchers.js.map +0 -1
- package/dist/matchers/index.d.ts +0 -19
- package/dist/matchers/index.js +0 -36
- package/dist/matchers/index.js.map +0 -1
- package/dist/matchers/toBeArrayOf.d.ts +0 -11
- package/dist/matchers/toBeArrayOf.js +0 -14
- package/dist/matchers/toBeArrayOf.js.map +0 -1
- package/dist/matchers/toBeArrayOfWithLength.d.ts +0 -11
- package/dist/matchers/toBeArrayOfWithLength.js +0 -15
- package/dist/matchers/toBeArrayOfWithLength.js.map +0 -1
- package/dist/matchers/toBeAt.d.ts +0 -11
- package/dist/matchers/toBeAt.js +0 -19
- package/dist/matchers/toBeAt.js.map +0 -1
- package/dist/matchers/toBeExactlyAt.d.ts +0 -11
- package/dist/matchers/toBeExactlyAt.js +0 -22
- package/dist/matchers/toBeExactlyAt.js.map +0 -1
- package/dist/matchers/toBeQueriedWith.d.ts +0 -9
- package/dist/matchers/toBeQueriedWith.js +0 -14
- package/dist/matchers/toBeQueriedWith.js.map +0 -1
- package/dist/matchers/toBeRoutedTo.d.ts +0 -9
- package/dist/matchers/toBeRoutedTo.js +0 -15
- package/dist/matchers/toBeRoutedTo.js.map +0 -1
- package/dist/matchers/toBeValid.d.ts +0 -10
- package/dist/matchers/toBeValid.js +0 -15
- package/dist/matchers/toBeValid.js.map +0 -1
- package/dist/matchers/toFailMatcher.d.ts +0 -21
- package/dist/matchers/toFailMatcher.js +0 -27
- package/dist/matchers/toFailMatcher.js.map +0 -1
- package/dist/matchers/toMatchArray.d.ts +0 -9
- package/dist/matchers/toMatchArray.js +0 -15
- package/dist/matchers/toMatchArray.js.map +0 -1
- package/dist/matchers/toMatchExactJson.d.ts +0 -16
- package/dist/matchers/toMatchExactJson.js +0 -21
- package/dist/matchers/toMatchExactJson.js.map +0 -1
- package/dist/matchers/toMatchException.d.ts +0 -11
- package/dist/matchers/toMatchException.js +0 -16
- package/dist/matchers/toMatchException.js.map +0 -1
- package/dist/matchers/toMatchJson.d.ts +0 -16
- package/dist/matchers/toMatchJson.js +0 -22
- package/dist/matchers/toMatchJson.js.map +0 -1
- package/dist/matchers/toMatchRoute.d.ts +0 -11
- package/dist/matchers/toMatchRoute.js +0 -15
- package/dist/matchers/toMatchRoute.js.map +0 -1
- package/dist/matchers/toMatchText.d.ts +0 -10
- package/dist/matchers/toMatchText.js +0 -15
- package/dist/matchers/toMatchText.js.map +0 -1
- package/dist/matchers/toPassMatcher.d.ts +0 -21
- package/dist/matchers/toPassMatcher.js +0 -27
- package/dist/matchers/toPassMatcher.js.map +0 -1
- package/dist/mock/Fits.d.ts +0 -24
- package/dist/mock/Fits.js +0 -44
- package/dist/mock/Fits.js.map +0 -1
- package/dist/mock/Mocks.d.ts +0 -41
- package/dist/mock/Mocks.js +0 -75
- package/dist/mock/Mocks.js.map +0 -1
- package/dist/mock/index.d.ts +0 -2
- package/dist/mock/index.js +0 -19
- package/dist/mock/index.js.map +0 -1
- package/dist/utils/Eq.d.ts +0 -5
- package/dist/utils/Eq.js +0 -11
- package/dist/utils/Eq.js.map +0 -1
- package/dist/utils/Req.d.ts +0 -14
- package/dist/utils/Req.js +0 -32
- package/dist/utils/Req.js.map +0 -1
- package/dist/utils/Response.d.ts +0 -25
- package/dist/utils/Response.js +0 -3
- package/dist/utils/Response.js.map +0 -1
- package/dist/utils/Types.d.ts +0 -44
- package/dist/utils/Types.js +0 -7
- package/dist/utils/Types.js.map +0 -1
- package/dist/utils/Utils.d.ts +0 -12
- package/dist/utils/Utils.js +0 -28
- package/dist/utils/Utils.js.map +0 -1
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import CustomMatcherResult = jest.CustomMatcherResult;
|
|
2
1
|
import { Constructor as Ctor } from '../utils/Types';
|
|
3
2
|
import { match } from './Match';
|
|
4
3
|
|
|
5
|
-
export const toBeArrayOfWithLength = <T>(items: unknown, ctor: Ctor<T>, length: number): CustomMatcherResult =>
|
|
4
|
+
export const toBeArrayOfWithLength = <T>(items: unknown, ctor: Ctor<T>, length: number): jest.CustomMatcherResult =>
|
|
6
5
|
match<unknown>(items)
|
|
7
6
|
.undefined(it => it, 'Subject is undefined.')
|
|
8
7
|
.not(it => it instanceof Array, 'Subject is not an array.')
|
package/src/matchers/toBeAt.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import CustomMatcherResult = jest.CustomMatcherResult;
|
|
2
1
|
import { Id, Tester, UseCase } from '../utils/Types';
|
|
3
2
|
import { match } from './Match';
|
|
4
3
|
|
|
5
|
-
export const toBeAt = (tester?: Tester, uc?: UseCase, id?: Id): CustomMatcherResult => {
|
|
4
|
+
export const toBeAt = (tester?: Tester, uc?: UseCase, id?: Id): jest.CustomMatcherResult => {
|
|
6
5
|
return match<Tester>(tester as Tester)
|
|
7
6
|
.undefined(t => t, 'Tester is undefined')
|
|
8
7
|
.undefined(t => t.url, 'Tester does not contain a URL')
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import CustomMatcherResult = jest.CustomMatcherResult;
|
|
2
1
|
import { Id, Tester, UseCase } from '../utils/Types';
|
|
3
2
|
import { isDefined } from '../utils/Utils';
|
|
4
3
|
import { match } from './Match';
|
|
@@ -8,7 +7,7 @@ const toUrl = (uc: UseCase, id?: Id): string => {
|
|
|
8
7
|
return `/${uc.app.id}/${uc.id}${i}`;
|
|
9
8
|
};
|
|
10
9
|
|
|
11
|
-
export const toBeExactlyAt = (tester?: Tester, uc?: UseCase, id?: Id): CustomMatcherResult => {
|
|
10
|
+
export const toBeExactlyAt = (tester?: Tester, uc?: UseCase, id?: Id): jest.CustomMatcherResult => {
|
|
12
11
|
return match<Tester>(tester as Tester)
|
|
13
12
|
.undefined(t => t, 'Tester is undefined')
|
|
14
13
|
.undefined(t => t.url, 'Tester does not contain a URL')
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import CustomMatcherResult = jest.CustomMatcherResult;
|
|
2
1
|
import { Validatable } from '../utils/Types';
|
|
3
2
|
import { isA } from '../utils/Utils';
|
|
4
3
|
import { match } from './Match';
|
|
5
4
|
|
|
6
|
-
export const toBeValid = (v?: unknown): CustomMatcherResult =>
|
|
5
|
+
export const toBeValid = (v?: unknown): jest.CustomMatcherResult =>
|
|
7
6
|
match<Validatable>(v as Validatable)
|
|
8
7
|
.undefined(s => s, 'Subject is undefined.')
|
|
9
8
|
.not(s => isA<Validatable>(s, 'isValid'), 'Subject is not validatable.')
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { match } from './Match';
|
|
2
2
|
import { Message, toMessage } from '../utils/Types';
|
|
3
|
-
import CustomMatcherResult = jest.CustomMatcherResult;
|
|
4
3
|
|
|
5
4
|
// Handles CustomMatcherResult validations.
|
|
6
5
|
|
|
@@ -14,7 +13,7 @@ export const FailsWith = {
|
|
|
14
13
|
No: (message: string, instead: string): string => `Match does fail, however not with message '${message}', but with message '${instead}' instead.`,
|
|
15
14
|
};
|
|
16
15
|
|
|
17
|
-
export const toFailMatcher = (result: CustomMatcherResult): CustomMatcherResult =>
|
|
16
|
+
export const toFailMatcher = (result: jest.CustomMatcherResult): jest.CustomMatcherResult =>
|
|
18
17
|
match(result)
|
|
19
18
|
.not(
|
|
20
19
|
c => !c.pass,
|
|
@@ -22,7 +21,7 @@ export const toFailMatcher = (result: CustomMatcherResult): CustomMatcherResult
|
|
|
22
21
|
)
|
|
23
22
|
.else(Fails.Yes);
|
|
24
23
|
|
|
25
|
-
export const toFailMatcherWith = (result: CustomMatcherResult, message: Message<CustomMatcherResult>): CustomMatcherResult =>
|
|
24
|
+
export const toFailMatcherWith = (result: jest.CustomMatcherResult, message: Message<jest.CustomMatcherResult>): jest.CustomMatcherResult =>
|
|
26
25
|
match(result)
|
|
27
26
|
.not(
|
|
28
27
|
c => !c.pass,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import CustomMatcherResult = jest.CustomMatcherResult;
|
|
2
1
|
import { match } from './Match';
|
|
3
2
|
import { eq } from '../utils/Eq';
|
|
4
3
|
|
|
@@ -9,7 +8,7 @@ export const MatchesExactJson = {
|
|
|
9
8
|
Yes: 'Object matches subject exactly',
|
|
10
9
|
};
|
|
11
10
|
|
|
12
|
-
export const toMatchExactJson = (value?: unknown, json?: unknown): CustomMatcherResult =>
|
|
11
|
+
export const toMatchExactJson = (value?: unknown, json?: unknown): jest.CustomMatcherResult =>
|
|
13
12
|
match<unknown>(value)
|
|
14
13
|
.undefined(v => v, MatchesExactJson.SubjectUndefined)
|
|
15
14
|
.undefined(() => json, MatchesExactJson.SubsetUndefined)
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import CustomMatcherResult = jest.CustomMatcherResult;
|
|
2
1
|
import { Exception } from '../utils/Types';
|
|
3
2
|
import { match } from './Match';
|
|
4
3
|
import { isDefined } from '../utils/Utils';
|
|
5
4
|
|
|
6
|
-
export const toMatchException = (received: Exception, expected: unknown, reason?: string): CustomMatcherResult =>
|
|
5
|
+
export const toMatchException = (received: Exception, expected: unknown, reason?: string): jest.CustomMatcherResult =>
|
|
7
6
|
match<Exception>(expected as Exception)
|
|
8
7
|
.undefined(e => e.id, 'Expected value is not an exception.')
|
|
9
8
|
.not(
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import CustomMatcherResult = jest.CustomMatcherResult;
|
|
2
1
|
import { match } from './Match';
|
|
3
2
|
import { eq } from '../utils/Eq';
|
|
4
3
|
import { asJson } from '../utils/Utils';
|
|
@@ -10,7 +9,7 @@ export const MatchesJson = {
|
|
|
10
9
|
Yes: 'Subset matches subject',
|
|
11
10
|
};
|
|
12
11
|
|
|
13
|
-
export const toMatchJson = (value?: unknown, subset?: unknown): CustomMatcherResult =>
|
|
12
|
+
export const toMatchJson = (value?: unknown, subset?: unknown): jest.CustomMatcherResult =>
|
|
14
13
|
match<unknown>(value)
|
|
15
14
|
.undefined(v => v, MatchesJson.SubjectUndefined)
|
|
16
15
|
.undefined(() => subset, MatchesJson.SubsetUndefined)
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import CustomMatcherResult = jest.CustomMatcherResult;
|
|
2
1
|
import { Uri } from '../utils/Types';
|
|
3
2
|
import { match } from './Match';
|
|
4
3
|
import { asString } from '../utils/Utils';
|
|
5
4
|
|
|
6
|
-
export const toMatchRoute = (uri?: Uri, route?: Uri | string): CustomMatcherResult =>
|
|
5
|
+
export const toMatchRoute = (uri?: Uri, route?: Uri | string): jest.CustomMatcherResult =>
|
|
7
6
|
match<Uri | undefined>(uri)
|
|
8
7
|
.undefined(u => u, 'Subject is undefined.')
|
|
9
8
|
.undefined(() => route, 'Route to include is undefined.')
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import CustomMatcherResult = jest.CustomMatcherResult;
|
|
2
1
|
import { match } from './Match';
|
|
3
2
|
import { asString } from '../utils/Utils';
|
|
4
3
|
|
|
5
|
-
export const toMatchText = (value?: unknown, text?: unknown): CustomMatcherResult =>
|
|
4
|
+
export const toMatchText = (value?: unknown, text?: unknown): jest.CustomMatcherResult =>
|
|
6
5
|
match<unknown>(value)
|
|
7
6
|
.undefined(v => v, 'Subject is undefined.')
|
|
8
7
|
.undefined(() => text, 'Text to match with is undefined.')
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { match } from './Match';
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import { Message, toMessage } from '../utils/Types';
|
|
4
4
|
|
|
5
5
|
// Handles CustomMatcherResult validations.
|
|
@@ -14,7 +14,7 @@ export const PassesWith = {
|
|
|
14
14
|
No: (message: string, instead: string): string => `Match does pass, however not with message '${message}', but with message '${instead}' instead.`,
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
export const toPassMatcher = (result: CustomMatcherResult): CustomMatcherResult =>
|
|
17
|
+
export const toPassMatcher = (result: jest.CustomMatcherResult): jest.CustomMatcherResult =>
|
|
18
18
|
match(result)
|
|
19
19
|
.not(
|
|
20
20
|
c => c.pass,
|
|
@@ -22,7 +22,7 @@ export const toPassMatcher = (result: CustomMatcherResult): CustomMatcherResult
|
|
|
22
22
|
)
|
|
23
23
|
.else(Passes.Yes);
|
|
24
24
|
|
|
25
|
-
export const toPassMatcherWith = (result: CustomMatcherResult, message: Message<CustomMatcherResult>): CustomMatcherResult =>
|
|
25
|
+
export const toPassMatcherWith = (result: jest.CustomMatcherResult, message: Message<jest.CustomMatcherResult>): jest.CustomMatcherResult =>
|
|
26
26
|
match(result)
|
|
27
27
|
.not(
|
|
28
28
|
c => c.pass,
|
package/src/mock/Mocks.ts
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import NonFunctionPropertyNames = jest.NonFunctionPropertyNames;
|
|
2
|
-
import SpyInstance = jest.SpyInstance;
|
|
3
|
-
import Mock = jest.Mock;
|
|
4
|
-
import PropertyAccessors = jest.PropertyAccessors;
|
|
5
1
|
import { Id, Json } from '../utils/Types';
|
|
6
2
|
import { Req } from '../utils/Req';
|
|
7
3
|
import { HttpStatus, Response } from '../utils/Response';
|
|
8
4
|
|
|
9
5
|
export class Mocks {
|
|
10
6
|
clear = (): typeof jest => jest.clearAllMocks();
|
|
11
|
-
impl = (f?: (...args: any[]) => any): Mock => jest.fn().mockImplementation(f);
|
|
12
|
-
property = <T extends object, P extends NonFunctionPropertyNames<Required<T>>>(object: T, getter: P, value: T[P]): SpyInstance =>
|
|
13
|
-
jest.spyOn(object, getter, 'get' as PropertyAccessors<P, T>).mockReturnValue(value as any);
|
|
14
|
-
reject = (value?: unknown): Mock => jest.fn().mockRejectedValue(value);
|
|
15
|
-
rejectWith = <T = any>(props: Partial<T> = {}): Mock => jest.fn().mockRejectedValue(mock.a(props));
|
|
7
|
+
impl = (f?: (...args: any[]) => any): jest.Mock => jest.fn().mockImplementation(f);
|
|
8
|
+
property = <T extends object, P extends jest.NonFunctionPropertyNames<Required<T>>>(object: T, getter: P, value: T[P]): jest.SpyInstance =>
|
|
9
|
+
jest.spyOn(object, getter, 'get' as jest.PropertyAccessors<P, T>).mockReturnValue(value as any);
|
|
10
|
+
reject = (value?: unknown): jest.Mock => jest.fn().mockRejectedValue(value);
|
|
11
|
+
rejectWith = <T = any>(props: Partial<T> = {}): jest.Mock => jest.fn().mockRejectedValue(mock.a(props));
|
|
16
12
|
req = {
|
|
17
13
|
id: (id: Id): Req => new Req({ id }),
|
|
18
14
|
q: (q: unknown): Req => new Req({ q }),
|
|
@@ -44,13 +40,13 @@ export class Mocks {
|
|
|
44
40
|
},
|
|
45
41
|
}),
|
|
46
42
|
};
|
|
47
|
-
resolve = (value?: unknown): Mock => jest.fn().mockResolvedValue(value);
|
|
48
|
-
resolveWith = <T = any>(props: Partial<T> = {}): Mock => jest.fn().mockResolvedValue(mock.a(props));
|
|
49
|
-
return = (value?: unknown): Mock => jest.fn().mockReturnValue(value);
|
|
50
|
-
returnWith = <T = any>(props: Partial<T> = {}): Mock => jest.fn().mockReturnValue(mock.a(props));
|
|
51
|
-
this = (): Mock => jest.fn().mockReturnThis();
|
|
43
|
+
resolve = (value?: unknown): jest.Mock => jest.fn().mockResolvedValue(value);
|
|
44
|
+
resolveWith = <T = any>(props: Partial<T> = {}): jest.Mock => jest.fn().mockResolvedValue(mock.a(props));
|
|
45
|
+
return = (value?: unknown): jest.Mock => jest.fn().mockReturnValue(value);
|
|
46
|
+
returnWith = <T = any>(props: Partial<T> = {}): jest.Mock => jest.fn().mockReturnValue(mock.a(props));
|
|
47
|
+
this = (): jest.Mock => jest.fn().mockReturnThis();
|
|
52
48
|
provider = {
|
|
53
|
-
data: (...items: any[]): { execute: Mock } => ({
|
|
49
|
+
data: (...items: any[]): { execute: jest.Mock } => ({
|
|
54
50
|
execute: jest.fn().mockResolvedValue({
|
|
55
51
|
body: {
|
|
56
52
|
data: {
|
|
@@ -71,7 +67,7 @@ export class Mocks {
|
|
|
71
67
|
date.toDateString = mock.return('19/01/1970');
|
|
72
68
|
return date;
|
|
73
69
|
};
|
|
74
|
-
once = (...values: unknown[]): Mock => values.reduce((m: Mock, v: unknown) => m.mockImplementationOnce(() => v), jest.fn());
|
|
70
|
+
once = (...values: unknown[]): jest.Mock => values.reduce((m: jest.Mock, v: unknown) => m.mockImplementationOnce(() => v), jest.fn());
|
|
75
71
|
}
|
|
76
72
|
|
|
77
73
|
export const mock = new Mocks();
|
package/src/utils/Req.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { asNumber,
|
|
1
|
+
import { asNumber, isNumber } from './Utils';
|
|
2
2
|
import { Id, Json, JsonValue, OneOrMore, Text } from './Types';
|
|
3
3
|
|
|
4
4
|
export class Req {
|
|
5
|
-
readonly skip = isDefined(this.query?.skip) ? asNumber(this.query?.skip) : undefined;
|
|
6
|
-
readonly take = isDefined(this.query?.take) ? asNumber(this.query?.take) : undefined;
|
|
7
|
-
|
|
8
5
|
constructor(readonly state: any = {}) {}
|
|
9
6
|
|
|
10
7
|
get id(): Id {
|
|
@@ -23,6 +20,14 @@ export class Req {
|
|
|
23
20
|
return this.state?.query ?? {};
|
|
24
21
|
}
|
|
25
22
|
|
|
23
|
+
get skip(): number | undefined {
|
|
24
|
+
return isNumber(this.query?.skip) ? asNumber(this.query?.skip) : undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
get take(): number | undefined {
|
|
28
|
+
return isNumber(this.query?.take) ? asNumber(this.query?.take) : undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
26
31
|
get body(): unknown {
|
|
27
32
|
return this.state.body;
|
|
28
33
|
}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,yCAAuB"}
|
package/dist/matchers/Check.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/// <reference types="jest" />
|
|
2
|
-
import CustomMatcherResult = jest.CustomMatcherResult;
|
|
3
|
-
type ToMessage<S> = string | ((s: S[]) => string);
|
|
4
|
-
declare class Check<S> {
|
|
5
|
-
private ctx;
|
|
6
|
-
private readonly received;
|
|
7
|
-
private readonly expected;
|
|
8
|
-
private readonly failed;
|
|
9
|
-
private readonly message;
|
|
10
|
-
constructor(ctx: jest.MatcherContext, received: S, expected: S, failed?: boolean, message?: string);
|
|
11
|
-
print(message: ToMessage<S>): string;
|
|
12
|
-
not(p: (s: (S)[]) => boolean, message: ToMessage<S>): Check<S>;
|
|
13
|
-
undefined(p: (s: (S)[]) => any, message: ToMessage<S>): Check<S>;
|
|
14
|
-
else(message?: ToMessage<S>): CustomMatcherResult;
|
|
15
|
-
}
|
|
16
|
-
export declare const check: <S>(ctx: jest.MatcherContext, received: S, expected?: S | undefined) => Check<S>;
|
|
17
|
-
export declare const checkDefined: <S>(ctx: jest.MatcherContext, received: S, expected?: S | undefined) => Check<S>;
|
|
18
|
-
export {};
|
package/dist/matchers/Check.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkDefined = exports.check = void 0;
|
|
4
|
-
const Utils_1 = require("../utils/Utils");
|
|
5
|
-
class Check {
|
|
6
|
-
constructor(ctx, received, expected, failed = false, message = "") {
|
|
7
|
-
this.ctx = ctx;
|
|
8
|
-
this.received = received;
|
|
9
|
-
this.expected = expected;
|
|
10
|
-
this.failed = failed;
|
|
11
|
-
this.message = message;
|
|
12
|
-
}
|
|
13
|
-
print(message) {
|
|
14
|
-
return (typeof message === "function" ? message([this.received, this.expected]) : message)
|
|
15
|
-
.replace("{r}", this.ctx.utils.printReceived(this.received))
|
|
16
|
-
.replace("{e}", this.ctx.utils.printExpected(this.expected))
|
|
17
|
-
.replace("{diff}", this.ctx.utils.diff(this.received, this.expected) ?? "");
|
|
18
|
-
}
|
|
19
|
-
not(p, message) {
|
|
20
|
-
if (this.failed) {
|
|
21
|
-
return this;
|
|
22
|
-
}
|
|
23
|
-
try {
|
|
24
|
-
return new Check(this.ctx, this.received, this.expected, !p([this.received, this.expected]), this.print(message));
|
|
25
|
-
}
|
|
26
|
-
catch (e) {
|
|
27
|
-
return new Check(this.ctx, this.received, this.expected, true, e.message);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
undefined(p, message) {
|
|
31
|
-
return this.not(() => (0, Utils_1.isDefined)(p([this.received, this.expected])), this.print(message));
|
|
32
|
-
}
|
|
33
|
-
else(message = "Expected {r} not to match with {e}, but it did.") {
|
|
34
|
-
return {
|
|
35
|
-
pass: !this.failed,
|
|
36
|
-
message: () => (this.failed ? this.message : this.print(message))
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
const check = (ctx, received, expected) => new Check(ctx, received, expected);
|
|
41
|
-
exports.check = check;
|
|
42
|
-
const checkDefined = (ctx, received, expected) => new Check(ctx, received, expected)
|
|
43
|
-
.undefined(([r]) => r, "Received array is undefined.")
|
|
44
|
-
.undefined(([, e]) => e, "Expected array is undefined.");
|
|
45
|
-
exports.checkDefined = checkDefined;
|
|
46
|
-
//# sourceMappingURL=Check.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Check.js","sourceRoot":"","sources":["../../src/matchers/Check.ts"],"names":[],"mappings":";;;AAAA,0CAA2C;AAM3C,MAAM,KAAK;IACT,YAAoB,GAAwB,EAAmB,QAAW,EAAmB,QAAW,EAAmB,SAAS,KAAK,EAAmB,UAAU,EAAE;QAApJ,QAAG,GAAH,GAAG,CAAqB;QAAmB,aAAQ,GAAR,QAAQ,CAAG;QAAmB,aAAQ,GAAR,QAAQ,CAAG;QAAmB,WAAM,GAAN,MAAM,CAAQ;QAAmB,YAAO,GAAP,OAAO,CAAK;IACxK,CAAC;IAED,KAAK,CAAC,OAAqB;QACzB,OAAO,CAAC,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;aACvF,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;aAC3D,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ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,CAAC;IACJ,CAAC;CACF;AAEM,MAAM,KAAK,GAAG,CAAI,GAAwB,EAAE,QAAW,EAAE,QAAY,EAAY,EAAE,CAAC,IAAI,KAAK,CAAI,GAAG,EAAE,QAAQ,EAAE,QAAa,CAAC,CAAC;AAAzH,QAAA,KAAK,SAAoH;AAE/H,MAAM,YAAY,GAAG,CAAI,GAAwB,EAAE,QAAW,EAAE,QAAY,EAAY,EAAE,CAAC,IAAI,KAAK,CAAI,GAAG,EAAE,QAAQ,EAAE,QAAa,CAAC;KACzI,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,8BAA8B,CAAC;KACrD,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,8BAA8B,CAAC,CACzD;AAHY,QAAA,YAAY,gBAGxB"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/// <reference types="jest" />
|
|
2
|
-
import CustomMatcherResult = jest.CustomMatcherResult;
|
|
3
|
-
import { Response } from '../utils/Response';
|
|
4
|
-
export declare const toHaveStatus: (res: Response, code: number) => CustomMatcherResult;
|
|
5
|
-
export declare const toBeOk: (res: Response) => CustomMatcherResult;
|
|
6
|
-
export declare const toBeCreated: (res: Response) => CustomMatcherResult;
|
|
7
|
-
export declare const toHaveNoContent: (res: Response) => CustomMatcherResult;
|
|
8
|
-
export declare const toBeBadRequest: (res: Response) => CustomMatcherResult;
|
|
9
|
-
export declare const toBeUnauthorized: (res: Response) => CustomMatcherResult;
|
|
10
|
-
export declare const toBeForbidden: (res: Response) => CustomMatcherResult;
|
|
11
|
-
export declare const toBeNotFound: (res: Response) => CustomMatcherResult;
|
|
12
|
-
export declare const toBeConflict: (res: Response) => CustomMatcherResult;
|
|
13
|
-
export declare const toBeInternalServerError: (res: Response) => CustomMatcherResult;
|
|
14
|
-
export declare const toBeBadGateway: (res: Response) => CustomMatcherResult;
|
|
15
|
-
export declare const toBeOkWithItems: (res: Response, length: number) => CustomMatcherResult;
|
|
16
|
-
declare global {
|
|
17
|
-
namespace jest {
|
|
18
|
-
interface Matchers<R, T> {
|
|
19
|
-
toBeOk(): R;
|
|
20
|
-
toBeOkWithItems(length: number): R;
|
|
21
|
-
toBeCreated(): R;
|
|
22
|
-
toHaveNoContent(): R;
|
|
23
|
-
toBeNotFound(): R;
|
|
24
|
-
toBeUnauthorized(): R;
|
|
25
|
-
toBeForbidden(): R;
|
|
26
|
-
toBeBadRequest(): R;
|
|
27
|
-
toBeConflict(): R;
|
|
28
|
-
toBeInternalServerError(): R;
|
|
29
|
-
toBeBadGateway(): R;
|
|
30
|
-
toHaveStatus(code: number): R;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toBeOkWithItems = exports.toBeBadGateway = exports.toBeInternalServerError = exports.toBeConflict = exports.toBeNotFound = exports.toBeForbidden = exports.toBeUnauthorized = exports.toBeBadRequest = exports.toHaveNoContent = exports.toBeCreated = exports.toBeOk = exports.toHaveStatus = void 0;
|
|
4
|
-
const Match_1 = require("./Match");
|
|
5
|
-
const toHaveStatus = (res, code) => (0, Match_1.match)(res)
|
|
6
|
-
.undefined(r => r, 'Response is unknown.')
|
|
7
|
-
.undefined(r => r?.status?.id, () => 'Response does not have a status code')
|
|
8
|
-
.not(r => r.status.id === code, r => `Response does not have code '${code}', but has code '${r.status.id}' instead.`)
|
|
9
|
-
.else(`Response does have status code '${code}'.`);
|
|
10
|
-
exports.toHaveStatus = toHaveStatus;
|
|
11
|
-
const toBeOk = (res) => (0, exports.toHaveStatus)(res, 200);
|
|
12
|
-
exports.toBeOk = toBeOk;
|
|
13
|
-
const toBeCreated = (res) => (0, exports.toHaveStatus)(res, 201);
|
|
14
|
-
exports.toBeCreated = toBeCreated;
|
|
15
|
-
const toHaveNoContent = (res) => (0, exports.toHaveStatus)(res, 204);
|
|
16
|
-
exports.toHaveNoContent = toHaveNoContent;
|
|
17
|
-
const toBeBadRequest = (res) => (0, exports.toHaveStatus)(res, 400);
|
|
18
|
-
exports.toBeBadRequest = toBeBadRequest;
|
|
19
|
-
const toBeUnauthorized = (res) => (0, exports.toHaveStatus)(res, 401);
|
|
20
|
-
exports.toBeUnauthorized = toBeUnauthorized;
|
|
21
|
-
const toBeForbidden = (res) => (0, exports.toHaveStatus)(res, 403);
|
|
22
|
-
exports.toBeForbidden = toBeForbidden;
|
|
23
|
-
const toBeNotFound = (res) => (0, exports.toHaveStatus)(res, 404);
|
|
24
|
-
exports.toBeNotFound = toBeNotFound;
|
|
25
|
-
const toBeConflict = (res) => (0, exports.toHaveStatus)(res, 409);
|
|
26
|
-
exports.toBeConflict = toBeConflict;
|
|
27
|
-
const toBeInternalServerError = (res) => (0, exports.toHaveStatus)(res, 500);
|
|
28
|
-
exports.toBeInternalServerError = toBeInternalServerError;
|
|
29
|
-
const toBeBadGateway = (res) => (0, exports.toHaveStatus)(res, 502);
|
|
30
|
-
exports.toBeBadGateway = toBeBadGateway;
|
|
31
|
-
const toBeOkWithItems = (res, length) => (0, Match_1.match)(res)
|
|
32
|
-
.undefined(r => r.status?.id, 'Response did not have a status')
|
|
33
|
-
.not(r => r.status.id === 200, r => `Response did not have status '200'. It had status '${r.status.id}' instead.`)
|
|
34
|
-
.undefined(r => r?.body?.data?.items, `Response did not have any items.`)
|
|
35
|
-
.not(r => (r?.body?.data?.itemCount ?? 0) >= length, r => `Response did not have at least ${length} items. It only had ${r?.body?.data?.itemCount ?? 0} items.`)
|
|
36
|
-
.else(`Response had status 200 and at least ${length} items`);
|
|
37
|
-
exports.toBeOkWithItems = toBeOkWithItems;
|
|
38
|
-
expect.extend({
|
|
39
|
-
toBeOk: exports.toBeOk,
|
|
40
|
-
toBeOkWithItems: exports.toBeOkWithItems,
|
|
41
|
-
toBeCreated: exports.toBeCreated,
|
|
42
|
-
toHaveNoContent: exports.toHaveNoContent,
|
|
43
|
-
toBeNotFound: exports.toBeNotFound,
|
|
44
|
-
toBeBadRequest: exports.toBeBadRequest,
|
|
45
|
-
toBeUnauthorized: exports.toBeUnauthorized,
|
|
46
|
-
toBeForbidden: exports.toBeForbidden,
|
|
47
|
-
toBeConflict: exports.toBeConflict,
|
|
48
|
-
toBeInternalServerError: exports.toBeInternalServerError,
|
|
49
|
-
toHaveStatus: exports.toHaveStatus,
|
|
50
|
-
toBeBadGateway: exports.toBeBadGateway,
|
|
51
|
-
});
|
|
52
|
-
//# sourceMappingURL=HttpMatchers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HttpMatchers.js","sourceRoot":"","sources":["../../src/matchers/HttpMatchers.ts"],"names":[],"mappings":";;;AAEA,mCAAgC;AAEzB,MAAM,YAAY,GAAG,CAAC,GAAa,EAAE,IAAY,EAAuB,EAAE,CAC/E,IAAA,aAAK,EAAW,GAAG,CAAC;KACjB,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,sBAAsB,CAAC;KACzC,SAAS,CACR,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAClB,GAAG,EAAE,CAAC,sCAAsC,CAC7C;KACA,GAAG,CACF,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,IAAI,EACzB,CAAC,CAAC,EAAE,CAAC,gCAAgC,IAAI,oBAAoB,CAAC,CAAC,MAAM,CAAC,EAAE,YAAY,CACrF;KACA,IAAI,CAAC,mCAAmC,IAAI,IAAI,CAAC,CAAC;AAX1C,QAAA,YAAY,gBAW8B;AAEhD,MAAM,MAAM,GAAG,CAAC,GAAa,EAAuB,EAAE,CAAC,IAAA,oBAAY,EAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAAxE,QAAA,MAAM,UAAkE;AAE9E,MAAM,WAAW,GAAG,CAAC,GAAa,EAAuB,EAAE,CAAC,IAA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W,GAAG,CAAC;KACjB,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,EAAE,gCAAgC,CAAC;KAC9D,GAAG,CACF,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,GAAG,EACxB,CAAC,CAAC,EAAE,CAAC,sDAAsD,CAAC,CAAC,MAAM,CAAC,EAAE,YAAY,CACnF;KACA,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,kCAAkC,CAAC;KACxE,GAAG,CACF,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,IAAI,CAAC,CAAC,IAAI,MAAM,EAC9C,CAAC,CAAC,EAAE,CAAC,kCAAkC,MAAM,uBAAuB,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,IAAI,CAAC,SAAS,CAC3G;KACA,IAAI,CAAC,wCAAwC,MAAM,QAAQ,CAAC,CAAC;AAZrD,QAAA,eAAe,mBAYsC;AAElE,MAAM,CAAC,MAAM,CAAC;IACZ,MAAM,EAAN,cAAM;IACN,eAAe,EAAf,uBAAe;IACf,WAAW,EAAX,mBAAW;IACX,eAAe,EAAf,uBAAe;IACf,YAAY,EAAZ,oBAAY;IACZ,cAAc,EAAd,sBAAc;IACd,gBAAgB,EAAhB,wBAAgB;IAChB,aAAa,EAAb,qBAAa;IACb,YAAY,EAAZ,oBAAY;IACZ,uBAAuB,EAAvB,+BAAuB;IACvB,YAAY,EAAZ,oBAAY;IACZ,cAAc,EAAd,sBAAc;CACf,CAAC,CAAC"}
|
package/dist/matchers/Match.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/// <reference types="jest" />
|
|
2
|
-
import { Message } from '../utils/Types';
|
|
3
|
-
import CustomMatcherResult = jest.CustomMatcherResult;
|
|
4
|
-
export declare class Match<S> {
|
|
5
|
-
private readonly subject;
|
|
6
|
-
private readonly failed;
|
|
7
|
-
private readonly message;
|
|
8
|
-
constructor(subject: S, failed?: boolean, message?: Message<S>);
|
|
9
|
-
not(p: (s: S) => boolean, message: Message<S>): Match<S>;
|
|
10
|
-
undefined(p: (s: S) => any, message: Message<S>): Match<S>;
|
|
11
|
-
else(message: Message<S>): CustomMatcherResult;
|
|
12
|
-
}
|
|
13
|
-
export declare const match: <S>(subject: S) => Match<S>;
|
package/dist/matchers/Match.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.match = exports.Match = void 0;
|
|
4
|
-
const Utils_1 = require("../utils/Utils");
|
|
5
|
-
const Types_1 = require("../utils/Types");
|
|
6
|
-
class Match {
|
|
7
|
-
constructor(subject, failed = false, message = '') {
|
|
8
|
-
this.subject = subject;
|
|
9
|
-
this.failed = failed;
|
|
10
|
-
this.message = message;
|
|
11
|
-
}
|
|
12
|
-
not(p, message) {
|
|
13
|
-
if (this.failed) {
|
|
14
|
-
return this;
|
|
15
|
-
}
|
|
16
|
-
try {
|
|
17
|
-
return new Match(this.subject, !p(this.subject), (0, Types_1.toMessage)(message, this.subject));
|
|
18
|
-
}
|
|
19
|
-
catch (e) {
|
|
20
|
-
return new Match(this.subject, true, e.message);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
undefined(p, message) {
|
|
24
|
-
return this.not(() => (0, Utils_1.isDefined)(p(this.subject)), message);
|
|
25
|
-
}
|
|
26
|
-
else(message) {
|
|
27
|
-
return {
|
|
28
|
-
pass: !this.failed,
|
|
29
|
-
message: () => (this.failed ? (0, Types_1.toMessage)(this.message) : `${(0, Types_1.toMessage)(message, this.subject)}, which we did not expect.`),
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.Match = Match;
|
|
34
|
-
const match = (subject) => new Match(subject);
|
|
35
|
-
exports.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IAAI,CAAC,OAAO,CAAC,4BAA4B,CAAC;SACzH,CAAC;IACJ,CAAC;CACF;AAzBD,sBAyBC;AAEM,MAAM,KAAK,GAAG,CAAI,OAAU,EAAY,EAAE,CAAC,IAAI,KAAK,CAAI,OAAO,CAAC,CAAC;AAA3D,QAAA,KAAK,SAAsD"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/// <reference types="jest" />
|
|
2
|
-
import CustomMatcherResult = jest.CustomMatcherResult;
|
|
3
|
-
import { Results } from '../utils/Types';
|
|
4
|
-
export declare const toResultWith: (results: Results, message: string) => CustomMatcherResult;
|
|
5
|
-
export declare const toFail: (results: Results) => CustomMatcherResult;
|
|
6
|
-
export declare const toFailWith: (results: Results, message: string) => CustomMatcherResult;
|
|
7
|
-
declare global {
|
|
8
|
-
namespace jest {
|
|
9
|
-
interface Matchers<R, T> {
|
|
10
|
-
toResultWith(message: string): R;
|
|
11
|
-
toFail(): R;
|
|
12
|
-
toFailWith(message: string): R;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toFailWith = exports.toFail = exports.toResultWith = void 0;
|
|
4
|
-
const Match_1 = require("./Match");
|
|
5
|
-
const notDefined = 'Results is not defined.';
|
|
6
|
-
const doesNotFail = 'Results does not fail.';
|
|
7
|
-
const hasMessage = (res, message) => res.results.some((r) => r.message === message);
|
|
8
|
-
const messages = (res) => "'" + res?.results.map(r => r.message).join("', '") + "'";
|
|
9
|
-
const toResultWith = (results, message) => (0, Match_1.match)(results)
|
|
10
|
-
.undefined(r => r, notDefined)
|
|
11
|
-
.not(r => hasMessage(r, message), r => `Results does not have message '${message}', but it has messages ${messages(r)} instead.`)
|
|
12
|
-
.else(`Succeeds with message ${message}`);
|
|
13
|
-
exports.toResultWith = toResultWith;
|
|
14
|
-
const toFail = (results) => (0, Match_1.match)(results)
|
|
15
|
-
.undefined(r => r, notDefined)
|
|
16
|
-
.not(r => !r.isValid, doesNotFail)
|
|
17
|
-
.else('Results does not fail');
|
|
18
|
-
exports.toFail = toFail;
|
|
19
|
-
const toFailWith = (results, message) => (0, Match_1.match)(results)
|
|
20
|
-
.undefined(r => r, notDefined)
|
|
21
|
-
.not(r => !r.isValid, doesNotFail)
|
|
22
|
-
.not(r => hasMessage(r, message), r => `Fails, but results does not have message '${message}', but it has messages ${messages(r)} instead.`)
|
|
23
|
-
.else(`Fails with message '${message}'`);
|
|
24
|
-
exports.toFailWith = toFailWith;
|
|
25
|
-
expect.extend({
|
|
26
|
-
toResultWith: exports.toResultWith,
|
|
27
|
-
toFail: exports.toFail,
|
|
28
|
-
toFailWith: exports.toFailWith,
|
|
29
|
-
});
|
|
30
|
-
//# sourceMappingURL=ResultMatchers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ResultMatchers.js","sourceRoot":"","sources":["../../src/matchers/ResultMatchers.ts"],"names":[],"mappings":";;;AACA,mCAAgC;AAKhC,MAAM,UAAU,GAAG,yBAAyB,CAAC;AAC7C,MAAM,WAAW,GAAG,wBAAwB,CAAC;AAE7C,MAAM,UAAU,GAAG,CAAC,GAAY,EAAE,OAAe,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC;AAE1G,MAAM,QAAQ,GAAG,CAAC,GAAY,EAAU,EAAE,CAAC,GAAG,GAAG,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC;AAE9F,MAAM,YAAY,GAAG,CAAC,OAAgB,EAAE,OAAe,EAAuB,EAAE,CACrF,IAAA,aAAK,EAAC,OAAO,CAAC;KACX,SAAS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/dist/matchers/index.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export * from './HttpMatchers';
|
|
2
|
-
export * from './Match';
|
|
3
|
-
export * from './Check';
|
|
4
|
-
export * from './ResultMatchers';
|
|
5
|
-
export * from './toBeArrayOf';
|
|
6
|
-
export * from './toBeArrayOfWithLength';
|
|
7
|
-
export * from './toBeAt';
|
|
8
|
-
export * from './toBeExactlyAt';
|
|
9
|
-
export * from './toFailMatcher';
|
|
10
|
-
export * from './toBeValid';
|
|
11
|
-
export * from './toMatchArray';
|
|
12
|
-
export * from './toMatchExactJson';
|
|
13
|
-
export * from './toMatchException';
|
|
14
|
-
export * from './toMatchJson';
|
|
15
|
-
export * from './toMatchRoute';
|
|
16
|
-
export * from './toMatchText';
|
|
17
|
-
export * from './toPassMatcher';
|
|
18
|
-
export * from './toBeQueriedWith';
|
|
19
|
-
export * from './toBeRoutedTo';
|
package/dist/matchers/index.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./HttpMatchers"), exports);
|
|
18
|
-
__exportStar(require("./Match"), exports);
|
|
19
|
-
__exportStar(require("./Check"), exports);
|
|
20
|
-
__exportStar(require("./ResultMatchers"), exports);
|
|
21
|
-
__exportStar(require("./toBeArrayOf"), exports);
|
|
22
|
-
__exportStar(require("./toBeArrayOfWithLength"), exports);
|
|
23
|
-
__exportStar(require("./toBeAt"), exports);
|
|
24
|
-
__exportStar(require("./toBeExactlyAt"), exports);
|
|
25
|
-
__exportStar(require("./toFailMatcher"), exports);
|
|
26
|
-
__exportStar(require("./toBeValid"), exports);
|
|
27
|
-
__exportStar(require("./toMatchArray"), exports);
|
|
28
|
-
__exportStar(require("./toMatchExactJson"), exports);
|
|
29
|
-
__exportStar(require("./toMatchException"), exports);
|
|
30
|
-
__exportStar(require("./toMatchJson"), exports);
|
|
31
|
-
__exportStar(require("./toMatchRoute"), exports);
|
|
32
|
-
__exportStar(require("./toMatchText"), exports);
|
|
33
|
-
__exportStar(require("./toPassMatcher"), exports);
|
|
34
|
-
__exportStar(require("./toBeQueriedWith"), exports);
|
|
35
|
-
__exportStar(require("./toBeRoutedTo"), exports);
|
|
36
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/matchers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,0CAAwB;AACxB,0CAAwB;AACxB,mDAAiC;AACjC,gDAA8B;AAC9B,0DAAwC;AACxC,2CAAyB;AACzB,kDAAgC;AAChC,kDAAgC;AAChC,8CAA4B;AAC5B,iDAA+B;AAC/B,qDAAmC;AACnC,qDAAmC;AACnC,gDAA8B;AAC9B,iDAA+B;AAC/B,gDAA8B;AAC9B,kDAAgC;AAChC,oDAAkC;AAClC,iDAA+B"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="jest" />
|
|
2
|
-
import CustomMatcherResult = jest.CustomMatcherResult;
|
|
3
|
-
import { Constructor as Ctor } from '../utils/Types';
|
|
4
|
-
export declare const toBeArrayOf: <T>(items: unknown, ctor: Ctor<T>) => CustomMatcherResult;
|
|
5
|
-
declare global {
|
|
6
|
-
namespace jest {
|
|
7
|
-
interface Matchers<R, T> {
|
|
8
|
-
toBeArrayOf<Z>(ctor: Ctor<Z>): R;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toBeArrayOf = void 0;
|
|
4
|
-
const Match_1 = require("./Match");
|
|
5
|
-
const toBeArrayOf = (items, ctor) => (0, Match_1.match)(items)
|
|
6
|
-
.undefined(it => it, 'Subject is undefined.')
|
|
7
|
-
.not(it => it instanceof Array, 'Subject is not an array.')
|
|
8
|
-
.not(it => it.every((i) => i instanceof ctor), `Not all elements are of type '${ctor.name}'.`)
|
|
9
|
-
.else(`All elements in array are of type '${ctor.name}'`);
|
|
10
|
-
exports.toBeArrayOf = toBeArrayOf;
|
|
11
|
-
expect.extend({
|
|
12
|
-
toBeArrayOf: exports.toBeArrayOf,
|
|
13
|
-
});
|
|
14
|
-
//# sourceMappingURL=toBeArrayOf.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"toBeArrayOf.js","sourceRoot":"","sources":["../../src/matchers/toBeArrayOf.ts"],"names":[],"mappings":";;;AAEA,mCAAgC;AAEzB,MAAM,WAAW,GAAG,CAAI,KAAc,EAAE,IAAa,EAAuB,EAAE,CACnF,IAAA,aAAK,EAAU,KAAK,CAAC;KAClB,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,uBAAuB,CAAC;KAC5C,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,YAAY,KAAK,EAAE,0BAA0B,CAAC;KAC1D,GAAG,CAAC,EAAE,CAAC,EAAE,CAAE,EAAS,CAAC,KAAK,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,YAAY,IAAI,CAAC,EAAE,iCAAiC,IAAI,CAAC,IAAI,IAAI,CAAC;KAC1G,IAAI,CAAC,sCAAsC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;AALjD,QAAA,WAAW,eAKsC;AAE9D,MAAM,CAAC,MAAM,CAAC;IACZ,WAAW,EAAX,mBAAW;CACZ,CAAC,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="jest" />
|
|
2
|
-
import CustomMatcherResult = jest.CustomMatcherResult;
|
|
3
|
-
import { Constructor as Ctor } from '../utils/Types';
|
|
4
|
-
export declare const toBeArrayOfWithLength: <T>(items: unknown, ctor: Ctor<T>, length: number) => CustomMatcherResult;
|
|
5
|
-
declare global {
|
|
6
|
-
namespace jest {
|
|
7
|
-
interface Matchers<R, T> {
|
|
8
|
-
toBeArrayOfWithLength<Z>(ctor: Ctor<Z>, length: number): R;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|