Skip to content

Commit 482894e

Browse files
committed
Simplify workspace reducer test generation code
1 parent 496b4b1 commit 482894e

File tree

1 file changed

+10
-56
lines changed

1 file changed

+10
-56
lines changed

src/commons/workspace/__tests__/WorkspaceReducer.ts

Lines changed: 10 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -70,66 +70,20 @@ import {
7070
WorkspaceManagerState
7171
} from '../WorkspaceTypes';
7272

73-
const assessmentWorkspace: WorkspaceLocation = 'assessment';
74-
const gradingWorkspace: WorkspaceLocation = 'grading';
7573
const playgroundWorkspace: WorkspaceLocation = 'playground';
76-
const sourcecastWorkspace: WorkspaceLocation = 'sourcecast';
77-
const sourcereelWorkspace: WorkspaceLocation = 'sourcereel';
7874
const sicpWorkspace: WorkspaceLocation = 'sicp';
79-
const githubAssessmentWorkspace: WorkspaceLocation = 'githubAssessment';
75+
const locations: ReadonlyArray<WorkspaceLocation> = [
76+
'assessment',
77+
'grading',
78+
'playground',
79+
'sourcecast',
80+
'sourcereel',
81+
'sicp',
82+
'githubAssessment'
83+
] as const;
8084

8185
function generateActions(type: string, payload: any = {}): any[] {
82-
return [
83-
{
84-
type,
85-
payload: {
86-
...payload,
87-
workspaceLocation: assessmentWorkspace
88-
}
89-
},
90-
{
91-
type,
92-
payload: {
93-
...payload,
94-
workspaceLocation: gradingWorkspace
95-
}
96-
},
97-
{
98-
type,
99-
payload: {
100-
...payload,
101-
workspaceLocation: playgroundWorkspace
102-
}
103-
},
104-
{
105-
type,
106-
payload: {
107-
...payload,
108-
workspaceLocation: sourcecastWorkspace
109-
}
110-
},
111-
{
112-
type,
113-
payload: {
114-
...payload,
115-
workspaceLocation: sourcereelWorkspace
116-
}
117-
},
118-
{
119-
type,
120-
payload: {
121-
...payload,
122-
workspaceLocation: sicpWorkspace
123-
}
124-
},
125-
{
126-
type,
127-
payload: {
128-
...payload,
129-
workspaceLocation: githubAssessmentWorkspace
130-
}
131-
}
132-
];
86+
return locations.map(l => ({ type, payload: { ...payload, workspaceLocation: l } }));
13387
}
13488

13589
// cloneDeep not required for proper redux

0 commit comments

Comments
 (0)