strong-mock 8.0.0-beta.1 → 8.0.0-beta.2

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.
@@ -1,5 +1,5 @@
1
- import { ExpectationRepository } from '../expectation/repository/expectation-repository';
2
- import { Mock } from '../mock/mock';
1
+ import type { ExpectationRepository } from '../expectation/repository/expectation-repository';
2
+ import type { Mock } from '../mock/mock';
3
3
  export declare const verifyRepo: (repository: ExpectationRepository) => void;
4
4
  /**
5
5
  * Verify that all expectations on the given mock have been met.
@@ -1,30 +1,31 @@
1
- import { Expectation, ReturnValue } from '../expectation/expectation';
2
- import { ExpectationRepository } from '../expectation/repository/expectation-repository';
3
- import { ConcreteMatcher } from '../mock/options';
4
- import { Property } from '../proxy';
5
- export declare type ExpectationFactory = (property: Property, args: any[] | undefined, returnValue: ReturnValue, concreteMatcher: ConcreteMatcher) => Expectation;
1
+ import type { Expectation } from '../expectation/expectation';
2
+ import type { ReturnValue } from '../expectation/repository/return-value';
3
+ import type { ConcreteMatcher } from '../mock/options';
4
+ import type { Property } from '../proxy';
5
+ /**
6
+ * An expectation has to be built incrementally, starting first with the property
7
+ * being accessed inside {@link createStub}, then any arguments passed to it, and ending
8
+ * it with the returned value from {@link createReturns}.
9
+ */
6
10
  export interface PendingExpectation {
7
- start(repo: ExpectationRepository, concreteMatcher: ConcreteMatcher): void;
11
+ setProperty(prop: Property): void;
12
+ setArgs(args: any[] | undefined): void;
8
13
  finish(returnValue: ReturnValue): Expectation;
9
- clear(): void;
10
- property: Property;
11
- args: any[] | undefined;
12
14
  /**
13
15
  * Used by `pretty-format`.
14
16
  */
15
17
  toJSON(): string;
16
18
  }
17
- export declare class RepoSideEffectPendingExpectation implements PendingExpectation {
19
+ export declare type ExpectationFactory = (property: Property, args: any[] | undefined, returnValue: ReturnValue, concreteMatcher: ConcreteMatcher, exactParams: boolean) => Expectation;
20
+ export declare class PendingExpectationWithFactory implements PendingExpectation {
18
21
  private createExpectation;
19
- private _repo;
20
- private _concreteMatcher;
21
- private _args;
22
- private _property;
23
- constructor(createExpectation: ExpectationFactory);
24
- start(repo: ExpectationRepository, concreteMatcher: ConcreteMatcher): void;
25
- set property(value: Property);
26
- set args(value: any[] | undefined);
22
+ private concreteMatcher;
23
+ private exactParams;
24
+ private args;
25
+ private property;
26
+ constructor(createExpectation: ExpectationFactory, concreteMatcher: ConcreteMatcher, exactParams: boolean);
27
+ setProperty(value: Property): void;
28
+ setArgs(value: any[] | undefined): void;
27
29
  finish(returnValue: ReturnValue): Expectation;
28
- clear(): void;
29
30
  toJSON(): string;
30
31
  }
@@ -1,4 +1,8 @@
1
- import { Stub } from '../return/returns';
1
+ import type { NonPromiseStub, PromiseStub } from '../return/returns';
2
+ interface When {
3
+ <R>(expectation: () => Promise<R>): PromiseStub<R, Promise<R>>;
4
+ <R>(expectation: () => R): NonPromiseStub<R>;
5
+ }
2
6
  /**
3
7
  * Set an expectation on a mock.
4
8
  *
@@ -24,4 +28,5 @@ import { Stub } from '../return/returns';
24
28
  * const fn = mock<(x: number) => Promise<number>();
25
29
  * when(() => fn(23)).thenResolve(42);
26
30
  */
27
- export declare const when: <R>(expectation: () => R) => Stub<R>;
31
+ export declare const when: When;
32
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strong-mock",
3
- "version": "8.0.0-beta.1",
3
+ "version": "8.0.0-beta.2",
4
4
  "description": "Simple type safe mocking library",
5
5
  "keywords": [
6
6
  "tdd",
@@ -21,7 +21,7 @@
21
21
  "dist"
22
22
  ],
23
23
  "dependencies": {
24
- "jest-matcher-utils": "~27.5.0",
24
+ "jest-matcher-utils": "~28.1.0",
25
25
  "lodash": "~4.17.0"
26
26
  },
27
27
  "devDependencies": {
@@ -32,14 +32,14 @@
32
32
  "@types/node": "~17.0.8",
33
33
  "@types/lodash": "~4.14.0",
34
34
  "doctoc": "~2.2.0",
35
- "eslint": "~8.20.0",
35
+ "eslint": "~8.24.0",
36
36
  "jest": "~28.1.3",
37
37
  "microbundle": "~0.15.0",
38
38
  "standard-version": "~9.5.0",
39
39
  "strip-ansi": "~6.0.0",
40
40
  "strong-mock": "~6.0.0",
41
41
  "tslib": "~2.4.0",
42
- "typescript": "~4.7.0"
42
+ "typescript": "~4.8.0"
43
43
  },
44
44
  "scripts": {
45
45
  "docs": "doctoc --title '**Table of Contents**' README.md",