Skip to content
This repository has been archived by the owner on Oct 27, 2022. It is now read-only.

Commit

Permalink
add tests and pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkuz committed Sep 18, 2016
1 parent 0e7d1ed commit 08425d2
Show file tree
Hide file tree
Showing 22 changed files with 569 additions and 10 deletions.
6 changes: 6 additions & 0 deletions __tests__/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"env": {
"node": true,
"jest": true
}
}
23 changes: 23 additions & 0 deletions __tests__/Autocomplete.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import renderer from 'react-test-renderer';
import Autocomplete from '../src/Autocomplete';

describe('Autocomplete', () => {
it('renders correctly with function child', () => {
const tree = renderer.create(
<Autocomplete value='test' options={['test1', 'test2']}>
{props => <input {...props} />}
</Autocomplete>
).toJSON();
expect(tree).toMatchSnapshot();
});

it('renders correctly with element child', () => {
const tree = renderer.create(
<Autocomplete value='test' options={['test1', 'test2']}>
<input />
</Autocomplete>
).toJSON();
expect(tree).toMatchSnapshot();
});
});
23 changes: 23 additions & 0 deletions __tests__/Autosize.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import renderer from 'react-test-renderer';
import Autosize from '../src/Autosize';

describe('Autosize', () => {
it('renders correctly with function child', () => {
const tree = renderer.create(
<Autosize value='test'>
{props => <input {...props} />}
</Autosize>
).toJSON();
expect(tree).toMatchSnapshot();
});

it('renders correctly with element child', () => {
const tree = renderer.create(
<Autosize value='test'>
<input />
</Autosize>
).toJSON();
expect(tree).toMatchSnapshot();
});
});
23 changes: 23 additions & 0 deletions __tests__/Combobox.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import renderer from 'react-test-renderer';
import Combobox from '../src/Combobox';

describe('Combobox', () => {
it('renders correctly with function child', () => {
const tree = renderer.create(
<Combobox value='test' options={['test1', 'test2']} autosize autocomplete>
{props => <input {...props} />}
</Combobox>
).toJSON();
expect(tree).toMatchSnapshot();
});

it('renders correctly with element child', () => {
const tree = renderer.create(
<Combobox value='test' options={['test1', 'test2']} autosize autocomplete>
<input />
</Combobox>
).toJSON();
expect(tree).toMatchSnapshot();
});
});
30 changes: 30 additions & 0 deletions __tests__/DatePicker.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';
import renderer from 'react-test-renderer';
import DatePicker from '../src/DatePicker';
import moment from 'moment';

const now = moment(0);

describe('DatePicker', () => {
it('renders correctly with function child', () => {
const tree = renderer.create(
<DatePicker
value={now.format('ddd DD/MM/YYYY')}
>
{props => <input {...props} />}
</DatePicker>
).toJSON();
expect(tree).toMatchSnapshot();
});

it('renders correctly with element child', () => {
const tree = renderer.create(
<DatePicker
value={now.format('ddd DD/MM/YYYY')}
>
<input />
</DatePicker>
).toJSON();
expect(tree).toMatchSnapshot();
});
});
23 changes: 23 additions & 0 deletions __tests__/Dropdown.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import renderer from 'react-test-renderer';
import Dropdown from '../src/Dropdown';

describe('Dropdown', () => {
it('renders correctly with function child', () => {
const tree = renderer.create(
<Dropdown value='test' options={['test1', 'test2']}>
{props => <input {...props} />}
</Dropdown>
).toJSON();
expect(tree).toMatchSnapshot();
});

it('renders correctly with element child', () => {
const tree = renderer.create(
<Dropdown value='test' options={['test1', 'test2']}>
<input />
</Dropdown>
).toJSON();
expect(tree).toMatchSnapshot();
});
});
23 changes: 23 additions & 0 deletions __tests__/Mask.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import renderer from 'react-test-renderer';
import Mask from '../src/Mask';

describe('Mask', () => {
it('renders correctly with function child', () => {
const tree = renderer.create(
<Mask value='123' pattern='0-0-0'>
{props => <input {...props} />}
</Mask>
).toJSON();
expect(tree).toMatchSnapshot();
});

it('renders correctly with element child', () => {
const tree = renderer.create(
<Mask value='123' pattern='0-0-0'>
<input />
</Mask>
).toJSON();
expect(tree).toMatchSnapshot();
});
});
13 changes: 13 additions & 0 deletions __tests__/__snapshots__/Autocomplete.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
exports[`Autocomplete renders correctly with element child 1`] = `
<input
onChange={[Function anonymous]}
onKeyDown={[Function anonymous]}
value="test" />
`;

exports[`Autocomplete renders correctly with function child 1`] = `
<input
onChange={[Function anonymous]}
onKeyDown={[Function anonymous]}
value="test" />
`;
15 changes: 15 additions & 0 deletions __tests__/__snapshots__/Autosize.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
exports[`Autosize renders correctly with element child 1`] = `
<input
onChange={[Function anonymous]}
placeholder={undefined}
style={Object {}}
value="test" />
`;

exports[`Autosize renders correctly with function child 1`] = `
<input
onChange={[Function anonymous]}
placeholder={undefined}
style={Object {}}
value="test" />
`;
103 changes: 103 additions & 0 deletions __tests__/__snapshots__/Combobox.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
exports[`Combobox renders correctly with element child 1`] = `
<div
onBlur={[Function anonymous]}
onFocus={[Function anonymous]}
style={
Object {
"display": "inline-block",
"position": "relative"
}
}>
<input
onBlur={undefined}
onChange={[Function anonymous]}
onFocus={undefined}
onInput={undefined}
onKeyDown={[Function anonymous]}
onMouseEnter={[Function anonymous]}
onMouseLeave={[Function anonymous]}
placeholder={undefined}
style={Object {}}
value="test1" />
<div
style={
Object {
"paddingLeft": "3px",
"paddingTop": "5px",
"position": "absolute",
"right": "5px",
"top": 0,
"verticalAlign": "middle",
"width": "10px"
}
}>
<svg
fill="currentColor"
height="5"
style={
Object {
"display": "inline-block",
"opacity": 0,
"transform": "translateY(5px)",
"transition": "opacity 0.15s linear, transform 0.15s linear"
}
}
width="10">
<path
d="M0 0 H10 L5 5 z" />
</svg>
</div>
</div>
`;

exports[`Combobox renders correctly with function child 1`] = `
<div
onBlur={[Function anonymous]}
onFocus={[Function anonymous]}
style={
Object {
"display": "inline-block",
"position": "relative"
}
}>
<input
onBlur={undefined}
onChange={[Function anonymous]}
onFocus={undefined}
onInput={undefined}
onKeyDown={[Function anonymous]}
onMouseEnter={[Function anonymous]}
onMouseLeave={[Function anonymous]}
placeholder={undefined}
style={Object {}}
value="test1" />
<div
style={
Object {
"paddingLeft": "3px",
"paddingTop": "5px",
"position": "absolute",
"right": "5px",
"top": 0,
"verticalAlign": "middle",
"width": "10px"
}
}>
<svg
fill="currentColor"
height="5"
style={
Object {
"display": "inline-block",
"opacity": 0,
"transform": "translateY(5px)",
"transition": "opacity 0.15s linear, transform 0.15s linear"
}
}
width="10">
<path
d="M0 0 H10 L5 5 z" />
</svg>
</div>
</div>
`;
Loading

0 comments on commit 08425d2

Please sign in to comment.