-
Notifications
You must be signed in to change notification settings - Fork 149
Replace connect with useSelector() and useDispatch() 4/5 #2317 #2346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
2bb2b76
cced750
f973345
2dfe074
9a5743b
a191dc4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,27 +1,8 @@ | ||||||||||||
import React from 'react'; | ||||||||||||
import { render, screen, initializeMocks } from '@src/testUtils'; | ||||||||||||
import ExplanationWidget from '.'; | ||||||||||||
|
||||||||||||
jest.mock('../../../../../data/redux', () => ({ | ||||||||||||
__esModule: true, | ||||||||||||
default: jest.fn(), | ||||||||||||
selectors: { | ||||||||||||
problem: { | ||||||||||||
settings: jest.fn(state => ({ question: state })), | ||||||||||||
}, | ||||||||||||
app: { | ||||||||||||
learningContextId: jest.fn(state => ({ learningContextId: state })), | ||||||||||||
images: jest.fn(state => ({ images: state })), | ||||||||||||
isLibrary: jest.fn(state => ({ isLibrary: state })), | ||||||||||||
blockId: jest.fn(state => ({ blockId: state })), | ||||||||||||
}, | ||||||||||||
}, | ||||||||||||
thunkActions: { | ||||||||||||
video: { | ||||||||||||
importTranscript: jest.fn(), | ||||||||||||
}, | ||||||||||||
}, | ||||||||||||
})); | ||||||||||||
import { screen, initializeMocks } from '@src/testUtils'; | ||||||||||||
import editorRender from '../../../../../modifiedEditorTestRender'; | ||||||||||||
import ExplanationWidget from './index'; | ||||||||||||
import { initializeStore } from '../../../../../data/redux'; | ||||||||||||
|
||||||||||||
jest.mock('../../../../../sharedComponents/TinyMceWidget/hooks', () => ({ | ||||||||||||
...jest.requireActual('../../../../../sharedComponents/TinyMceWidget/hooks'), | ||||||||||||
|
@@ -36,19 +17,27 @@ jest.mock('../../../../../sharedComponents/TinyMceWidget', () => ({ | |||||||||||
default: () => <div>TinyMceWidget</div>, | ||||||||||||
})); | ||||||||||||
|
||||||||||||
describe('SolutionWidget', () => { | ||||||||||||
const props = { | ||||||||||||
const initialState = { | ||||||||||||
problem: { | ||||||||||||
settings: { solutionExplanation: 'This is my solution' }, | ||||||||||||
}, | ||||||||||||
app: { | ||||||||||||
learningContextId: 'course+org+run', | ||||||||||||
images: {}, | ||||||||||||
isLibrary: false, | ||||||||||||
blockId: 'block-v1:Org+TS100+24+type@html+block@12345', | ||||||||||||
}; | ||||||||||||
}, | ||||||||||||
}; | ||||||||||||
|
||||||||||||
describe('SolutionWidget', () => { | ||||||||||||
beforeEach(() => { | ||||||||||||
initializeMocks(); | ||||||||||||
initializeMocks({ | ||||||||||||
initializeStore, | ||||||||||||
initialState, | ||||||||||||
}); | ||||||||||||
Comment on lines
+34
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Since you are passing |
||||||||||||
}); | ||||||||||||
test('renders correct default', () => { | ||||||||||||
render(<ExplanationWidget {...props} />); | ||||||||||||
editorRender(<ExplanationWidget />, { initialState }); | ||||||||||||
expect(screen.getByText('Explanation')).toBeInTheDocument(); | ||||||||||||
expect(screen.getByText('Provide an explanation for the correct answer')).toBeInTheDocument(); | ||||||||||||
expect(screen.getByText('TinyMceWidget')).toBeInTheDocument(); | ||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -1,33 +1,8 @@ | ||||||||
import React from 'react'; | ||||||||
import { render, screen, initializeMocks } from '@src/testUtils'; | ||||||||
import { formatMessage } from '@src/editors/testUtils'; | ||||||||
import { QuestionWidgetInternal as QuestionWidget } from '.'; | ||||||||
|
||||||||
jest.mock('@src/editors/data/redux', () => ({ | ||||||||
__esModule: true, | ||||||||
default: jest.fn(), | ||||||||
actions: { | ||||||||
problem: { | ||||||||
updateQuestion: jest.fn().mockName('actions.problem.updateQuestion'), | ||||||||
}, | ||||||||
}, | ||||||||
selectors: { | ||||||||
app: { | ||||||||
learningContextId: jest.fn(state => ({ learningContextId: state })), | ||||||||
images: jest.fn(state => ({ images: state })), | ||||||||
isLibrary: jest.fn(state => ({ isLibrary: state })), | ||||||||
blockId: jest.fn(state => ({ blockId: state })), | ||||||||
}, | ||||||||
problem: { | ||||||||
question: jest.fn(state => ({ question: state })), | ||||||||
}, | ||||||||
}, | ||||||||
thunkActions: { | ||||||||
video: { | ||||||||
importTranscript: jest.fn(), | ||||||||
}, | ||||||||
}, | ||||||||
})); | ||||||||
import { screen, initializeMocks } from '@src/testUtils'; | ||||||||
import editorRender from '../../../../../modifiedEditorTestRender'; | ||||||||
import { initializeStore } from '../../../../../data/redux'; | ||||||||
Comment on lines
+3
to
+4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
import QuestionWidget from '.'; | ||||||||
|
||||||||
jest.mock('@src/editors/sharedComponents/TinyMceWidget/hooks', () => ({ | ||||||||
...jest.requireActual('../../../../../sharedComponents/TinyMceWidget/hooks'), | ||||||||
|
@@ -39,23 +14,28 @@ jest.mock('@src/editors/sharedComponents/TinyMceWidget/hooks', () => ({ | |||||||
|
||||||||
jest.mock('@src/editors/sharedComponents/TinyMceWidget', () => ('TinyMceWidget')); | ||||||||
|
||||||||
describe('QuestionWidget', () => { | ||||||||
const props = { | ||||||||
const initialState = { | ||||||||
problem: { | ||||||||
question: 'This is my question', | ||||||||
updateQuestion: jest.fn(), | ||||||||
}, | ||||||||
app: { | ||||||||
learningContextId: 'course+org+run', | ||||||||
images: {}, | ||||||||
isLibrary: false, | ||||||||
blockId: '', | ||||||||
// injected | ||||||||
intl: { formatMessage }, | ||||||||
}; | ||||||||
}, | ||||||||
}; | ||||||||
|
||||||||
describe('QuestionWidget', () => { | ||||||||
beforeEach(() => { | ||||||||
initializeMocks({ initialState, initializeStore }); | ||||||||
}); | ||||||||
Comment on lines
+30
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
describe('render', () => { | ||||||||
beforeEach(() => { | ||||||||
initializeMocks(); | ||||||||
}); | ||||||||
test('renders correct default', () => { | ||||||||
render(<QuestionWidget {...props} />); | ||||||||
editorRender(<QuestionWidget />, { initialState }); | ||||||||
expect(screen.getByText('Question')).toBeInTheDocument(); | ||||||||
}); | ||||||||
}); | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this
modifiedEditorTestRender
? It doesn't seem to be necessary. The existingeditorRender
works fine.