Skip to content

Commit 6d51846

Browse files
committed
Test fixes
1 parent d525a89 commit 6d51846

File tree

2 files changed

+25
-63
lines changed

2 files changed

+25
-63
lines changed

ui/js/dfv/src/store/test/actions.js

Lines changed: 16 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,17 @@
11
import {
2-
SAVE_STATUSES,
3-
DUPLICATE_STATUSES,
4-
DELETE_STATUSES,
5-
UI_ACTIONS,
6-
CURRENT_POD_ACTIONS,
2+
SAVE_STATUSES, DUPLICATE_STATUSES, DELETE_STATUSES, UI_ACTIONS, CURRENT_POD_ACTIONS,
73
} from '../constants';
84

95
import {
106
// UI
11-
setActiveTab,
12-
setSaveStatus,
13-
setDeleteStatus,
14-
setGroupSaveStatus,
15-
setGroupDuplicateStatus,
16-
setGroupDeleteStatus,
17-
// @todo add Field tests:
18-
setFieldSaveStatus,
19-
setFieldDeleteStatus,
7+
setActiveTab, setSaveStatus, setDeleteStatus, setGroupSaveStatus, setGroupDuplicateStatus, setGroupDeleteStatus, // @todo add Field tests:
8+
setFieldSaveStatus, setFieldDeleteStatus,
209

2110
// Current Pod options
22-
setPodName,
23-
setOptionValue,
24-
setOptionsValues,
25-
moveGroup,
26-
addGroup,
11+
setPodName, setOptionValue, setOptionsValues, moveGroup, addGroup,
2712

2813
// API
29-
savePod,
30-
deletePod,
31-
saveGroup,
32-
duplicateGroup,
33-
deleteGroup,
14+
savePod, deletePod, saveGroup, duplicateGroup, deleteGroup,
3415

3516
// setGroupFields,
3617
// addGroupField,
@@ -97,9 +78,7 @@ describe( 'actions', () => {
9778
},
9879
};
9980

100-
const result = setGroupSaveStatus(
101-
SAVE_STATUSES.SAVE_SUCCESS,
102-
)( {
81+
const result = setGroupSaveStatus( SAVE_STATUSES.SAVE_SUCCESS )( {
10382
message: 'Saved successfully.',
10483
} );
10584

@@ -109,15 +88,14 @@ describe( 'actions', () => {
10988
test( 'setGroupDuplicateStatus() creates a function to create an action to change the group\'s duplicate status', () => {
11089
const expected = {
11190
type: UI_ACTIONS.SET_GROUP_DUPLICATE_STATUS,
112-
saveStatus: DUPLICATE_STATUSES.DUPLICATE_SUCCESS,
91+
duplicateStatus: DUPLICATE_STATUSES.DUPLICATE_SUCCESS,
92+
name: 'new_group_name',
11393
result: {
11494
message: 'Duplicated successfully.',
11595
},
11696
};
11797

118-
const result = setGroupDuplicateStatus(
119-
DUPLICATE_STATUSES.DUPLICATE_SUCCESS,
120-
)( {
98+
const result = setGroupDuplicateStatus( DUPLICATE_STATUSES.DUPLICATE_SUCCESS, 'new_group_name' )( {
12199
message: 'Duplicated successfully.',
122100
} );
123101

@@ -133,9 +111,7 @@ describe( 'actions', () => {
133111
},
134112
};
135113

136-
const result = setGroupDeleteStatus(
137-
DELETE_STATUSES.DELETING,
138-
)( {
114+
const result = setGroupDeleteStatus( DELETE_STATUSES.DELETING )( {
139115
message: 'Deleted.',
140116
} );
141117

@@ -151,9 +127,7 @@ describe( 'actions', () => {
151127
},
152128
};
153129

154-
const result = setFieldSaveStatus(
155-
SAVE_STATUSES.SAVE_SUCCESS,
156-
)( {
130+
const result = setFieldSaveStatus( SAVE_STATUSES.SAVE_SUCCESS )( {
157131
message: 'Saved successfully.',
158132
} );
159133

@@ -169,9 +143,7 @@ describe( 'actions', () => {
169143
},
170144
};
171145

172-
const result = setFieldDeleteStatus(
173-
DELETE_STATUSES.DELETING,
174-
)( {
146+
const result = setFieldDeleteStatus( DELETE_STATUSES.DELETING )( {
175147
message: 'Deleted.',
176148
} );
177149

@@ -273,15 +245,12 @@ describe( 'actions', () => {
273245
storage: 'test',
274246
object_storage_type: 'collection',
275247
type: 'post_type',
276-
_locale: 'user',
277-
// The following should be included.
248+
_locale: 'user', // The following should be included.
278249
label_add_new: 'Add New Something',
279250
rest_enable: '0',
280-
description: 'Test',
281-
// Groups/fields will change into the "order" data.
251+
description: 'Test', // Groups/fields will change into the "order" data.
282252
groups: [
283-
GROUP,
284-
{
253+
GROUP, {
285254
...GROUP,
286255
id: 123,
287256
name: 'another-group',
@@ -306,8 +275,7 @@ describe( 'actions', () => {
306275
{
307276
group_id: 122,
308277
fields: [ 119 ],
309-
},
310-
{
278+
}, {
311279
group_id: 123,
312280
fields: [ 139 ],
313281
},

ui/js/dfv/src/store/test/reducer.js

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,11 @@ import deepFreeze from 'deep-freeze';
33
import * as paths from '../state-paths';
44

55
import {
6-
SAVE_STATUSES,
7-
DUPLICATE_STATUSES,
8-
DELETE_STATUSES,
9-
CURRENT_POD_ACTIONS,
10-
UI_ACTIONS,
11-
INITIAL_UI_STATE,
6+
SAVE_STATUSES, DUPLICATE_STATUSES, DELETE_STATUSES, CURRENT_POD_ACTIONS, UI_ACTIONS, INITIAL_UI_STATE,
127
} from '../constants';
138

149
import {
15-
ui,
16-
currentPod,
17-
global,
10+
ui, currentPod, global,
1811
} from '../reducer';
1912

2013
describe( 'UI reducer', () => {
@@ -60,9 +53,10 @@ describe( 'UI reducer', () => {
6053
expect( newState.saveMessage ).toEqual( 'Saving...' );
6154
} );
6255

63-
it( 'changes the duplicate status', () => {
56+
it( 'changes the group duplicate status', () => {
6457
const action = {
65-
type: UI_ACTIONS.SET_DUPLICATE_STATUS,
58+
type: UI_ACTIONS.SET_GROUP_DUPLICATE_STATUS,
59+
name: 'group_abc',
6660
duplicateStatus: DUPLICATE_STATUSES.DUPLICATING,
6761
result: {
6862
message: 'Duplicating...',
@@ -71,13 +65,13 @@ describe( 'UI reducer', () => {
7165

7266
const newState = ui( state, action );
7367

74-
expect( newState.duplicateStatus ).toEqual( action.duplicateStatus );
75-
expect( newState.duplicateMessage ).toEqual( 'Duplicating...' );
68+
expect( newState.groupDuplicateStatuses.group_abc ).toEqual( action.duplicateStatus );
69+
expect( newState.groupDuplicateMessages.group_abc ).toEqual( 'Duplicating...' );
7670
} );
7771

78-
it( 'uses the default for an unknown duplicate status', () => {
72+
it( 'uses the default for an unknown group duplicate status', () => {
7973
const action = {
80-
type: UI_ACTIONS.SET_DUPLICATE_STATUS,
74+
type: UI_ACTIONS.SET_GROUP_DUPLICATE_STATUS,
8175
duplicateStatus: 'xyzzy',
8276
};
8377

0 commit comments

Comments
 (0)