Skip to content

Commit 080e62d

Browse files
committed
test: add unit tests for setXBlockPublishState reducer
1 parent e8fa69f commit 080e62d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/course-unit/data/slice.test.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { reducer, setXBlockPublishState } from './slice';
2+
3+
describe('setXBlockPublishState reducer', () => {
4+
it('sets published and hasChanges correctly when payload is true', () => {
5+
const prevState = {
6+
courseSectionVertical: {
7+
xblockInfo: {
8+
published: false,
9+
hasChanges: true,
10+
},
11+
},
12+
};
13+
const nextState = reducer(prevState, setXBlockPublishState(true));
14+
expect(nextState.courseSectionVertical.xblockInfo.published).toBe(true);
15+
expect(nextState.courseSectionVertical.xblockInfo.hasChanges).toBe(false);
16+
});
17+
18+
it('sets published and hasChanges correctly when payload is false', () => {
19+
const prevState = {
20+
courseSectionVertical: {
21+
xblockInfo: {
22+
published: true,
23+
hasChanges: false,
24+
},
25+
},
26+
};
27+
const nextState = reducer(prevState, setXBlockPublishState(false));
28+
expect(nextState.courseSectionVertical.xblockInfo.published).toBe(false);
29+
expect(nextState.courseSectionVertical.xblockInfo.hasChanges).toBe(true);
30+
});
31+
});

0 commit comments

Comments
 (0)