-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Expand file tree
/
Copy pathindex.test.jsx
More file actions
67 lines (58 loc) · 1.62 KB
/
index.test.jsx
File metadata and controls
67 lines (58 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { render } from '@testing-library/react';
import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import Select from '..';
const noop = () => {};
describe('Select', () => {
const values = ['Option 1', 'Option 2', 'Option 3'];
const defaultValue = 'Option 1';
const placeholder = 'Select an option';
const dropdownLabel = 'Dropdown label';
const label = 'Option label';
global.ResizeObserver = class {
observe = noop;
unobserve = noop;
disconnect = noop;
};
it('renders the label when provided', () => {
const { getByLabelText } = render(
<Select
values={values}
value={defaultValue}
placeholder={placeholder}
dropdownLabel={dropdownLabel}
label={label}
onChange={noop}
/>
);
const element = getByLabelText(label);
assert.ok(element.ownerDocument);
});
it('renders the default value when provided', () => {
const { getByText } = render(
<Select
values={values}
value={defaultValue}
placeholder={placeholder}
dropdownLabel={dropdownLabel}
label={label}
onChange={noop}
/>
);
const element = getByText(defaultValue);
assert.ok(element.ownerDocument);
});
it('renders the placeholder when default value is not provided', () => {
const { getByText } = render(
<Select
values={values}
placeholder={placeholder}
dropdownLabel={dropdownLabel}
label={label}
onChange={noop}
/>
);
const element = getByText(placeholder);
assert.ok(element.ownerDocument);
});
});