@thisisagile/easy-test 8.41.12 → 8.42.0

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.
@@ -4,6 +4,7 @@ export * from './ResultMatchers';
4
4
  export * from './toBeArrayOf';
5
5
  export * from './toBeArrayOfWithLength';
6
6
  export * from './toBeAt';
7
+ export * from './toBeExactlyAt';
7
8
  export * from './toFailMatcher';
8
9
  export * from './toBeValid';
9
10
  export * from './toMatchExactJson';
@@ -16,6 +16,7 @@ __exportStar(require("./ResultMatchers"), exports);
16
16
  __exportStar(require("./toBeArrayOf"), exports);
17
17
  __exportStar(require("./toBeArrayOfWithLength"), exports);
18
18
  __exportStar(require("./toBeAt"), exports);
19
+ __exportStar(require("./toBeExactlyAt"), exports);
19
20
  __exportStar(require("./toFailMatcher"), exports);
20
21
  __exportStar(require("./toBeValid"), exports);
21
22
  __exportStar(require("./toMatchExactJson"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/matchers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAA+B;AAC/B,0CAAwB;AACxB,mDAAiC;AACjC,gDAA8B;AAC9B,0DAAwC;AACxC,2CAAyB;AACzB,kDAAgC;AAChC,8CAA4B;AAC5B,qDAAmC;AACnC,qDAAmC;AACnC,gDAA8B;AAC9B,iDAA+B;AAC/B,gDAA8B;AAC9B,kDAAgC;AAChC,oDAAkC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/matchers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAA+B;AAC/B,0CAAwB;AACxB,mDAAiC;AACjC,gDAA8B;AAC9B,0DAAwC;AACxC,2CAAyB;AACzB,kDAAgC;AAChC,kDAAgC;AAChC,8CAA4B;AAC5B,qDAAmC;AACnC,qDAAmC;AACnC,gDAA8B;AAC9B,iDAA+B;AAC/B,gDAA8B;AAC9B,kDAAgC;AAChC,oDAAkC"}
@@ -1,18 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toBeAt = void 0;
4
- const Utils_1 = require("../utils/Utils");
5
4
  const Match_1 = require("./Match");
6
- const toUrl = (uc, id) => {
7
- const i = (0, Utils_1.isDefined)(id) ? `/${id}` : '';
8
- return `/${uc.app.id}/${uc.id}${i}`;
9
- };
10
5
  const toBeAt = (tester, uc, id) => {
11
6
  return (0, Match_1.match)(tester)
12
7
  .undefined(t => t, 'Tester is undefined')
13
8
  .undefined(t => t.url, 'Tester does not contain a URL')
14
9
  .undefined(() => uc, 'Use case is undefined')
15
- .not(t => t.url.includes(toUrl(uc, id)), t => `We expected the tester to be at: '${toUrl(uc, id)}', but it is at: '${t?.url}' instead.`)
10
+ .not(t => t.url.includes(`/${uc?.app.id}`), t => `We expected the tester to be at app '${uc?.app.id}', but it is at '${t?.url}' instead.`)
11
+ .not(t => t.url.includes(`/${uc?.id}`), t => `We expected the tester to be at use case '${uc?.id}', but it is at '${t?.url}' instead.`)
12
+ .not(t => t.url.includes(id ? `/${id}` : ''), t => `We expected the path to contain '/42', but it is '${t?.url}' instead.`)
16
13
  .else(t => `The tester is at '${t?.url}'`);
17
14
  };
18
15
  exports.toBeAt = toBeAt;
@@ -1 +1 @@
1
- {"version":3,"file":"toBeAt.js","sourceRoot":"","sources":["../../src/matchers/toBeAt.ts"],"names":[],"mappings":";;;AAEA,0CAA2C;AAC3C,mCAAgC;AAEhC,MAAM,KAAK,GAAG,CAAC,EAAW,EAAE,EAAO,EAAU,EAAE;IAC7C,MAAM,CAAC,GAAG,IAAA,iBAAS,EAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACxC,OAAO,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;AACtC,CAAC,CAAC;AAEK,MAAM,MAAM,GAAG,CAAC,M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,CAAC,IAAI,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,EACrC,CAAC,CAAC,EAAE,CAAC,wCAAwC,EAAE,EAAE,GAAG,CAAC,EAAE,oBAAoB,CAAC,EAAE,GAAG,YAAY,CAC9F;SACA,GAAG,CACF,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,EACjC,CAAC,CAAC,EAAE,CAAC,6CAA6C,EAAE,EAAE,EAAE,oBAAoB,CAAC,EAAE,GAAG,YAAY,CAC/F;SACA,GAAG,CACF,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EACvC,CAAC,CAAC,EAAE,CAAC,qDAAqD,CAAC,EAAE,GAAG,YAAY,CAC7E;SACA,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,qBAAqB,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC;AAC/C,CAAC,CAAC;AAlBW,QAAA,MAAM,UAkBjB;AAEF,MAAM,CAAC,MAAM,CAAC;IACZ,MAAM,EAAN,cAAM;CACP,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ /// <reference types="jest" />
2
+ import CustomMatcherResult = jest.CustomMatcherResult;
3
+ import { Id, Tester, UseCase } from '../utils/Types';
4
+ export declare const toBeExactlyAt: (tester?: Tester | undefined, uc?: UseCase | undefined, id?: Id | undefined) => CustomMatcherResult;
5
+ declare global {
6
+ namespace jest {
7
+ interface Matchers<R, T> {
8
+ toBeExactlyAt(uc?: UseCase, id?: Id): R;
9
+ }
10
+ }
11
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toBeExactlyAt = void 0;
4
+ const Utils_1 = require("../utils/Utils");
5
+ const Match_1 = require("./Match");
6
+ const toUrl = (uc, id) => {
7
+ const i = (0, Utils_1.isDefined)(id) ? `/${id}` : '';
8
+ return `/${uc.app.id}/${uc.id}${i}`;
9
+ };
10
+ const toBeExactlyAt = (tester, uc, id) => {
11
+ return (0, Match_1.match)(tester)
12
+ .undefined(t => t, 'Tester is undefined')
13
+ .undefined(t => t.url, 'Tester does not contain a URL')
14
+ .undefined(() => uc, 'Use case is undefined')
15
+ .not(t => t.url.includes(toUrl(uc, id)), t => `We expected the tester to be at: '${toUrl(uc, id)}', but it is at: '${t?.url}' instead.`)
16
+ .else(t => `The tester is at '${t?.url}'`);
17
+ };
18
+ exports.toBeExactlyAt = toBeExactlyAt;
19
+ expect.extend({
20
+ toBeExactlyAt: exports.toBeExactlyAt,
21
+ });
22
+ //# sourceMappingURL=toBeExactlyAt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toBeExactlyAt.js","sourceRoot":"","sources":["../../src/matchers/toBeExactlyAt.ts"],"names":[],"mappings":";;;AAEA,0CAA2C;AAC3C,mCAAgC;AAEhC,MAAM,KAAK,GAAG,CAAC,EAAW,EAAE,EAAO,EAAU,EAAE;IAC7C,MAAM,CAAC,GAAG,IAAA,iBAAS,EAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACxC,OAAO,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;AACtC,CAAC,CAAC;AAEK,MAAM,aAAa,GAAG,CAAC,MAAe,EAAE,EAAY,EAAE,EAAO,EAAuB,EAAE;IAC3F,OAAO,IAAA,aAAK,EAAS,MAAgB,CAAC;SACnC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,qBAAqB,CAAC;SACxC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,+BAA+B,CAAC;SACtD,SAAS,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,uBAAuB,CAAC;SAC5C,GAAG,CACF,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAa,EAAE,EAAE,CAAC,CAAC,EAC7C,CAAC,CAAC,EAAE,CAAC,qCAAqC,KAAK,CAAC,EAAa,EAAE,EAAE,CAAC,qBAAqB,CAAC,EAAE,GAAG,YAAY,CAC1G;SACA,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,qBAAqB,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC;AAC/C,CAAC,CAAC;AAVW,QAAA,aAAa,iBAUxB;AAEF,MAAM,CAAC,MAAM,CAAC;IACZ,aAAa,EAAb,qBAAa;CACd,CAAC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  export declare type Constructor<T> = {
2
2
  new (...args: any[]): T;
3
3
  };
4
- export declare type Message<P extends unknown> = Text | ((...params: P[]) => Text);
4
+ export declare type Message<P> = Text | ((...params: P[]) => Text);
5
5
  export declare const toMessage: <P>(g: Message<P>, ...params: P[]) => string;
6
6
  export declare type Validatable = {
7
7
  isValid: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thisisagile/easy-test",
3
- "version": "8.41.12",
3
+ "version": "8.42.0",
4
4
  "description": "Straightforward library for testing microservices built with @thisisagile/easy",
5
5
  "author": "Sander Hoogendoorn",
6
6
  "license": "MIT",
@@ -4,6 +4,7 @@ export * from './ResultMatchers';
4
4
  export * from './toBeArrayOf';
5
5
  export * from './toBeArrayOfWithLength';
6
6
  export * from './toBeAt';
7
+ export * from './toBeExactlyAt';
7
8
  export * from './toFailMatcher';
8
9
  export * from './toBeValid';
9
10
  export * from './toMatchExactJson';
@@ -1,21 +1,23 @@
1
1
  import CustomMatcherResult = jest.CustomMatcherResult;
2
2
  import { Id, Tester, UseCase } from '../utils/Types';
3
- import { isDefined } from '../utils/Utils';
4
3
  import { match } from './Match';
5
4
 
6
- const toUrl = (uc: UseCase, id?: Id): string => {
7
- const i = isDefined(id) ? `/${id}` : '';
8
- return `/${uc.app.id}/${uc.id}${i}`;
9
- };
10
-
11
5
  export const toBeAt = (tester?: Tester, uc?: UseCase, id?: Id): CustomMatcherResult => {
12
6
  return match<Tester>(tester as Tester)
13
7
  .undefined(t => t, 'Tester is undefined')
14
8
  .undefined(t => t.url, 'Tester does not contain a URL')
15
9
  .undefined(() => uc, 'Use case is undefined')
16
10
  .not(
17
- t => t.url.includes(toUrl(uc as UseCase, id)),
18
- t => `We expected the tester to be at: '${toUrl(uc as UseCase, id)}', but it is at: '${t?.url}' instead.`
11
+ t => t.url.includes(`/${uc?.app.id}`),
12
+ t => `We expected the tester to be at app '${uc?.app.id}', but it is at '${t?.url}' instead.`,
13
+ )
14
+ .not(
15
+ t => t.url.includes(`/${uc?.id}`),
16
+ t => `We expected the tester to be at use case '${uc?.id}', but it is at '${t?.url}' instead.`,
17
+ )
18
+ .not(
19
+ t => t.url.includes(id ? `/${id}` : ''),
20
+ t => `We expected the path to contain '/42', but it is '${t?.url}' instead.`,
19
21
  )
20
22
  .else(t => `The tester is at '${t?.url}'`);
21
23
  };
@@ -0,0 +1,34 @@
1
+ import CustomMatcherResult = jest.CustomMatcherResult;
2
+ import { Id, Tester, UseCase } from '../utils/Types';
3
+ import { isDefined } from '../utils/Utils';
4
+ import { match } from './Match';
5
+
6
+ const toUrl = (uc: UseCase, id?: Id): string => {
7
+ const i = isDefined(id) ? `/${id}` : '';
8
+ return `/${uc.app.id}/${uc.id}${i}`;
9
+ };
10
+
11
+ export const toBeExactlyAt = (tester?: Tester, uc?: UseCase, id?: Id): CustomMatcherResult => {
12
+ return match<Tester>(tester as Tester)
13
+ .undefined(t => t, 'Tester is undefined')
14
+ .undefined(t => t.url, 'Tester does not contain a URL')
15
+ .undefined(() => uc, 'Use case is undefined')
16
+ .not(
17
+ t => t.url.includes(toUrl(uc as UseCase, id)),
18
+ t => `We expected the tester to be at: '${toUrl(uc as UseCase, id)}', but it is at: '${t?.url}' instead.`
19
+ )
20
+ .else(t => `The tester is at '${t?.url}'`);
21
+ };
22
+
23
+ expect.extend({
24
+ toBeExactlyAt,
25
+ });
26
+
27
+ declare global {
28
+ // eslint-disable-next-line @typescript-eslint/no-namespace
29
+ namespace jest {
30
+ interface Matchers<R, T> {
31
+ toBeExactlyAt(uc?: UseCase, id?: Id): R;
32
+ }
33
+ }
34
+ }
@@ -2,7 +2,7 @@ import { asString, isFunction } from './Utils';
2
2
 
3
3
  export type Constructor<T> = { new (...args: any[]): T };
4
4
 
5
- export type Message<P extends unknown> = Text | ((...params: P[]) => Text);
5
+ export type Message<P> = Text | ((...params: P[]) => Text);
6
6
 
7
7
  export const toMessage = <P>(g: Message<P>, ...params: P[]): string => asString(isFunction(g) ? g(...params) : g);
8
8