aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/utils/FeatureStore.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/features/utils/FeatureStore.test.js')
-rw-r--r--src/features/utils/FeatureStore.test.js93
1 files changed, 0 insertions, 93 deletions
diff --git a/src/features/utils/FeatureStore.test.js b/src/features/utils/FeatureStore.test.js
deleted file mode 100644
index 1995431bd..000000000
--- a/src/features/utils/FeatureStore.test.js
+++ /dev/null
@@ -1,93 +0,0 @@
1import PropTypes from 'prop-types';
2import { observable } from 'mobx';
3import { FeatureStore } from './FeatureStore';
4import { createActionsFromDefinitions } from '../../actions/lib/actions';
5import { createActionBindings } from './ActionBinding';
6import { createReactions } from '../../stores/lib/Reaction';
7
8const actions = createActionsFromDefinitions(
9 {
10 countUp: {},
11 },
12 PropTypes.checkPropTypes,
13);
14
15class TestFeatureStore extends FeatureStore {
16 @observable count = 0;
17
18 reactionInvokedCount = 0;
19
20 start() {
21 this._registerActions(
22 createActionBindings([[actions.countUp, this._countUp]]),
23 );
24 this._registerReactions(createReactions([this._countReaction]));
25 }
26
27 _countUp = () => {
28 this.count += 1;
29 };
30
31 _countReaction = () => {
32 this.reactionInvokedCount += 1;
33 };
34}
35
36describe('FeatureStore', () => {
37 let store = null;
38
39 beforeEach(() => {
40 store = new TestFeatureStore();
41 });
42
43 describe('registering actions', () => {
44 it('starts the actions', () => {
45 store.start();
46 actions.countUp();
47 expect(store.count).toBe(1);
48 });
49 it('starts the reactions', () => {
50 store.start();
51 actions.countUp();
52 expect(store.reactionInvokedCount).toBe(1);
53 });
54 });
55
56 describe('stopping the store', () => {
57 it('stops the actions', () => {
58 store.start();
59 actions.countUp();
60 store.stop();
61 actions.countUp();
62 expect(store.count).toBe(1);
63 });
64 it('stops the reactions', () => {
65 store.start();
66 actions.countUp();
67 store.stop();
68 store.count += 1;
69 expect(store.reactionInvokedCount).toBe(1);
70 });
71 });
72
73 describe('toggling the store', () => {
74 it('restarts the actions correctly', () => {
75 store.start();
76 actions.countUp();
77 store.stop();
78 actions.countUp();
79 store.start();
80 actions.countUp();
81 expect(store.count).toBe(2);
82 });
83 it('restarts the reactions correctly', () => {
84 store.start();
85 actions.countUp();
86 store.stop();
87 actions.countUp();
88 store.start();
89 actions.countUp();
90 expect(store.count).toBe(2);
91 });
92 });
93});