-
-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: coverage * fix: coverage * add: tests * add: action tests * fix: add better test description * fix: coverage * fix: snapshot
- Loading branch information
Showing
9 changed files
with
363 additions
and
7 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
21 changes: 21 additions & 0 deletions
21
src/components/AuthScreen/Information/__tests__/Information.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,21 @@ | ||
import React from 'react'; | ||
|
||
import { shallowMatchSnapshot } from '../../../../common/test_utils'; | ||
import Information from '../Information'; | ||
|
||
jest.mock('../Information.messages', () => ({ | ||
heading: { | ||
id: 'cboard.components.AuthScreenInformation.heading', | ||
defaultMessage: 'Cboard' | ||
}, | ||
text: { | ||
id: 'cboard.components.AuthScreenInformation.text', | ||
defaultMessage: 'Sign up to sync your settings!' | ||
} | ||
})); | ||
|
||
describe('AuthScreen Information tests', () => { | ||
test('default renderer', () => { | ||
shallowMatchSnapshot(<Information />); | ||
}); | ||
}); |
28 changes: 28 additions & 0 deletions
28
src/components/AuthScreen/Information/__tests__/__snapshots__/Information.test.js.snap
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,28 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`AuthScreen Information tests default renderer 1`] = ` | ||
<React.Fragment> | ||
<WithStyles(Typography) | ||
align="center" | ||
className="AuthScreen__heading" | ||
variant="h2" | ||
> | ||
<FormattedMessage | ||
defaultMessage="Cboard" | ||
id="cboard.components.AuthScreenInformation.heading" | ||
values={Object {}} | ||
/> | ||
</WithStyles(Typography)> | ||
<WithStyles(Typography) | ||
align="center" | ||
className="AuthScreen__heading" | ||
variant="body1" | ||
> | ||
<FormattedMessage | ||
defaultMessage="Sign up to sync your settings!" | ||
id="cboard.components.AuthScreenInformation.text" | ||
values={Object {}} | ||
/> | ||
</WithStyles(Typography)> | ||
</React.Fragment> | ||
`; |
175 changes: 175 additions & 0 deletions
175
src/components/Communicator/__tests__/Communicator.actions.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,175 @@ | ||
import * as actions from '../Communicator.actions'; | ||
import * as types from '../Communicator.constants'; | ||
|
||
describe('actions', () => { | ||
it('should create an action to import communicator', () => { | ||
const payload = {}; | ||
|
||
const expectedAction = { | ||
type: types.IMPORT_COMMUNICATOR, | ||
payload | ||
}; | ||
expect(actions.importCommunicator(payload)).toEqual(expectedAction); | ||
}); | ||
|
||
it('should create an action to create communicator', () => { | ||
const payload = {}; | ||
const expectedAction = { | ||
type: types.CREATE_COMMUNICATOR, | ||
payload | ||
}; | ||
expect(actions.createCommunicator(payload)).toEqual(expectedAction); | ||
}); | ||
|
||
it('should create an action to edit communicator', () => { | ||
const payload = {}; | ||
const expectedAction = { | ||
type: types.EDIT_COMMUNICATOR, | ||
payload | ||
}; | ||
expect(actions.editCommunicator(payload)).toEqual(expectedAction); | ||
}); | ||
|
||
it('should create an action to delete communicator', () => { | ||
const id = {}; | ||
const expectedAction = { | ||
type: types.DELETE_COMMUNICATOR, | ||
payload: id | ||
}; | ||
expect(actions.deleteCommunicator(id)).toEqual(expectedAction); | ||
}); | ||
|
||
it('should create an action to change communicator', () => { | ||
const id = {}; | ||
const expectedAction = { | ||
type: types.CHANGE_COMMUNICATOR, | ||
payload: id | ||
}; | ||
expect(actions.changeCommunicator(id)).toEqual(expectedAction); | ||
}); | ||
|
||
it('should create an action to add board communicator', () => { | ||
const boardId = {}; | ||
const expectedAction = { | ||
type: types.ADD_BOARD_COMMUNICATOR, | ||
boardId | ||
}; | ||
expect(actions.addBoardCommunicator(boardId)).toEqual(expectedAction); | ||
}); | ||
|
||
it('should create an action to delete board communicator', () => { | ||
const boardId = {}; | ||
const expectedAction = { | ||
type: types.DELETE_BOARD_COMMUNICATOR, | ||
boardId | ||
}; | ||
expect(actions.deleteBoardCommunicator(boardId)).toEqual(expectedAction); | ||
}); | ||
|
||
it('should create an action to replace board communicator', () => { | ||
const prevBoardId = '10'; | ||
const nextBoardId = '20'; | ||
|
||
const expectedAction = { | ||
type: types.REPLACE_BOARD_COMMUNICATOR, | ||
prevBoardId, | ||
nextBoardId | ||
}; | ||
expect(actions.replaceBoardCommunicator(prevBoardId, nextBoardId)).toEqual( | ||
expectedAction | ||
); | ||
}); | ||
|
||
it('should create an action to get API success', () => { | ||
const communicators = {}; | ||
const expectedAction = { | ||
type: types.GET_API_MY_COMMUNICATORS_SUCCESS, | ||
communicators | ||
}; | ||
expect(actions.getApiMyCommunicatorsSuccess(communicators)).toEqual( | ||
expectedAction | ||
); | ||
}); | ||
|
||
it('should create an action to get API started', () => { | ||
const expectedAction = { | ||
type: types.GET_API_MY_COMMUNICATORS_STARTED | ||
}; | ||
expect(actions.getApiMyCommunicatorsStarted()).toEqual(expectedAction); | ||
}); | ||
|
||
it('should create an action to get API failure', () => { | ||
const message = 'dummy message'; | ||
const expectedAction = { | ||
type: types.GET_API_MY_COMMUNICATORS_FAILURE, | ||
message | ||
}; | ||
expect(actions.getApiMyCommunicatorsFailure(message)).toEqual( | ||
expectedAction | ||
); | ||
}); | ||
|
||
it('should create an action to create API success', () => { | ||
const communicator = {}; | ||
const communicatorId = '10'; | ||
|
||
const expectedAction = { | ||
type: types.CREATE_API_COMMUNICATOR_SUCCESS, | ||
communicator, | ||
communicatorId | ||
}; | ||
|
||
expect( | ||
actions.createApiCommunicatorSuccess(communicator, communicatorId) | ||
).toEqual(expectedAction); | ||
}); | ||
|
||
it('should create an action to create API started', () => { | ||
const expectedAction = { | ||
type: types.CREATE_API_COMMUNICATOR_STARTED | ||
}; | ||
expect(actions.createApiCommunicatorStarted()).toEqual(expectedAction); | ||
}); | ||
|
||
it('should create an action to create API failure', () => { | ||
const message = 'dummy message'; | ||
const expectedAction = { | ||
type: types.CREATE_API_COMMUNICATOR_FAILURE, | ||
message | ||
}; | ||
|
||
expect(actions.createApiCommunicatorFailure(message)).toEqual( | ||
expectedAction | ||
); | ||
}); | ||
|
||
it('should create an action to update API success', () => { | ||
const communicator = {}; | ||
const expectedAction = { | ||
type: types.UPDATE_API_COMMUNICATOR_SUCCESS, | ||
communicator | ||
}; | ||
expect(actions.updateApiCommunicatorSuccess(communicator)).toEqual( | ||
expectedAction | ||
); | ||
}); | ||
|
||
it('should create an action to update API started', () => { | ||
const expectedAction = { | ||
type: types.UPDATE_API_COMMUNICATOR_STARTED | ||
}; | ||
expect(actions.updateApiCommunicatorStarted()).toEqual(expectedAction); | ||
}); | ||
|
||
it('should create an action to update API failure', () => { | ||
const message = 'dummy message'; | ||
const expectedAction = { | ||
type: types.UPDATE_API_COMMUNICATOR_FAILURE, | ||
message | ||
}; | ||
|
||
expect(actions.updateApiCommunicatorFailure(message)).toEqual( | ||
expectedAction | ||
); | ||
}); | ||
}); |
23 changes: 23 additions & 0 deletions
23
src/components/Notifications/__tests__/Notifications.actions.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,23 @@ | ||
import * as actions from '../Notifications.actions'; | ||
import * as types from '../Notifications.constants'; | ||
|
||
describe('actions', () => { | ||
it('should create an action to show notifications', () => { | ||
const message = 'dummy message'; | ||
|
||
const expectedAction = { | ||
type: types.SHOW_NOTIFICATION, | ||
message, | ||
open: true | ||
}; | ||
expect(actions.showNotification(message)).toEqual(expectedAction); | ||
}); | ||
|
||
it('should create an action to hide notification', () => { | ||
const expectedAction = { | ||
type: types.HIDE_NOTIFICATION, | ||
open: false | ||
}; | ||
expect(actions.hideNotification()).toEqual(expectedAction); | ||
}); | ||
}); |
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,10 +1,44 @@ | ||
import React from 'react'; | ||
import { shallowMatchSnapshot } from '../../../common/test_utils'; | ||
import { mount } from 'enzyme'; | ||
import LockOutlinedIcon from '@material-ui/icons/LockOutlined'; | ||
import LockOpenIcon from '@material-ui/icons/LockOpen'; | ||
|
||
import { shallowMatchSnapshot } from '../../../common/test_utils'; | ||
import LockToggle from './LockToggle'; | ||
|
||
jest.mock('./LockToggle.messages', () => ({ | ||
lock: { | ||
id: 'cboard.components.LockToggle.lock', | ||
defaultMessage: 'Lock' | ||
}, | ||
unlock: { | ||
id: 'cboard.components.LockToggle.unlock', | ||
defaultMessage: 'Unlock' | ||
} | ||
})); | ||
|
||
describe('LockToggle tests', () => { | ||
test('default renderer', () => { | ||
it('default renderer', () => { | ||
shallowMatchSnapshot(<LockToggle onClick={() => {}} />); | ||
}); | ||
|
||
it('should render with unlocked icon', () => { | ||
const props = { | ||
onClick: () => {}, | ||
locked: false | ||
}; | ||
const wrapper = mount(<LockToggle {...props} />); | ||
|
||
expect(wrapper.find(LockOpenIcon)).toHaveLength(1); | ||
}); | ||
|
||
it('should render with locked icon', () => { | ||
const props = { | ||
onClick: () => {}, | ||
locked: true | ||
}; | ||
const wrapper = mount(<LockToggle {...props} />); | ||
|
||
expect(wrapper.find(LockOutlinedIcon)).toHaveLength(1); | ||
}); | ||
}); |
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
Oops, something went wrong.