@tramvai/test-mocks 5.49.1 → 5.53.74

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/lib/context.es.js CHANGED
@@ -1,10 +1,13 @@
1
- import { STORE_TOKEN, ACTION_EXECUTION_TOKEN, ACTION_CONDITIONALS, EXECUTION_CONTEXT_MANAGER_TOKEN, DEFERRED_ACTIONS_MAP_TOKEN, CONTEXT_TOKEN } from '@tramvai/tokens-common';
1
+ import { STORE_TOKEN, ACTION_EXECUTION_HOOKS_TOKEN, ACTION_EXECUTION_TOKEN, ACTION_CONDITIONALS, EXECUTION_CONTEXT_MANAGER_TOKEN, DEFERRED_ACTIONS_MAP_TOKEN, CONTEXT_TOKEN } from '@tramvai/tokens-common';
2
+ import { TAPABLE_HOOK_FACTORY_TOKEN } from '@tramvai/tokens-core';
3
+ import { TapableHooks } from '@tinkoff/hook-runner';
2
4
  import { alwaysCondition, onlyServer, onlyBrowser, pageServer, pageBrowser, ExecutionContextManager, ActionExecution, createConsumerContext } from '@tramvai/module-common';
3
5
  import { PubSub } from '@tinkoff/pubsub';
4
6
  import { DI_TOKEN } from '@tinkoff/dippy';
5
7
  import { createMockStore } from './store.es.js';
6
8
  import { createMockDi } from './di.es.js';
7
9
 
