@tramvai/test-unit 2.28.0 → 2.29.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.
package/README.md CHANGED
@@ -39,14 +39,18 @@ it('test', async () => {
39
39
 
40
40
  ### Testing actions
41
41
 
42
+ Tramvai context and DI will be created automatically, otherwise you can directly pass it as an argument.
43
+
42
44
  ```ts
43
45
  import { testAction } from '@tramvai/test-unit';
44
46
 
45
47
  it('test', async () => {
46
- const { run } = testAction(action);
48
+ const { run, context } = testAction(action, { initialState: { a: 1 } });
47
49
 
48
50
  expect(await run(true)).toBe('hello');
49
51
  expect(await run(false)).toBe('world');
52
+
53
+ context.getState(); // { a: 1 }
50
54
  });
51
55
  ```
52
56
 
package/lib/index.es.js CHANGED
@@ -15,7 +15,7 @@ import { MetricsModule as MetricsModule$1 } from '@tramvai/module-metrics';
15
15
  import { SERVER_TOKEN as SERVER_TOKEN$1 } from '@tramvai/tokens-server';
16
16
  import { WEB_FASTIFY_APP_TOKEN } from '@tramvai/tokens-server-private';
17
17
 
18
- function testAction(action, { initialState, providers, di, store, stores, context = createMockContext({ initialState, di, providers, store, stores }), } = {}) {
18
+ function testAction(action, { initialState, providers, modules, di, store, stores, context = createMockContext({ initialState, di, providers, modules, store, stores }), } = {}) {
19
19
  return {
20
20
  /**
21
21
  * @description
@@ -26,6 +26,7 @@ function testAction(action, { initialState, providers, di, store, stores, contex
26
26
  run: (payload) => {
27
27
  return context.executeAction(action, payload);
28
28
  },
29
+ context,
29
30
  };
30
31
  }
31
32
 
package/lib/index.js CHANGED
@@ -24,7 +24,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
24
24
  var mapObj__default = /*#__PURE__*/_interopDefaultLegacy(mapObj);
25
25
  var values__default = /*#__PURE__*/_interopDefaultLegacy(values);
26
26
 
27
- function testAction(action, { initialState, providers, di, store, stores, context = testMocks.createMockContext({ initialState, di, providers, store, stores }), } = {}) {
27
+ function testAction(action, { initialState, providers, modules, di, store, stores, context = testMocks.createMockContext({ initialState, di, providers, modules, store, stores }), } = {}) {
28
28
  return {
29
29
  /**
30
30
  * @description
@@ -35,6 +35,7 @@ function testAction(action, { initialState, providers, di, store, stores, contex
35
35
  run: (payload) => {
36
36
  return context.executeAction(action, payload);
37
37
  },
38
+ context,
38
39
  };
39
40
  }
40
41
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/test-unit",
3
- "version": "2.28.0",
3
+ "version": "2.29.0",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -18,21 +18,21 @@
18
18
  "build-for-publish": "true"
19
19
  },
20
20
  "dependencies": {
21
- "@tramvai/cli": "2.28.0",
22
- "@tramvai/core": "2.28.0",
23
- "@tramvai/module-common": "2.28.0",
24
- "@tramvai/module-log": "2.28.0",
25
- "@tramvai/module-metrics": "2.28.0",
26
- "@tramvai/module-mocker": "2.28.0",
27
- "@tramvai/module-render": "2.28.0",
28
- "@tramvai/module-router": "2.28.0",
29
- "@tramvai/module-server": "2.28.0",
30
- "@tramvai/state": "2.28.0",
31
- "@tramvai/test-helpers": "2.28.0",
32
- "@tramvai/test-mocks": "2.28.0",
33
- "@tramvai/tokens-common": "2.28.0",
34
- "@tramvai/tokens-server": "2.28.0",
35
- "@tramvai/tokens-server-private": "2.28.0",
21
+ "@tramvai/cli": "2.29.0",
22
+ "@tramvai/core": "2.29.0",
23
+ "@tramvai/module-common": "2.29.0",
24
+ "@tramvai/module-log": "2.29.0",
25
+ "@tramvai/module-metrics": "2.29.0",
26
+ "@tramvai/module-mocker": "2.29.0",
27
+ "@tramvai/module-render": "2.29.0",
28
+ "@tramvai/module-router": "2.29.0",
29
+ "@tramvai/module-server": "2.29.0",
30
+ "@tramvai/state": "2.29.0",
31
+ "@tramvai/test-helpers": "2.29.0",
32
+ "@tramvai/test-mocks": "2.29.0",
33
+ "@tramvai/tokens-common": "2.29.0",
34
+ "@tramvai/tokens-server": "2.29.0",
35
+ "@tramvai/tokens-server-private": "2.29.0",
36
36
  "utility-types": "^3.10.0"
37
37
  },
38
38
  "peerDependencies": {