@@ -17,14 +17,15 @@ describe('Input', () => {
17
17
$label = document . querySelector ( '.govuk-label' )
18
18
} )
19
19
20
- it ( 'sets the `id` attribute based on the `id` option' , ( ) => {
21
- expect ( $component ) . toHaveAttribute ( 'id' , 'input-example' )
22
- } )
23
-
24
20
it ( 'sets the `name` attribute based on the `name` option' , ( ) => {
25
21
expect ( $component ) . toHaveAttribute ( 'name' , 'test-name' )
26
22
} )
27
23
24
+ it ( 'sets the `id` attribute based on the `name` option' , ( ) => {
25
+ const inputName = $component . getAttribute ( 'name' )
26
+ expect ( $component ) . toHaveAttribute ( 'id' , inputName )
27
+ } )
28
+
28
29
it ( 'sets the `type` attribute to a default value of "text"' , ( ) => {
29
30
expect ( $component ) . toHaveAttribute ( 'type' , 'text' )
30
31
} )
@@ -65,6 +66,13 @@ describe('Input', () => {
65
66
} )
66
67
67
68
describe ( 'custom options' , ( ) => {
69
+ it ( 'sets the `id` attribute based on the `id` option' , ( ) => {
70
+ document . body . innerHTML = render ( 'input' , examples . id )
71
+
72
+ const $component = document . querySelector ( '.govuk-input' )
73
+ expect ( $component ) . toHaveAttribute ( 'id' , 'test-id' )
74
+ } )
75
+
68
76
it ( 'includes additional classes from the `classes` option' , ( ) => {
69
77
document . body . innerHTML = render ( 'input' , examples . classes )
70
78
0 commit comments