10
+ new TapableHooks();
8
11
  /**
9
12
  * Создаёт мок для consumerContext
10
13
  *
@@ -23,6 +26,20 @@ const createMockContext = ({ stores, initialState, store = createMockStore({ sto
23
26
  provide: STORE_TOKEN,
24
27
  useValue: store,
25
28
  });
29
+ di.register({
30
+ provide: TAPABLE_HOOK_FACTORY_TOKEN,
31
+ useClass: TapableHooks,
32
+ });
33
+ di.register({
34
+ provide: ACTION_EXECUTION_HOOKS_TOKEN,
35
+ useFactory: ({ hookFactory }) => ({
36
+ startExecution: hookFactory.createSync('startActionExecution'),
37
+ endExecution: hookFactory.createSync('endActionExecution'),
38
+ }),
39
+ deps: {
40
+ hookFactory: TAPABLE_HOOK_FACTORY_TOKEN,
41
+ },
42
+ });
26
43
  if (!di.get({ token: ACTION_EXECUTION_TOKEN, optional: true })) {
27
44
  if (useTramvaiActionsConditionals) {
28
45
  di.register({
@@ -41,12 +58,14 @@ const createMockContext = ({ stores, initialState, store = createMockStore({ sto
41
58
  });
42
59
  di.register({
43
60
  provide: ACTION_EXECUTION_TOKEN,
61
+ // @ts-ignore
44
62
  useClass: ActionExecution,
45
63
  deps: {
46
64
  actionConditionals: { token: ACTION_CONDITIONALS, optional: true },
47
65
  context: CONTEXT_TOKEN,
48
66
  store: STORE_TOKEN,
49
67
  di: DI_TOKEN,
68
+ hooks: ACTION_EXECUTION_HOOKS_TOKEN,
50
69
  transformAction: {
51
70
  token: 'actionTransformAction',
52
71
  optional: true,
package/lib/context.js CHANGED
@@ -3,12 +3,15 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var tokensCommon = require('@tramvai/tokens-common');
6
+ var tokensCore = require('@tramvai/tokens-core');
7
+ var hookRunner = require('@tinkoff/hook-runner');
6
8
  var moduleCommon = require('@tramvai/module-common');
7
9
  var pubsub = require('@tinkoff/pubsub');
8
10
  var dippy = require('@tinkoff/dippy');
9
11
  var store = require('./store.js');
10
12
  var di = require('./di.js');
11
13
 
14
+ new hookRunner.TapableHooks();
12
15
  /**
13
16
  * Создаёт мок для consumerContext
14
17
  *
@@ -27,6 +30,20 @@ const createMockContext = ({ stores, initialState, store: store$1 = store.create
27
30
  provide: tokensCommon.STORE_TOKEN,
28
31
  useValue: store$1,
29
32
  });
33
+ di$1.register({
34
+ provide: tokensCore.TAPABLE_HOOK_FACTORY_TOKEN,
35
+ useClass: hookRunner.TapableHooks,
36
+ });
37
+ di$1.register({
38
+ provide: tokensCommon.ACTION_EXECUTION_HOOKS_TOKEN,
39
+ useFactory: ({ hookFactory }) => ({
40
+ startExecution: hookFactory.createSync('startActionExecution'),
41
+ endExecution: hookFactory.createSync('endActionExecution'),
42
+ }),
43
+ deps: {
44
+ hookFactory: tokensCore.TAPABLE_HOOK_FACTORY_TOKEN,
45
+ },
46
+ });
30
47
  if (!di$1.get({ token: tokensCommon.ACTION_EXECUTION_TOKEN, optional: true })) {
31
48
  if (useTramvaiActionsConditionals) {
32
49
  di$1.register({
@@ -45,12 +62,14 @@ const createMockContext = ({ stores, initialState, store: store$1 = store.create
45
62
  });
46
63
  di$1.register({
47
64
  provide: tokensCommon.ACTION_EXECUTION_TOKEN,
65
+ // @ts-ignore
48
66
  useClass: moduleCommon.ActionExecution,
49
67
  deps: {
50
68
  actionConditionals: { token: tokensCommon.ACTION_CONDITIONALS, optional: true },
51
69
  context: tokensCommon.CONTEXT_TOKEN,
52
70
  store: tokensCommon.STORE_TOKEN,
53
71
  di: dippy.DI_TOKEN,
72
+ hooks: tokensCommon.ACTION_EXECUTION_HOOKS_TOKEN,
54
73
  transformAction: {
55
74
  token: 'actionTransformAction',
56
75
  optional: true,
package/lib/router.es.js CHANGED
@@ -16,13 +16,10 @@ const createMockRouter = ({ currentRoute = { name: 'root', path: '/' }, currentU
16
16
  let url = currentUrl;
17
17
  let blocked = false;
18
18
  return new (class extends AbstractRouter {
19
- constructor() {
20
- super(...arguments);
21
- this.onRedirect = async (navigation) => {
22
- this.commitNavigation(navigation);
23
- blocked = true;
24
- };
25
- }
19
+ onRedirect = async (navigation) => {
20
+ this.commitNavigation(navigation);
21
+ blocked = true;
22
+ };
26
23
  getCurrentRoute() {
27
24
  return route;
28
25
  }
package/lib/router.js CHANGED
@@ -20,13 +20,10 @@ const createMockRouter = ({ currentRoute = { name: 'root', path: '/' }, currentU
20
20
  let url = currentUrl;
21
21
  let blocked = false;
22
22
  return new (class extends router.AbstractRouter {
23
- constructor() {
24
- super(...arguments);
25
- this.onRedirect = async (navigation) => {
26
- this.commitNavigation(navigation);
27
- blocked = true;
28
- };
29
- }
23
+ onRedirect = async (navigation) => {
24
+ this.commitNavigation(navigation);
25
+ blocked = true;
26
+ };
30
27
  getCurrentRoute() {
31
28
  return route;
32
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/test-mocks",
3
- "version": "5.49.1",
3
+ "version": "5.53.74",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -17,21 +17,22 @@
17
17
  "watch": "tsc -w"
18
18
  },
19
19
  "dependencies": {
20
- "@tramvai/core": "5.49.1",
20
+ "@tinkoff/hook-runner": "0.7.4",
21
21
  "@tinkoff/pubsub": "0.8.2",
22
- "@tinkoff/router": "0.5.115",
23
- "@tinkoff/url": "0.11.2",
24
- "@tramvai/module-cookie": "5.49.1",
25
- "@tramvai/module-common": "5.49.1",
26
- "@tramvai/state": "5.49.1",
27
- "@tramvai/tokens-common": "5.49.1"
22
+ "@tinkoff/router": "0.5.198",
23
+ "@tinkoff/url": "0.11.3",
24
+ "@tramvai/core": "5.53.74",
25
+ "@tramvai/module-common": "5.53.74",
26
+ "@tramvai/module-cookie": "5.53.74",
27
+ "@tramvai/state": "5.53.74",
28
+ "@tramvai/tokens-common": "5.53.74",
29
+ "@tramvai/tokens-core": "5.53.74"
28
30
  },
29
31
  "peerDependencies": {
30
- "@tinkoff/dippy": "0.11.4",
32
+ "@tinkoff/dippy": "0.11.5",
31
33
  "@tinkoff/utils": "^2.1.2",
32
34
  "tslib": "^2.4.0"
33
35
  },
34
- "devDependencies": {},
35
36
  "license": "Apache-2.0",
36
37
  "module": "lib/index.es.js"
37
38
  }