Skip to content

Commit fd61e2b

Browse files
ClarkeCDCChristian Clarke
andauthored
Add tests for Label Component (#122)
Co-authored-by: Christian Clarke <[email protected]>
1 parent 6db7a3e commit fd61e2b

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React from 'react';
2+
import { shallow } from 'enzyme';
3+
import Label from '../Label';
4+
5+
describe('Label', () => {
6+
it('Label', () => {
7+
const element = shallow(<Label>Text</Label>);
8+
expect(element.children().text()).toBe('Text')
9+
/*
10+
Need to do .html as BaseLabel is used in Label.
11+
I don't think snapshots is the best way to do this
12+
*/
13+
expect(element.html()).toBe('<label class="nhsuk-label">Text</label>')
14+
element.unmount();
15+
});
16+
17+
it('Label with size m', () => {
18+
const element = shallow(<Label size='m'>Text</Label>);
19+
expect(element.children().text()).toBe('Text')
20+
/*
21+
Need to do .html as BaseLabel is used in Label.
22+
I don't think snapshots is the best way to do this
23+
*/
24+
expect(element.html()).toBe('<label class="nhsuk-label nhsuk-label--m">Text</label>')
25+
element.unmount();
26+
});
27+
28+
it('Label with heading prop', () => {
29+
const element = shallow(<Label isPageHeading>Text</Label>);
30+
expect(element.children().children().text()).toBe('Text')
31+
/*
32+
Need to do .html as BaseLabel is used in Label.
33+
I don't think snapshots is the best way to do this
34+
*/
35+
expect(element.html()).toBe('<h1 class="nhsuk-label-wrapper"><label class="nhsuk-label nhsuk-label--xl">Text</label></h1>')
36+
element.unmount();
37+
});
38+
39+
});

0 commit comments

Comments
 (0)