-
Notifications
You must be signed in to change notification settings - Fork 831
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 #317 from tkachenko-tatiana/develop
Today button implementation
- Loading branch information
Showing
13 changed files
with
223 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
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,16 +1,86 @@ | ||
import React from 'react'; | ||
import { shallow } from '../test-utils'; | ||
import ModalDialog from '../../src/_shared/ModalDialog'; | ||
import { ModalDialog } from '../../src/_shared/ModalDialog'; | ||
|
||
const initialProps = { | ||
onAccept: jest.fn(), | ||
onDismiss: jest.fn(), | ||
onClear: jest.fn(), | ||
okLabel: 'OK', | ||
cancelLabel: 'Cancel', | ||
clearLabel: 'Clear', | ||
clearable: false, | ||
todayLabel: 'Today', | ||
showTodayButton: false, | ||
onSetToday: jest.fn(), | ||
classes: {}, | ||
children: 'Test', | ||
}; | ||
|
||
describe('ModalDialog', () => { | ||
let component; | ||
const props = { ...initialProps }; | ||
|
||
beforeEach(() => { | ||
component = shallow(<ModalDialog />); | ||
component = shallow(<ModalDialog {...props} />); | ||
}); | ||
|
||
it('Should renders', () => { | ||
// console.log(component.debug()); | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('Should render dialog content', () => { | ||
expect(component.find('WithStyles(DialogContent)').props().children).toBe(props.children); | ||
}); | ||
|
||
it('Should render dialog actions with 2 buttons', () => { | ||
expect(component.find('WithStyles(DialogActions)').length).toBe(1); | ||
expect(component.find('WithStyles(Button)').at(0).props().children).toBe('Cancel'); | ||
expect(component.find('WithStyles(Button)').at(1).props().children).toBe('OK'); | ||
}); | ||
|
||
it('Should handle on OK button click', () => { | ||
component.find('WithStyles(Button)').at(1).simulate('click'); | ||
expect(props.onAccept).toHaveBeenCalled(); | ||
}); | ||
|
||
it('Should handle on Cancel button click', () => { | ||
component.find('WithStyles(Button)').at(0).simulate('click'); | ||
expect(props.onDismiss).toHaveBeenCalled(); | ||
}); | ||
}); | ||
|
||
describe('ModalDialog with Clear Button', () => { | ||
let component; | ||
const props = { | ||
...initialProps, | ||
clearable: true, | ||
}; | ||
|
||
beforeEach(() => { | ||
component = shallow(<ModalDialog {...props} />); | ||
}); | ||
|
||
it('Should handle on Clear button click', () => { | ||
component.find('WithStyles(Button)').at(0).simulate('click'); | ||
expect(props.onClear).toHaveBeenCalled(); | ||
}); | ||
}); | ||
|
||
describe('ModalDialog with Today Button', () => { | ||
let component; | ||
const props = { | ||
...initialProps, | ||
showTodayButton: true, | ||
}; | ||
|
||
beforeEach(() => { | ||
component = shallow(<ModalDialog {...props} />); | ||
}); | ||
|
||
it('Should handle on Clear button click', () => { | ||
component.find('WithStyles(Button)').at(0).simulate('click'); | ||
expect(props.onSetToday).toHaveBeenCalled(); | ||
}); | ||
}); |
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
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.