summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/storeUtil/utils/cr/cr.reducer.spec.ts
blob: e457cf9dc23a21481f8072e0bc5fc05d67186042 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import {ServiceInstanceActions} from "../../../models/serviceInstanceActions";
import { crReducer} from "./cr.reducer";
import {ActionOnFirstLevel} from "../firstLevel/firstLevel.actions";
import {CrActions} from "./cr.actions";
describe('crReducer', () => {

  test('#DELETE_ACTION_CR_INSTANCE', () => {
    let crState = crReducer(<any>{
        serviceInstance: {
          'serviceModelId': {
            collectionResources: {
              'crStoreKey': {
                isMissingData: true,
                action: 'None'
              }
            }
          }
        }
      },
      <ActionOnFirstLevel>{
        type: CrActions.DELETE_ACTION_CR_INSTANCE,
        storeKey: 'crStoreKey',
        firstLevelName: 'collectionResources',
        serviceId: 'serviceModelId'
      }).serviceInstance['serviceModelId']['collectionResources']['crStoreKey'];

    expect(crState).toBeDefined();
    expect(crState.action).toEqual(ServiceInstanceActions.None_Delete);
  });

  test('#UNDO_DELETE_ACTION_CR_INSTANCE', () => {
    let crState = crReducer(<any>{
        serviceInstance: {
          'serviceModelId': {
            collectionResources: {
              'crStoreKey': {
                isMissingData: true,
                action: 'Update_Delete'
              }
            }
          }
        }
      },
      <ActionOnFirstLevel>{
        type: CrActions.UNDO_DELETE_ACTION_CR_INSTANCE,
        storeKey: 'crStoreKey',
        firstLevelName: 'collectionResources',
        serviceId: 'serviceModelId'
      }).serviceInstance['serviceModelId']['collectionResources']['crStoreKey'];

    expect(crState).toBeDefined();
    expect(crState.action).toEqual(ServiceInstanceActions.Update);
  });

});