Last active
September 19, 2018 09:04
-
-
Save ihorkatkov/e8ff9e29e8ac64ef9ad1e4c28d64f8f2 to your computer and use it in GitHub Desktop.
Story example
This file contains hidden or 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
import React from 'react' | |
import { storiesOf, action } from '@storybook/react' | |
import Component from '../../../src/components/MunicipalitySelect/index' | |
import Provider from '../../../src/test/MockedApolloProvider' | |
const defaultValue = { | |
id: 'TG9jYXRpb246MzA=', | |
name: 'Vestby', | |
slug: 'vestby_akershus_municipality', | |
__typename: 'Location', | |
} | |
const resolvers = { | |
RootQueryType: { | |
locationsByParentId: () => [ | |
{ | |
slug: 'akershus_county', | |
name: 'Akershus', | |
id: 'TG9jYXRpb246Mjk=', | |
children: [ | |
{ | |
slug: 'vestby_akershus_municipality', | |
name: 'Vestby', | |
id: 'TG9jYXRpb246MzA=', | |
__typename: 'Location', | |
}, | |
], | |
__typename: 'Location', | |
}, | |
{ | |
slug: 'oslo_county', | |
name: 'Oslo', | |
id: 'TG9jYXRpb246NTI=', | |
children: [ | |
{ | |
slug: 'oslo_oslo_municipality', | |
name: 'Oslo', | |
id: 'TG9jYXRpb246NTM=', | |
__typename: 'Location', | |
}, | |
], | |
__typename: 'Location', | |
}, | |
], | |
}, | |
} | |
storiesOf('MunicipalitySelect', module) | |
.addDecorator(story => <Provider story={story()} resolvers={resolvers} />) | |
.add('default', () => <Component onChange={action('onChange')} />) | |
.add('with default value', () => ( | |
<Component onChange={action('onChange')} defaultValue={defaultValue} /> | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment