• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

digaev / interactor-js / 6656e8ee-9903-4023-ba76-c2dc6937abc6

24 Jun 2024 03:55PM UTC coverage: 99.074%. Remained the same
6656e8ee-9903-4023-ba76-c2dc6937abc6

push

circleci

web-flow
Update README.md

23 of 24 branches covered (95.83%)

Branch coverage included in aggregate %.

84 of 84 relevant lines covered (100.0%)

4.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/lib/interactor-factory.ts
1
/* eslint-disable prefer-arrow-callback */
2
/* eslint-disable max-classes-per-file */
3

4
import Interactor from './interactor';
1✔
5
import SafeInteractor from './safe-interactor';
1✔
6

7
export type AfterFunction = (this: Interactor) => Promise<any>;
8
export type BeforeFunction = (this: Interactor) => Promise<any>;
9
export type PerformFunction = (this: Interactor) => Promise<any>;
10
export type RollbackFunction = (this: Interactor) => Promise<any>;
11

12
export function createInteractor(perform: PerformFunction, rollback?: RollbackFunction, before?: BeforeFunction, after?: AfterFunction): typeof Interactor {
1✔
13
  const RuntimeInteractor = class extends Interactor {
2✔
14
    public after(): Promise<any> {
15
      if (after) {
2✔
16
        return after.call(this);
1✔
17
      }
18
      return super.after();
1✔
19
    }
20

21
    public before(): Promise<any> {
22
      if (before) {
2✔
23
        return before.call(this);
1✔
24
      }
25
      return super.before();
1✔
26
    }
27

28
    public perform(): Promise<any> {
29
      return perform.call(this);
2✔
30
    }
31

32
    public rollback(): Promise<any> {
33
      if (rollback) {
2✔
34
        return rollback.call(this);
1✔
35
      }
36
      return super.rollback();
1✔
37
    }
38
  };
39

40
  return RuntimeInteractor;
2✔
41
}
42

43
export function createSafeInteractor(perform: PerformFunction, rollback?: RollbackFunction, before?: BeforeFunction, after?: AfterFunction): typeof Interactor {
1✔
44
  const RuntimeSafeInteractor = class extends SafeInteractor {
2✔
45
    public after(): Promise<any> {
46
      if (after) {
2✔
47
        return after.call(this);
1✔
48
      }
49
      return super.after();
1✔
50
    }
51

52
    public before(): Promise<any> {
53
      if (before) {
2✔
54
        return before.call(this);
1✔
55
      }
56
      return super.before();
1✔
57
    }
58

59
    public perform(): Promise<any> {
60
      return perform.call(this);
2✔
61
    }
62

63
    public rollback(): Promise<any> {
64
      if (rollback) {
2✔
65
        return rollback.call(this);
1✔
66
      }
67
      return super.rollback();
1✔
68
    }
69
  };
70

71
  return RuntimeSafeInteractor;
2✔
72
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc