-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
179 additions
and
5 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
33 changes: 33 additions & 0 deletions
33
src/containers/ReviewProblemStepsModal/components/ReviewProblemStepActions/index.test.jsx
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,33 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import ReviewProblemStepActions from '.'; | ||
|
||
describe('ReviewProblemStepActions component', () => { | ||
it('renders without crashing', () => { | ||
const wrapper = shallow(<ReviewProblemStepActions />); | ||
expect(wrapper.exists()).toBe(true); | ||
}); | ||
it('should render the component with correct content', () => { | ||
const wrapper = shallow(<ReviewProblemStepActions />); | ||
|
||
// Check if certain elements with expected text content exist in the rendered component | ||
expect(wrapper.find('h3').text()).toEqual('John Doe'); | ||
expect(wrapper.find('p').at(0).text()).toEqual('jhon_20'); | ||
expect(wrapper.find('h4').at(0).text()).toEqual('Email'); | ||
expect(wrapper.find('p').at(1).text()).toEqual('[email protected]'); | ||
expect(wrapper.find('h4').at(1).text()).toEqual('Submission ID'); | ||
expect(wrapper.find('p').at(2).text()).toEqual('483234704918'); | ||
expect(wrapper.find('h4').at(2).text()).toEqual('Submission date'); | ||
expect(wrapper.find('p').at(3).text()).toEqual('9/13/2023, 7:13:56 AM'); | ||
expect(wrapper.find('h4').at(3).text()).toEqual('Grade'); | ||
expect(wrapper.find('p').at(4).text()).toEqual('3/10'); | ||
expect(wrapper.find('h4').at(4).text()).toEqual('Grading status'); | ||
expect(wrapper.find('p').at(5).text()).toEqual('Upgraded'); | ||
|
||
// Check if StatusBadges with expected titles exist | ||
expect(wrapper.find('StatusBadge').at(0).prop('title')).toEqual('Training'); | ||
expect(wrapper.find('StatusBadge').at(1).prop('title')).toEqual('Peers'); | ||
expect(wrapper.find('StatusBadge').at(2).prop('title')).toEqual('Self'); | ||
expect(wrapper.find('StatusBadge').at(3).prop('title')).toEqual('Staff'); | ||
}); | ||
}); |
31 changes: 31 additions & 0 deletions
31
...ReviewProblemStepsContent/components/ResponsesList/components/ResponseItem/index.test.jsx
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,31 @@ | ||
import React from 'react'; | ||
import { shallow, mount } from 'enzyme'; | ||
import ResponseItem from '.'; | ||
|
||
describe('ResponseItem component', () => { | ||
it('renders without crashing', () => { | ||
const wrapper = shallow(<ResponseItem title="Title" response="Response Content" />); | ||
expect(wrapper.exists()).toBe(true); | ||
}); | ||
|
||
it('displays the title and response', () => { | ||
const title = 'Title'; | ||
const response = 'Response Content'; | ||
const wrapper = shallow(<ResponseItem title={title} response={response} />); | ||
expect(wrapper.find('h4').text()).toBe(title); | ||
expect(wrapper.find('.collapsible-body').text()).toBe(response); | ||
}); | ||
|
||
it('collapses when trigger is clicked twice', () => { | ||
const title = 'Title'; | ||
const response = 'Response Content'; | ||
const wrapper = mount(<ResponseItem title={title} response={response} />); | ||
|
||
// Click on the trigger to expand | ||
wrapper.find('.collapsible-trigger').simulate('click'); | ||
// Click again to collapse | ||
wrapper.find('.collapsible-trigger').simulate('click'); | ||
// After clicking twice, the Collapsible should be closed | ||
expect(wrapper.find('.collapsible-body').hasClass('collapsible-body--open')).toBe(false); | ||
}); | ||
}); |
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,25 @@ | ||
import { actions, reducer, initialState } from './reducer'; | ||
|
||
describe('problemSteps reducer', () => { | ||
it('should return the initial state', () => { | ||
const state = reducer(undefined, {}); | ||
expect(state).toEqual(initialState); | ||
}); | ||
|
||
it('should handle setOpenReviewModal correctly', () => { | ||
const newState = reducer(initialState, actions.setOpenReviewModal(true)); | ||
|
||
expect(newState.reviewModalOpen).toEqual(true); | ||
expect(newState.someOtherProperty).toEqual(initialState.someOtherProperty); | ||
}); | ||
|
||
it('should handle setOpenReviewModal with false correctly', () => { | ||
// If you want to test setting reviewModalOpen to false | ||
const stateWithOpenModal = { ...initialState, reviewModalOpen: true }; | ||
const newState = reducer(stateWithOpenModal, actions.setOpenReviewModal(false)); | ||
|
||
// Check if reviewModalOpen is set to false | ||
expect(newState.reviewModalOpen).toEqual(false); | ||
expect(newState.someOtherProperty).toEqual(stateWithOpenModal.someOtherProperty); | ||
}); | ||
}); |
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,18 @@ | ||
import { simpleSelectors } from './selectors'; | ||
|
||
describe('simpleSelectors', () => { | ||
it('should select reviewModalOpen from the state', () => { | ||
const initialState = { | ||
problemSteps: { | ||
reviewModalOpen: true, | ||
}, | ||
}; | ||
|
||
const store = { | ||
getState: () => initialState, | ||
}; | ||
|
||
const selectedReviewModalOpen = simpleSelectors.reviewModalOpen(store.getState()); | ||
expect(selectedReviewModalOpen).toEqual(true); | ||
}); | ||
}); |