-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #223 from giranm/release/v0.3.0-beta.0
[Release] v0.3.0-beta.0
- Loading branch information
Showing
29 changed files
with
575 additions
and
154 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,5 +9,6 @@ module.exports = { | |
}, | ||
transform: { | ||
'^.+\\.[t|j]sx?$': 'babel-jest', | ||
'^.+\\.svg$': 'svg-jest', | ||
}, | ||
}; |
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
106 changes: 106 additions & 0 deletions
106
src/components/IncidentTable/IncidentTableComponent.test.js
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,106 @@ | ||
import '@testing-library/jest-dom'; | ||
|
||
import { | ||
sanitizeUrl, | ||
} from '@braintree/sanitize-url'; | ||
import validator from 'validator'; | ||
|
||
import { | ||
mockStore, componentWrapper, | ||
} from 'mocks/store.test'; | ||
|
||
import { | ||
generateMockIncidents, | ||
} from 'mocks/incidents.test'; | ||
|
||
import IncidentTableComponent from './IncidentTableComponent'; | ||
|
||
describe('IncidentTableComponent', () => { | ||
let baseStore; | ||
let store; | ||
// FIXME: Jest can only render max of 3 incidents for some reason? | ||
const mockIncidents = generateMockIncidents(3); | ||
|
||
beforeEach(() => { | ||
baseStore = { | ||
incidentTable: { | ||
incidentTableState: {}, | ||
incidentTableColumns: [ | ||
{ | ||
Header: '#', | ||
width: 60, | ||
columnType: 'incident', | ||
}, | ||
{ | ||
Header: 'Status', | ||
width: 100, | ||
columnType: 'incident', | ||
}, | ||
{ | ||
Header: 'Title', | ||
width: 400, | ||
columnType: 'incident', | ||
}, | ||
{ | ||
Header: 'quote', | ||
accessorPath: 'details.quote', | ||
aggregator: null, | ||
width: 100, | ||
columnType: 'alert', | ||
}, | ||
{ | ||
Header: 'link', | ||
accessorPath: 'details.link', | ||
aggregator: null, | ||
width: 100, | ||
columnType: 'alert', | ||
}, | ||
], | ||
}, | ||
incidentActions: { | ||
status: '', | ||
}, | ||
incidents: { | ||
filteredIncidentsByQuery: mockIncidents, | ||
fetchingIncidents: false, | ||
}, | ||
querySettings: { | ||
displayConfirmQueryModal: false, | ||
}, | ||
}; | ||
}); | ||
|
||
it('should render incident table with non-empty data', () => { | ||
store = mockStore(baseStore); | ||
const wrapper = componentWrapper(store, IncidentTableComponent); | ||
expect(wrapper.find('.incident-table-ctr')).toBeTruthy(); | ||
expect( | ||
wrapper | ||
.find('.th') | ||
.getElements() | ||
.filter((th) => th.key.includes('header')), | ||
).toHaveLength(baseStore.incidentTable.incidentTableColumns.length + 1); // Include selection header | ||
expect( | ||
wrapper | ||
.find('[role="row"]') | ||
.getElements() | ||
.filter((tr) => tr.key.includes('row')), | ||
).toHaveLength(mockIncidents.length); | ||
}); | ||
|
||
it('should render cell with valid hyperlink for custom detail field', () => { | ||
store = mockStore(baseStore); | ||
const wrapper = componentWrapper(store, IncidentTableComponent); | ||
|
||
const incidentNumber = 1; | ||
const customDetailField = 'link'; | ||
const url = wrapper | ||
.find('[role="row"]') | ||
.get(incidentNumber) | ||
.props.children.find((td) => td.key.includes(customDetailField)).props.children.props | ||
.cell.value; | ||
const sanitizedUrl = sanitizeUrl(url); | ||
|
||
expect(validator.isURL(sanitizedUrl)).toBeTruthy(); | ||
}); | ||
}); |
Oops, something went wrong.