-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: limit insert link only for course sections
- Loading branch information
Showing
14 changed files
with
204 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { actions, reducer } from './reducers'; | ||
export { default as selectors } from './selectors'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { createSlice } from '@reduxjs/toolkit'; | ||
import { StrictDict } from '../../../utils'; | ||
|
||
const initialState = { | ||
selectedBlocks: {}, | ||
}; | ||
|
||
// eslint-disable-next-line no-unused-vars | ||
const insertlink = createSlice({ | ||
name: 'insertlink', | ||
initialState, | ||
reducers: { | ||
addBlock: (state, { payload }) => { | ||
state.selectedBlocks = { ...state.selectedBlocks, ...payload }; | ||
}, | ||
}, | ||
}); | ||
|
||
const actions = StrictDict(insertlink.actions); | ||
|
||
const { reducer } = insertlink; | ||
|
||
export { | ||
actions, | ||
initialState, | ||
reducer, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { reducer, actions, initialState } from './reducers'; | ||
|
||
describe('insertlink reducer', () => { | ||
it('should return the initial state', () => { | ||
expect(reducer(undefined, {})).toEqual(initialState); | ||
}); | ||
|
||
it('should handle addBlock', () => { | ||
const payload = { | ||
block123: { id: 'block123', content: 'Block 123 content' }, | ||
block456: { id: 'block456', content: 'Block 456 content' }, | ||
}; | ||
const action = actions.addBlock(payload); | ||
|
||
const previousState = { | ||
selectedBlocks: { block789: { id: 'block789', content: 'Block 789 content' } }, | ||
}; | ||
|
||
const expectedState = { | ||
selectedBlocks: { | ||
...previousState.selectedBlocks, | ||
...payload, | ||
}, | ||
}; | ||
|
||
expect(reducer(previousState, action)).toEqual(expectedState); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const insertlinkState = (state) => state.insertlink; | ||
|
||
export default { | ||
insertlinkState, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { insertlinkState } from './selectors'; | ||
|
||
describe('insertlink selectors', () => { | ||
describe('insertlinkState selector', () => { | ||
it('should return the insertlink slice of the state', () => { | ||
const state = { | ||
insertlink: { | ||
selectedBlocks: { | ||
block123: { id: 'block123', url: 'https://www.example.com' }, | ||
block456: { id: 'block456', url: 'https://www.example.com' }, | ||
}, | ||
}, | ||
}; | ||
|
||
const { selectedBlocks } = insertlinkState(state); | ||
expect(selectedBlocks).toEqual(state.insertlink.selectedBlocks); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.