This repository has been archived by the owner on May 31, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
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 #263 from mkermani144/feature/startup-tab
Feature/startup tab
- Loading branch information
Showing
13 changed files
with
215 additions
and
22 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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React, { Component } from 'react'; | ||
import Dialog from 'material-ui/Dialog'; | ||
import { RadioButton, RadioButtonGroup } from 'material-ui/RadioButton'; | ||
import FlatButton from 'material-ui/FlatButton'; | ||
import { blue500, grey50 } from 'material-ui/styles/colors'; | ||
|
||
class StartupTabDialog extends Component { | ||
handleRequestClose = (e, target) => { | ||
setTimeout(() => { | ||
this.props.onRequestClose(target); | ||
}, 300); | ||
} | ||
render() { | ||
const actions = [ | ||
<FlatButton | ||
label="Cancel" | ||
primary | ||
onClick={() => this.props.onRequestClose(this.props.startupTab)} | ||
/>, | ||
]; | ||
const dialogContentStyle = { | ||
maxWidth: 256, | ||
}; | ||
const radioButtonStyle = { | ||
marginTop: 16, | ||
}; | ||
const dialogTitleStyle = { | ||
backgroundColor: blue500, | ||
color: grey50, | ||
}; | ||
return ( | ||
<Dialog | ||
title="Startup tab" | ||
titleStyle={dialogTitleStyle} | ||
contentStyle={dialogContentStyle} | ||
actions={actions} | ||
open={this.props.open} | ||
onRequestClose={() => this.props.onRequestClose(this.props.startupTab)} | ||
> | ||
<RadioButtonGroup | ||
name="startupTab" | ||
defaultSelected={this.props.startupTab} | ||
onChange={this.handleRequestClose} | ||
> | ||
<RadioButton | ||
label="tasks" | ||
value="tasks" | ||
style={radioButtonStyle} | ||
/> | ||
<RadioButton | ||
label="ideas" | ||
value="ideas" | ||
style={radioButtonStyle} | ||
/> | ||
</RadioButtonGroup> | ||
</Dialog> | ||
); | ||
} | ||
} | ||
|
||
export default StartupTabDialog; |
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,61 @@ | ||
/* eslint-env mocha, jest */ | ||
|
||
import getActualComponentFactory from '../../lib/testUtils'; | ||
import StartupTabDialog from '../StartupTabDialog'; | ||
|
||
const defaultProps = { | ||
open: false, | ||
startupTab: 'tasks', | ||
onRequestClose() {}, | ||
}; | ||
const getActualDialog = getActualComponentFactory(StartupTabDialog, defaultProps); | ||
|
||
jest.useFakeTimers(); | ||
|
||
it('should render', () => { | ||
getActualDialog(); | ||
}); | ||
it('should be a Dialog', () => { | ||
const wrapper = getActualDialog(); | ||
expect(wrapper.is('Dialog')).toBe(true); | ||
}); | ||
it('should have 2 RadioButton', () => { | ||
const wrapper = getActualDialog(); | ||
expect(wrapper.find('RadioButton').length).toBe(2); | ||
}); | ||
it('should set Dialog open based on props', () => { | ||
const wrapper = getActualDialog({ open: true }); | ||
expect(wrapper.find('Dialog').prop('open')).toBe(true); | ||
}); | ||
it('should set RadioButtonGroup defaultSelected based on props', () => { | ||
const wrapper = getActualDialog({ startupTab: 'ideas' }); | ||
expect(wrapper.find('RadioButtonGroup').prop('defaultSelected')).toBe('ideas'); | ||
}); | ||
it('should call onRequestClose inside Dialog onRequestClose', () => { | ||
const wrapper = getActualDialog({ | ||
startupTab: 'ideas', | ||
onRequestClose(startupTab) { | ||
expect(startupTab).toBe('ideas'); | ||
}, | ||
}); | ||
wrapper.find('Dialog').props().onRequestClose(); | ||
}); | ||
it('should call onRequestClose inside FlatButton onClick', () => { | ||
const wrapper = getActualDialog({ | ||
startupTab: 'ideas', | ||
onRequestClose(startupTab) { | ||
expect(startupTab).toBe('ideas'); | ||
}, | ||
}); | ||
wrapper.find('Dialog').prop('actions')[0].props.onClick(); | ||
}); | ||
it('should call onRequestClose inside RadioButtonGroup onChange', () => { | ||
const wrapper = getActualDialog({ | ||
startupTab: 'ideas', | ||
onRequestClose(startupTab) { | ||
expect(startupTab).toBe('ideas'); | ||
}, | ||
}); | ||
wrapper.find('RadioButtonGroup').props().onChange(null, 'ideas'); | ||
jest.runAllTimers(); | ||
}); |
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.