-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(scanDownload): class to function, hooks (#180)
* scanDownload, class to function, apply context hook * scanJobList, pass scan job object * scansContext, expand with onDownloadJob * reportsAction, fixes, allows toast notifications * reportsReducer, move type to scansReducer * scansReducer, expand actions with jobs type * scansSelectors, pass original job object
- Loading branch information
Showing
17 changed files
with
267 additions
and
365 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,42 @@ | ||
import React from 'react'; | ||
import configureMockStore from 'redux-mock-store'; | ||
import { Provider } from 'react-redux'; | ||
import { mount, shallow } from 'enzyme'; | ||
import { ConnectedScanDownload, ScanDownload } from '../scanDownload'; | ||
import { ScanDownload } from '../scanDownload'; | ||
import { apiTypes } from '../../../constants/apiConstants'; | ||
|
||
describe('ScanDownload Component', () => { | ||
const generateEmptyStore = (obj = {}) => configureMockStore()(obj); | ||
|
||
it('should render a connected component', () => { | ||
const store = generateEmptyStore({}); | ||
|
||
it('should render a basic component', async () => { | ||
const props = { | ||
downloadId: 1 | ||
job: { | ||
[apiTypes.API_RESPONSE_JOB_ID]: 1, | ||
[apiTypes.API_RESPONSE_JOB_NAME]: 'lorem ipsum' | ||
} | ||
}; | ||
|
||
const component = shallow( | ||
<Provider store={store}> | ||
<ConnectedScanDownload {...props} /> | ||
</Provider> | ||
); | ||
|
||
expect(component.render()).toMatchSnapshot('connected'); | ||
const component = await shallowHookComponent(<ScanDownload {...props} />); | ||
expect(component.render()).toMatchSnapshot('basic'); | ||
}); | ||
|
||
it('should render a non-connected component', () => { | ||
it('should handle custom children', async () => { | ||
const props = { | ||
downloadId: 1 | ||
job: { | ||
[apiTypes.API_RESPONSE_JOB_ID]: 1, | ||
[apiTypes.API_RESPONSE_JOB_NAME]: 'lorem ipsum' | ||
} | ||
}; | ||
|
||
const component = mount(<ScanDownload {...props} />); | ||
|
||
expect(component.render()).toMatchSnapshot('non-connected'); | ||
}); | ||
|
||
it('should handle custom children', () => { | ||
const props = { | ||
downloadId: 1 | ||
}; | ||
|
||
const component = mount(<ScanDownload {...props}>lorem ipsum</ScanDownload>); | ||
|
||
const component = await shallowHookComponent(<ScanDownload {...props}>lorem ipsum</ScanDownload>); | ||
expect(component.render()).toMatchSnapshot('custom'); | ||
}); | ||
|
||
it('should have an optional tooltip', () => { | ||
it('should have an optional tooltip', async () => { | ||
const props = { | ||
downloadId: 1, | ||
job: { | ||
[apiTypes.API_RESPONSE_JOB_ID]: 1, | ||
[apiTypes.API_RESPONSE_JOB_NAME]: 'lorem ipsum' | ||
}, | ||
tooltip: 'Lorem ipsum dolor sit' | ||
}; | ||
|
||
const component = mount(<ScanDownload {...props} />); | ||
|
||
const component = await shallowHookComponent(<ScanDownload {...props} />); | ||
expect(component).toMatchSnapshot('tooltip'); | ||
}); | ||
}); |
Oops, something went wrong.