This repository was archived by the owner on Mar 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLabelElement.test.js
More file actions
66 lines (54 loc) · 1.52 KB
/
LabelElement.test.js
File metadata and controls
66 lines (54 loc) · 1.52 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
/* @flow */
/*
import React from 'react';
import renderer from 'react-test-renderer';
import { shallow } from 'enzyme';
import LabelElement from './LabelElement';
import type { LabelElementProps } from './types';
describe('<LabelElement />', () => {
let wrapper;
const defaultProps = {
htmlFor: 'INPUT_ID',
text: 'FIELD_LABEL',
};
const shallowWithProps = (props: LabelElementProps = defaultProps) => {
wrapper = shallow(
<LabelElement {...props} />
);
};
const AnyChild = () => <div>AnyChild</div>;
describe('html element', () => {
it('should be label', () => {
shallowWithProps();
expect(wrapper.name()).toBe('label');
});
it('should have htmlFor attribute', () => {
shallowWithProps();
expect(wrapper.props().htmlFor).toBeDefined();
expect(wrapper.props().htmlFor).toEqual('INPUT_ID');
});
});
describe('content', () => {
it('should have FIELD_LABEL text', () => {
shallowWithProps();
expect(wrapper.text()).toEqual('FIELD_LABEL');
});
it('should have {children} if passed', () => {
wrapper = shallow(
<LabelElement {...defaultProps}>
<AnyChild />
</LabelElement>
);
expect(wrapper.find(AnyChild).length).toBe(1);
});
it('should render {children} before label text', () => {
wrapper = renderer.create(
<LabelElement {...defaultProps}>
<AnyChild />
</LabelElement>
);
expect(wrapper.toJSON()).toMatchSnapshot();
});
});
});
*/