File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
src/components/label/__tests__ Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 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+ } ) ;
You can’t perform that action at this time.
0 commit comments