forked from chpladmin/chpl-website
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'ver-11.20.1' into production
- Loading branch information
Showing
25 changed files
with
366 additions
and
84 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
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
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,84 @@ | ||
import React from 'react'; | ||
import { | ||
Button, | ||
Dialog, | ||
DialogActions, | ||
DialogContent, | ||
DialogContentText, | ||
DialogTitle, | ||
Divider, | ||
Slide, | ||
makeStyles, | ||
} from '@material-ui/core'; | ||
import { | ||
func, string, | ||
} from 'prop-types'; | ||
|
||
import CheckIcon from '@material-ui/icons/Check'; | ||
import CloseIcon from '@material-ui/icons/Close'; | ||
|
||
const Transition = React.forwardRef((props, ref) => <Slide direction="up" ref={ref} {...props} />); | ||
|
||
const useStyles = makeStyles({ | ||
dialogTitle: { | ||
fontWeight: 800, | ||
fontSize: '1.5em', | ||
}, | ||
dialogContent: { | ||
color: '#000000', | ||
}, | ||
dialogActions: { | ||
justifyContent: 'flex-start', | ||
}, | ||
iconSpacing: { | ||
marginLeft: '4px', | ||
}, | ||
}); | ||
|
||
function ChplActionBarConfirmation(props) { | ||
const classes = useStyles(); | ||
|
||
const act = (action) => { | ||
props.dispatch(action); | ||
}; | ||
|
||
return ( | ||
<Dialog | ||
open | ||
onClose={() => act('no')} | ||
aria-labelledby="alert-dialog-title" | ||
aria-describedby="alert-dialog-description" | ||
TransitionComponent={Transition} | ||
> | ||
<DialogTitle id="alert-dialog-title" className={classes.dialogTitle}> | ||
Confirm | ||
</DialogTitle> | ||
<Divider /> | ||
<DialogContent> | ||
<DialogContentText id="alert-dialog-description" className={classes.dialogContent}> | ||
{ props.pendingMessage } | ||
</DialogContentText> | ||
</DialogContent> | ||
<Divider /> | ||
<DialogActions className={classes.dialogActions}> | ||
<Button onClick={() => act('yes')} color="primary" variant="contained" autoFocus> | ||
Yes | ||
{' '} | ||
<CheckIcon className={classes.iconSpacing} /> | ||
</Button> | ||
<Button onClick={() => act('no')} color="default" variant="contained"> | ||
No | ||
{' '} | ||
<CloseIcon className={classes.iconSpacing} /> | ||
</Button> | ||
</DialogActions> | ||
</Dialog> | ||
); | ||
} | ||
|
||
export default ChplActionBarConfirmation; | ||
|
||
ChplActionBarConfirmation.propTypes = { | ||
dispatch: func.isRequired, | ||
pendingMessage: string.isRequired, | ||
}; |
47 changes: 47 additions & 0 deletions
47
src/app/components/action-bar/action-bar-confirmation.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,47 @@ | ||
import React from 'react'; | ||
import { | ||
cleanup, render, screen, waitFor, | ||
} from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import userEvent from '@testing-library/user-event'; | ||
|
||
import ChplActionBarConfirmation from './action-bar-confirmation'; | ||
|
||
const hocMock = { | ||
dispatch: jest.fn(), | ||
}; | ||
|
||
describe('the ChplActionBarConfirmation component', () => { | ||
beforeEach(async () => { | ||
render( | ||
<ChplActionBarConfirmation | ||
dispatch={hocMock.dispatch} | ||
pendingMessage="This is your message" | ||
/>, | ||
); | ||
}); | ||
|
||
afterEach(() => { | ||
cleanup(); | ||
}); | ||
|
||
describe('when taking actions', () => { | ||
it('should call the callback for "No"', async () => { | ||
hocMock.dispatch.mockClear(); | ||
userEvent.click(screen.getByRole('button', { name: /No/i })); | ||
|
||
await waitFor(() => { | ||
expect(hocMock.dispatch).toHaveBeenCalledWith('no'); | ||
}); | ||
}); | ||
|
||
it('should call the callback for "Yes"', async () => { | ||
hocMock.dispatch.mockClear(); | ||
userEvent.click(screen.getByRole('button', { name: /Yes/i })); | ||
|
||
await waitFor(() => { | ||
expect(hocMock.dispatch).toHaveBeenCalledWith('yes'); | ||
}); | ||
}); | ||
}); | ||
}); |
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
75 changes: 75 additions & 0 deletions
75
src/app/components/listing/details/criteria/criterion.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,75 @@ | ||
import React from 'react'; | ||
import { when } from 'jest-when'; | ||
import { | ||
cleanup, render, screen, waitFor, | ||
} from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import userEvent from '@testing-library/user-event'; | ||
|
||
import * as angularReactHelper from '../../../../services/angular-react-helper'; | ||
import ChplCriterion from './criterion'; | ||
|
||
const $analyticsMock = { | ||
eventTrack: jest.fn(), | ||
}; | ||
const utilServiceMock = { | ||
isCures: jest.fn(), | ||
}; | ||
angularReactHelper.getAngularService = jest.fn(); | ||
when(angularReactHelper.getAngularService).calledWith('$analytics').mockReturnValue($analyticsMock); | ||
when(angularReactHelper.getAngularService).calledWith('utilService').mockReturnValue(utilServiceMock); | ||
|
||
jest.mock('./criterion-details-view', () => ({ | ||
__esModule: true, | ||
default: jest.fn(() => 42), | ||
})); | ||
|
||
describe('the ChplCriterion component', () => { | ||
afterEach(() => { | ||
cleanup(); | ||
}); | ||
|
||
describe('when opening the accordion', () => { | ||
beforeEach(async () => { | ||
render( | ||
<ChplCriterion | ||
accessibilityStandards={[]} | ||
certificationResult={{ | ||
success: true, | ||
criterion: { | ||
number: '170.315 (z)(1)', | ||
title: 'Criterion Title', | ||
}, | ||
}} | ||
qmsStandards={[]} | ||
/>, | ||
); | ||
}); | ||
|
||
it('should track analytics', async () => { | ||
$analyticsMock.eventTrack.mockClear(); | ||
utilServiceMock.isCures.mockReturnValueOnce(false); | ||
userEvent.click(screen.getByText('170.315 (z)(1)')); | ||
|
||
await waitFor(() => { | ||
expect($analyticsMock.eventTrack).toHaveBeenCalledWith( | ||
'Viewed criteria details', | ||
{ category: 'Listing Details', label: '170.315 (z)(1)' }, | ||
); | ||
}); | ||
}); | ||
|
||
it('should track analytics for cures criteria', async () => { | ||
$analyticsMock.eventTrack.mockClear(); | ||
utilServiceMock.isCures.mockReturnValueOnce(true); | ||
userEvent.click(screen.getByText('170.315 (z)(1)')); | ||
|
||
await waitFor(() => { | ||
expect($analyticsMock.eventTrack).toHaveBeenCalledWith( | ||
'Viewed criteria details', | ||
{ category: 'Listing Details', label: '170.315 (z)(1) (Cures Update)' }, | ||
); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.