Skip to content

Commit

Permalink
TEST (test): add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sanusart committed Jan 8, 2019
1 parent e5cf319 commit 644bca1
Show file tree
Hide file tree
Showing 28 changed files with 3,827 additions and 48 deletions.
10 changes: 0 additions & 10 deletions .babelrc

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ dist
.idea
/src/helpers.js
.DS_Store
coverage
23 changes: 23 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
sudo: false
language: node_js

node_js:
- '10'

branches:
only:
- master

cache:
directories:
- node_modules
-
before_install:
- npm update

install:
- npm ci

script:
- npm test
- npm run coveralls
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Customisable dropdown select for react

![](https://badgen.net/bundlephobia/minzip/react-dropdown-select)
![](https://img.shields.io/npm/v/react-dropdown-select.svg)
[![Coverage Status](https://coveralls.io/repos/github/sanusart/react-dropdown-select/badge.svg?branch=master)](https://coveralls.io/github/sanusart/react-dropdown-select?branch=master)

### Installation

Expand Down
16 changes: 16 additions & 0 deletions __tests__/components/Clear.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import renderer from 'react-test-renderer';

import Clear from '../../src/components/Clear';

const props = {
parentProps: {
clearRenderer: null
}
};

it('<Clear/> renders correctly', () => {
const tree = renderer.create(<Clear {...props}/>).toJSON();

expect(tree).toMatchSnapshot();
});
24 changes: 24 additions & 0 deletions __tests__/components/Content.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';
import renderer from 'react-test-renderer';

import Content from '../../src/components/Content';

import {options} from '../../docs/src/options';

const props = {
parentProps: {
contentRenderer: null
},
parentState: {
values: options
},
parentMethods: {
getInputSize: () => undefined
}
};

it('<Content/> renders correctly', () => {
const tree = renderer.create(<Content {...props}/>).toJSON();

expect(tree).toMatchSnapshot();
});
22 changes: 22 additions & 0 deletions __tests__/components/Dropdown.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import renderer from 'react-test-renderer';

import Dropdown from '../../src/components/Dropdown';

const props = {
parentProps: {
dropdownRenderer: null,
},
parentState: {
selectBounds: {}
},
parentMethods: {
searchResults: () => []
}
};

it('<Dropdown/> renders correctly', () => {
const tree = renderer.create(<Dropdown {...props}/>).toJSON();

expect(tree).toMatchSnapshot();
});
19 changes: 19 additions & 0 deletions __tests__/components/DropdownHandle.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import renderer from 'react-test-renderer';

import DropdownHandle from '../../src/components/DropdownHandle';

const props = {
parentProps: {
dropdownHandleRenderer: null
},
parentState: {
dropdown: false
}
};

it('<DropdownHandle/> renders correctly', () => {
const tree = renderer.create(<DropdownHandle {...props}/>).toJSON();

expect(tree).toMatchSnapshot();
});
23 changes: 23 additions & 0 deletions __tests__/components/Input.spec.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 Input from '../../src/components/Input';
import { options } from '../../docs/src/options';

const props = {
parentProps: {
inputRenderer: null
},
parentState: {
values: options
},
parentMethods: {
getInputSize: () => undefined
}
};

it('<Input/> renders correctly', () => {
const tree = renderer.create(<Input {...props}/>).toJSON();

expect(tree).toMatchSnapshot();
});
25 changes: 25 additions & 0 deletions __tests__/components/Item.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react';
import renderer from 'react-test-renderer';

import Item from '../../src/components/Item';

import {options} from '../../docs/src/options';

const props = {
item: options[0],
parentProps: {
itemRenderer: null
},
parentState: {
cursor: 0
},
parentMethods: {
isSelected: () => undefined
}
};

it('<Item/> renders correctly', () => {
const tree = renderer.create(<Item {...props}/>).toJSON();

expect(tree).toMatchSnapshot();
});
16 changes: 16 additions & 0 deletions __tests__/components/Loading.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import renderer from 'react-test-renderer';

import Loading from '../../src/components/Loading';

const props = {
parentProps: {
loadingRenderer: null
}
};

it('<Loading/> renders correctly', () => {
const tree = renderer.create(<Loading {...props}/>).toJSON();

expect(tree).toMatchSnapshot();
});
16 changes: 16 additions & 0 deletions __tests__/components/NoData.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import renderer from 'react-test-renderer';

import NoData from '../../src/components/NoData';

const props = {
parentProps: {
noDataRenderer: null
}
};

it('<NoData/> renders correctly', () => {
const tree = renderer.create(<NoData {...props}/>).toJSON();

expect(tree).toMatchSnapshot();
});
19 changes: 19 additions & 0 deletions __tests__/components/Option.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import renderer from 'react-test-renderer';

import Option from '../../src/components/Option';

import {options} from '../../docs/src/options';

const props = {
parentItem: options[0],
parentProps: {
optionRenderer: null
}
};

it('<Option/> renders correctly', () => {
const tree = renderer.create(<Option {...props}/>).toJSON();

expect(tree).toMatchSnapshot();
});
16 changes: 16 additions & 0 deletions __tests__/components/Separator.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import renderer from 'react-test-renderer';

import Separator from '../../src/components/Separator';

const props = {
parentProps: {
separatorRenderer: null
}
};

it('<Separator/> renders correctly', () => {
const tree = renderer.create(<Separator {...props}/>).toJSON();

expect(tree).toMatchSnapshot();
});
12 changes: 12 additions & 0 deletions __tests__/components/__snapshots__/Clear.spec.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<Clear/> renders correctly 1`] = `
<div
className="css-x3l5ce-ClearComponent e11qlq5e0"
onClick={[Function]}
onKeyPress={[Function]}
tabIndex="-1"
>
×
</div>
`;
15 changes: 15 additions & 0 deletions __tests__/components/__snapshots__/Content.spec.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<Content/> renders correctly 1`] = `
<div
className="react-dropdown-select-content react-dropdown-select-type-single css-rpdrp-ContentComponent e1gn6jc30"
onClick={[Function]}
>
<span />
<input
className="react-dropdown-select-input css-1bc66r-InputComponent e11wid6y0"
onClick={[Function]}
tabIndex="-1"
/>
</div>
`;
14 changes: 14 additions & 0 deletions __tests__/components/__snapshots__/Dropdown.spec.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<Dropdown/> renders correctly 1`] = `
<div
aria-expanded="true"
className="react-dropdown-select-dropdown css-k5q2zn-DropDown e1qjn9k90"
role="list"
tabIndex="-1"
>
<div
className="css-1lli8k7-NoDataComponent e1l5ho1t0"
/>
</div>
`;
23 changes: 23 additions & 0 deletions __tests__/components/__snapshots__/DropdownHandle.spec.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<DropdownHandle/> renders correctly 1`] = `
<div
className="react-dropdown-select-dropdown-handle css-2zkru-DropdownHandleComponent e1vudypg0"
onClick={[Function]}
onKeyDown={[Function]}
onKeyPress={[Function]}
tabIndex="-1"
>
<svg
fill="currentColor"
preserveAspectRatio="xMidYMid meet"
viewBox="0 0 40 40"
>
<g>
<path
d="m31 26.4q0 0.3-0.2 0.5l-1.1 1.2q-0.3 0.2-0.6 0.2t-0.5-0.2l-8.7-8.8-8.8 8.8q-0.2 0.2-0.5 0.2t-0.5-0.2l-1.2-1.2q-0.2-0.2-0.2-0.5t0.2-0.5l10.4-10.4q0.3-0.2 0.6-0.2t0.5 0.2l10.4 10.4q0.2 0.2 0.2 0.5z"
/>
</g>
</svg>
</div>
`;
9 changes: 9 additions & 0 deletions __tests__/components/__snapshots__/Input.spec.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<Input/> renders correctly 1`] = `
<input
className="react-dropdown-select-input css-1bc66r-InputComponent e11wid6y0"
onClick={[Function]}
tabIndex="-1"
/>
`;
13 changes: 13 additions & 0 deletions __tests__/components/__snapshots__/Item.spec.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<Item/> renders correctly 1`] = `
<span
className="react-dropdown-select-item null css-7av8hz-ItemComponent evc32pp0"
onClick={[Function]}
onKeyPress={[Function]}
role="option"
tabIndex="-1"
>
</span>
`;
7 changes: 7 additions & 0 deletions __tests__/components/__snapshots__/Loading.spec.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<Loading/> renders correctly 1`] = `
<div
className="react-dropdown-select-loading css-k8dcp9-LoadingComponent e1l5cpc30"
/>
`;
7 changes: 7 additions & 0 deletions __tests__/components/__snapshots__/NoData.spec.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<NoData/> renders correctly 1`] = `
<div
className="css-1lli8k7-NoDataComponent e1l5ho1t0"
/>
`;
18 changes: 18 additions & 0 deletions __tests__/components/__snapshots__/Option.spec.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<Option/> renders correctly 1`] = `
<span
className="react-dropdown-select-option css-1sb8fud-OptionComponent e1l4eby50"
role="listitem"
>
<span
className="react-dropdown-select-option-label"
/>
<span
className="react-dropdown-select-option-remove"
onClick={[Function]}
>
×
</span>
</span>
`;
7 changes: 7 additions & 0 deletions __tests__/components/__snapshots__/Separator.spec.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<Separator/> renders correctly 1`] = `
<div
className="react-dropdown-select-separator css-vxbae9-SeparatorComponent e19h5j1v0"
/>
`;
10 changes: 10 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
plugins: [
"emotion",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-syntax-dynamic-import",
"transform-dynamic-import"
],
presets: ['@babel/preset-env', '@babel/preset-react']
};

0 comments on commit 644bca1

Please sign in to comment.