forked from felixakiragreen/react-kronos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://github.com/mthuret/storybook-addon-specifications/issues/24
- Loading branch information
Laurent Roger
committed
Jan 14, 2017
1 parent
4e6b4d2
commit acae72d
Showing
6 changed files
with
122 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import '@kadira/storybook/addons'; | ||
import 'storybook-addon-specifications/register'; |
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,8 @@ | ||
import { configure } from '@kadira/storybook'; | ||
|
||
function loadStories() { | ||
require('../stories/index.js'); | ||
// You can require as many stories as you need. | ||
} | ||
|
||
configure(loadStories, module); |
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,24 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
module: { | ||
loaders: [ | ||
{ | ||
test: /\.js$/, | ||
loader: 'babel', | ||
exclude: /node_modules/, | ||
}, | ||
{ | ||
test: /\.json$/, | ||
loader: 'json', | ||
}, | ||
] | ||
}, | ||
externals: { | ||
'jsdom': 'window', | ||
'cheerio': 'window', | ||
'react/lib/ExecutionEnvironment': true, | ||
'react/lib/ReactContext': 'window', | ||
'react/addons': true, | ||
} | ||
} |
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,48 @@ | ||
import React, { Component } from 'react' | ||
import Kronos from '../dist/bundle.js' | ||
import Moment from 'moment' | ||
|
||
export default class KronosDateTime extends Component { | ||
|
||
constructor(props) { | ||
super(props) | ||
this.state = { | ||
initDateTime: Moment().toISOString(), | ||
} | ||
} | ||
|
||
onChange(datetime) { | ||
this.setState({ initDateTime: datetime,}) | ||
console.log(datetime) | ||
} | ||
|
||
render() { | ||
return ( | ||
<div className='kronos'> | ||
<Kronos | ||
date={this.state.initDateTime} | ||
onChangeDateTime={::this.onChange} | ||
placeholder={'Choisir une date'} | ||
format={'DD MMMM YYYY'} | ||
options={ | ||
{ | ||
moment: { lang: 'fr' }, | ||
} | ||
} | ||
/> | ||
<Kronos | ||
time={this.state.initDateTime} | ||
onChangeDateTime={::this.onChange} | ||
placeholder={'Choisir une heure'} | ||
format={'HH:mm'} | ||
options={ | ||
{ | ||
moment: { lang: 'fr' }, | ||
format: { hour: 'HH:mm' }, | ||
} | ||
} | ||
/> | ||
</div> | ||
) | ||
} | ||
} |
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,31 @@ | ||
import React from 'react'; | ||
import { storiesOf, action } from '@kadira/storybook'; | ||
import { specs, describe, it } from 'storybook-addon-specifications' | ||
|
||
import {mount} from 'enzyme'; | ||
import expect from 'expect'; | ||
|
||
import KronosDateTime from '../component/Kronos'; | ||
|
||
const onButtonPress = action('Button has been pressed!'); | ||
|
||
storiesOf('Kronos', module) | ||
.add('Date and Time', function() { | ||
const story = | ||
<KronosDateTime | ||
initDateTime={ new Date() } | ||
onChange={ onButtonPress } | ||
/>; | ||
|
||
specs(() => describe('Date and Time', function () { | ||
it('Should have the current date and time', function () { | ||
// Invariant Violation: addComponentAsRefTo(...): Only a ReactOwner can have refs. | ||
let output = mount(story); | ||
// works fine without the previous line | ||
const foo = 'foo'; | ||
expect(foo).toEqual('foo'); | ||
}); | ||
})); | ||
|
||
return story; | ||
}); |