-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/cld 236 camera image upload component (#52)
- Loading branch information
NghiaPham
authored
Sep 11, 2019
1 parent
63ec2be
commit 6d556c9
Showing
9 changed files
with
117 additions
and
10 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
src/components/CamaraImageInput/__tests__/__snapshots__/index.tsx.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,14 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`CameraImageInput should match a snapshot 1`] = ` | ||
<Component | ||
id="test" | ||
inputProps={ | ||
Object { | ||
"capture": "camera", | ||
} | ||
} | ||
labelText="test" | ||
name="test" | ||
/> | ||
`; |
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 * as React from 'react' | ||
import { shallow } from 'enzyme' | ||
import { FileInputProps } from '../../FileInput' | ||
import { CameraImageInput } from '../index' | ||
import toJson from 'enzyme-to-json' | ||
|
||
const props: FileInputProps = { | ||
name: 'test', | ||
id: 'test', | ||
labelText: 'test' | ||
} | ||
|
||
describe('CameraImageInput', () => { | ||
it('should match a snapshot', () => { | ||
expect(toJson(shallow(<CameraImageInput {...props} />))).toMatchSnapshot() | ||
}) | ||
|
||
afterEach(() => { | ||
jest.resetAllMocks() | ||
}) | ||
}) |
24 changes: 24 additions & 0 deletions
24
src/components/CamaraImageInput/camera-image-input.stories.tsx
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 @@ | ||
import React from 'react' | ||
|
||
import { storiesOf } from '@storybook/react' | ||
import { action } from '@storybook/addon-actions' | ||
import { CameraImageInput } from '.' | ||
import { Form, Formik } from 'formik' | ||
|
||
storiesOf('form/CameraImageInput', module).add('Camera Image Input', () => ( | ||
<section className="section"> | ||
<Formik | ||
initialValues={{ imageInput: '' }} | ||
onSubmit={values => { | ||
action('Form Values' + values) | ||
}} | ||
render={() => ( | ||
<Form> | ||
<div className="column is-half-desktop"> | ||
<CameraImageInput id="imageInput" allowClear name="imageInput" labelText="Image Input" /> | ||
</div> | ||
</Form> | ||
)} | ||
/> | ||
</section> | ||
)) |
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,15 @@ | ||
import React from 'react' | ||
import { FileInput, FileInputProps } from '../FileInput' | ||
|
||
export const CameraImageInput = (props: FileInputProps) => ( | ||
<FileInput | ||
inputProps={{ | ||
capture: 'camera' | ||
}} | ||
dataTest={props.dataTest} | ||
name={props.name} | ||
labelText={props.labelText} | ||
id={props.id} | ||
allowClear={props.allowClear} | ||
/> | ||
) |
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