1
- import { render } from ' @ember/test-helpers' ;
1
+ import { findAll , render } from ' @ember/test-helpers' ;
2
2
import { module , test } from ' qunit' ;
3
3
4
4
import Field from ' @crowdstrike/ember-toucan-core/components/form/field' ;
@@ -58,9 +58,9 @@ module('Integration | Component | Field', function (hooks) {
58
58
assert .dom (hint ).exists (' Expected to have hint text rendered' );
59
59
assert .dom (hint ).hasText (' hint' , ' Expected to have hint text "hint"' );
60
60
61
- let childDivs = document . querySelectorAll (' [data-test-field] > div' );
61
+ let children = findAll (' [data-test-field] > div' );
62
62
assert .strictEqual (
63
- childDivs .length ,
63
+ children .length ,
64
64
2 ,
65
65
' Expect 1 div for hint, 1 div for error'
66
66
);
@@ -102,22 +102,24 @@ module('Integration | Component | Field', function (hooks) {
102
102
.hasText (' error' , ' Expected to have error text rendered' );
103
103
});
104
104
105
- // TODO: Checkpoint: finish this
106
105
test (' it renders conditionally' , async function (assert ) {
107
106
await render (<template >
108
- <Field as | field | >
109
- <field.Label >label</field.Label >
110
- <field.Hint ><span data-test-hint >hint</span ></field.Hint >
111
- <field.Control >
112
- <input type =" text" data-test-input />
113
- </field.Control >
114
- </Field >
107
+ <div data-test-field >
108
+ <Field as | field | >
109
+ <field.Label >label</field.Label >
110
+ <field.Hint ><span data-test-hint >hint</span ></field.Hint >
111
+ <field.Control >
112
+ <input type =" text" data-test-input />
113
+ </field.Control >
114
+ </Field >
115
+ </div >
115
116
</template >);
116
117
117
118
const label = ' label' ;
118
119
const hint = ' [data-test-hint]' ;
119
120
const error = ' [data-test-error]' ;
120
121
const control = ' [data-test-input]' ;
122
+ const children = findAll (' [data-test-field] > div' );
121
123
122
124
assert .dom (label ).exists (' Expected to have label block rendered' );
123
125
assert .dom (label ).hasText (' label' , ' Expected to have label text "label"' );
@@ -130,9 +132,12 @@ module('Integration | Component | Field', function (hooks) {
130
132
assert
131
133
.dom (' svg' )
132
134
.doesNotExist (' Error block does not exist (no error icon shown)' );
133
- assert
134
- .dom (error )
135
- .hasText (' error' , ' Expected to have error text rendered' );
135
+
136
+ assert .strictEqual (
137
+ children .length ,
138
+ 1 ,
139
+ ' Form only has div which is the hint'
140
+ );
136
141
});
137
142
});
138
143
});
0 commit comments