Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tests/Select.combobox.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ import React from 'react';
import Select, { Option } from '../src';
import { mount, render } from 'enzyme';
import { renderToJson } from 'enzyme-to-json';
import allowClearTest from './shared/allowClearTest';

describe('Select.combobox', () => {
allowClearTest('combobox');

it('renders correctly', () => {
const wrapper = render(
<Select combobox placeholder="Search">
Expand Down
2 changes: 2 additions & 0 deletions tests/Select.multiple.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
import React from 'react';
import { mount } from 'enzyme';
import Select, { Option, OptGroup } from '../src';
import allowClearTest from './shared/allowClearTest';
import blurTest from './shared/blurTest';
import renderTest from './shared/renderTest';
import removeSelectedTest from './shared/removeSelectedTest';

describe('Select.multiple', () => {
allowClearTest('multiple');
blurTest('multiple');
renderTest('multiple');
removeSelectedTest('multiple');
Expand Down
1 change: 0 additions & 1 deletion tests/Select.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ describe('Select', () => {

it('renders correctly', () => {
const wrapper = render(select);

expect(renderToJson(wrapper)).toMatchSnapshot();
});

Expand Down
2 changes: 2 additions & 0 deletions tests/Select.tags.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import React from 'react';
import { mount } from 'enzyme';
import KeyCode from 'rc-util/lib/KeyCode';
import Select, { Option } from '../src';
import allowClearTest from './shared/allowClearTest';
import blurTest from './shared/blurTest';
import renderTest from './shared/renderTest';
import removeSelectedTest from './shared/removeSelectedTest';

jest.unmock('react-dom');

describe('Select.tags', () => {
allowClearTest('tags');
blurTest('tags');
renderTest('tags');
removeSelectedTest('tags');
Expand Down
51 changes: 51 additions & 0 deletions tests/__snapshots__/Select.combobox.spec.js.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,56 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Select.combobox allowClear renders correctly 1`] = `
<div
class="rc-select rc-select-combobox rc-select-enabled rc-select-allow-clear"
>
<div
aria-autocomplete="list"
aria-expanded="false"
aria-haspopup="true"
class="rc-select-selection
rc-select-selection--single"
role="combobox"
>
<div
class="rc-select-selection__rendered"
>
<ul>
<li
class="rc-select-search rc-select-search--inline"
>
<div
class="rc-select-search__field__wrap"
>
<input
class="rc-select-search__field"
value=""
/>
<span
class="rc-select-search__field__mirror"
>

</span>
</div>
</li>
</ul>
</div>
<span
class="rc-select-selection__clear"
style="user-select:none;-webkit-user-select:none;display:none;"
unselectable="unselectable"
/>
<span
class="rc-select-arrow"
style="user-select:none;-webkit-user-select:none;"
unselectable="unselectable"
>
<b />
</span>
</div>
</div>
`;

exports[`Select.combobox renders correctly 1`] = `
<div
class="rc-select rc-select-combobox rc-select-enabled"
Expand Down
44 changes: 44 additions & 0 deletions tests/__snapshots__/Select.multiple.spec.js.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,49 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Select.multiple allowClear renders correctly 1`] = `
<div
class="rc-select rc-select-enabled rc-select-allow-clear"
>
<div
aria-autocomplete="list"
aria-expanded="false"
aria-haspopup="true"
class="rc-select-selection
rc-select-selection--multiple"
role="combobox"
>
<div
class="rc-select-selection__rendered"
>
<ul>
<li
class="rc-select-search rc-select-search--inline"
>
<div
class="rc-select-search__field__wrap"
>
<input
class="rc-select-search__field"
value=""
/>
<span
class="rc-select-search__field__mirror"
>

</span>
</div>
</li>
</ul>
</div>
<span
class="rc-select-selection__clear"
style="user-select:none;-webkit-user-select:none;display:none;"
unselectable="unselectable"
/>
</div>
</div>
`;

exports[`Select.multiple render render animation 1`] = `
<SelectTrigger
defaultActiveFirstOption={true}
Expand Down
44 changes: 44 additions & 0 deletions tests/__snapshots__/Select.tags.spec.js.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,49 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Select.tags allowClear renders correctly 1`] = `
<div
class="rc-select rc-select-enabled rc-select-allow-clear"
>
<div
aria-autocomplete="list"
aria-expanded="false"
aria-haspopup="true"
class="rc-select-selection
rc-select-selection--multiple"
role="combobox"
>
<div
class="rc-select-selection__rendered"
>
<ul>
<li
class="rc-select-search rc-select-search--inline"
>
<div
class="rc-select-search__field__wrap"
>
<input
class="rc-select-search__field"
value=""
/>
<span
class="rc-select-search__field__mirror"
>

</span>
</div>
</li>
</ul>
</div>
<span
class="rc-select-selection__clear"
style="user-select:none;-webkit-user-select:none;display:none;"
unselectable="unselectable"
/>
</div>
</div>
`;

exports[`Select.tags render render animation 1`] = `
<SelectTrigger
defaultActiveFirstOption={true}
Expand Down
14 changes: 14 additions & 0 deletions tests/shared/allowClearTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* eslint-disable no-undef */
import React from 'react';
import { render } from 'enzyme';
import { renderToJson } from 'enzyme-to-json';
import Select from '../../src/Select';

export default function allowClearTest(mode) {
describe('allowClear', () => {
it('renders correctly', () => {
const comboboxWrapper = render(<Select {...({ [mode]: true })} allowClear />);
expect(renderToJson(comboboxWrapper)).toMatchSnapshot();
});
});
}