Skip to content

Commit 47a8e12

Browse files
committed
Fix failing tests
1 parent f83a186 commit 47a8e12

File tree

3 files changed

+25
-27
lines changed

3 files changed

+25
-27
lines changed

test/renderers/array-renderer.test.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,11 @@ test('generate array child control', t => {
6868
const legend = fieldsetChildren.item(0);
6969
t.is(legend.tagName, 'LEGEND');
7070
const legendChildren = legend.children;
71-
const label = legendChildren.item(0);
71+
const label = legendChildren.item(1);
7272
t.is(label.tagName, 'LABEL');
7373
t.is(label.innerHTML, 'Test');
74-
const button = legendChildren.item(1);
74+
const button = legendChildren.item(0);
7575
t.is(button.tagName, 'BUTTON');
76-
t.is(button.innerHTML, 'Add to Test');
7776
const children = fieldsetChildren.item(1);
7877
t.is(children.tagName, 'DIV');
7978
t.is(children.className, 'children');
@@ -118,12 +117,11 @@ test('generate array child control w/o data', t => {
118117
const legend = fieldsetChildren.item(0);
119118
t.is(legend.tagName, 'LEGEND');
120119
const legendChildren = legend.children;
121-
const label = legendChildren.item(0);
120+
const label = legendChildren.item(1);
122121
t.is(label.tagName, 'LABEL');
123122
t.is(label.innerHTML, '');
124-
const button = legendChildren.item(1);
123+
const button = legendChildren.item(0);
125124
t.is(button.tagName, 'BUTTON');
126-
t.is(button.innerHTML, 'Add to Test');
127125
const children = fieldsetChildren.item(1);
128126
t.is(children.tagName, 'DIV');
129127
t.is(children.className, 'children');

test/renderers/base.control.tests.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,29 @@ export const testShow = (t, renderer) => {
2323
t.is(renderer.hidden, false);
2424
};
2525

26-
export const testDisable = (t, renderer) => {
26+
export const testDisable = (t, renderer, inputIndex = 1) => {
2727
const dataService = new DataService(t.context.data);
2828
renderer.setDataService(dataService);
2929
renderer.setDataSchema(t.context.schema);
3030
renderer.setUiSchema(t.context.uiSchema);
3131
renderer.connectedCallback();
3232
const runtime = t.context.uiSchema.runtime as Runtime;
3333
runtime.enabled = false;
34-
const input = renderer.children[1] as HTMLInputElement;
34+
const input = renderer.children[inputIndex] as HTMLInputElement;
3535
t.is(input.getAttribute('disabled'), 'true');
3636
// TODO would be nice
3737
// t.is(input.disabled, true);
3838
};
3939

40-
export const testEnable = (t, renderer) => {
40+
export const testEnable = (t, renderer, inputIndex = 1) => {
4141
const dataService = new DataService(t.context.data);
4242
renderer.setDataService(dataService);
4343
renderer.setDataSchema(t.context.schema);
4444
renderer.setUiSchema(t.context.uiSchema);
4545
renderer.connectedCallback();
4646
const runtime = t.context.uiSchema.runtime as Runtime;
4747
runtime.enabled = true;
48-
const input = renderer.children[1] as HTMLInputElement;
48+
const input = renderer.children[inputIndex] as HTMLInputElement;
4949
t.false(input.hasAttribute('disabled'));
5050
};
5151

@@ -123,7 +123,7 @@ export const testNotifyAboutVisibiltyWhenDisconnected = (t, renderer) => {
123123
t.is(renderer.hidden, false);
124124
};
125125

126-
export const testNotifyAboutEnablementWhenDisconnected = (t, renderer) => {
126+
export const testNotifyAboutEnablementWhenDisconnected = (t, renderer, inputIndex = 1) => {
127127
const dataService = new DataService(t.context.data);
128128
renderer.setDataService(dataService);
129129
renderer.setDataSchema(t.context.schema);
@@ -132,7 +132,7 @@ export const testNotifyAboutEnablementWhenDisconnected = (t, renderer) => {
132132
renderer.disconnectedCallback();
133133
const runtime = t.context.uiSchema.runtime as Runtime;
134134
runtime.enabled = false;
135-
const input = renderer.children[1] as HTMLInputElement;
135+
const input = renderer.children[inputIndex] as HTMLInputElement;
136136
t.false(input.hasAttribute('disabled'));
137137
};
138138

test/renderers/boolean.control.test.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ test('BooleanControl static', t => {
131131
t.true(className.indexOf('root_properties_foo') !== -1);
132132
t.true(className.indexOf('control') !== -1);
133133
t.is(result.childNodes.length, 3);
134-
const label = result.children[0] as HTMLLabelElement;
134+
const label = result.children[1] as HTMLLabelElement;
135135
t.is(label.tagName, 'LABEL');
136136
t.is(label.textContent, 'Foo');
137-
const input = result.children[1] as HTMLInputElement;
137+
const input = result.children[0] as HTMLInputElement;
138138
t.is(input.tagName, 'INPUT');
139139
t.is(input.type, 'checkbox');
140140
t.is(input.checked, true);
@@ -159,10 +159,10 @@ test('BooleanControl static no label', t => {
159159
const result = renderer.render();
160160
t.true(result.className.indexOf('control') !== -1);
161161
t.is(result.childNodes.length, 3);
162-
const label = result.children[0] as HTMLLabelElement;
162+
const label = result.children[1] as HTMLLabelElement;
163163
t.is(label.tagName, 'LABEL');
164164
t.is(label.textContent, '');
165-
const input = result.children[1] as HTMLInputElement;
165+
const input = result.children[0] as HTMLInputElement;
166166
t.is(input.tagName, 'INPUT');
167167
t.is(input.type, 'checkbox');
168168
t.is(input.checked, false);
@@ -177,7 +177,7 @@ test('BooleanControl inputChange', t => {
177177
renderer.setDataSchema(t.context.schema);
178178
renderer.setUiSchema(t.context.uiSchema);
179179
const result = renderer.render();
180-
const input = result.children[1] as HTMLInputElement;
180+
const input = result.children[0] as HTMLInputElement;
181181
input.checked = false;
182182
input.onchange(null);
183183
t.is(t.context.data.foo, false);
@@ -191,7 +191,7 @@ test('BooleanControl dataService notification', t => {
191191
renderer.setDataSchema(t.context.schema);
192192
renderer.setUiSchema(t.context.uiSchema);
193193
renderer.connectedCallback();
194-
const input = renderer.children[1] as HTMLInputElement;
194+
const input = renderer.children[0] as HTMLInputElement;
195195
dataService.notifyAboutDataChange({scope: {$ref: '#/properties/foo'}}, true);
196196
t.is(input.checked, true);
197197
});
@@ -203,7 +203,7 @@ test('BooleanControl dataService notification value undefined', t => {
203203
renderer.setDataSchema(t.context.schema);
204204
renderer.setUiSchema(t.context.uiSchema);
205205
renderer.connectedCallback();
206-
const input = renderer.children[1] as HTMLInputElement;
206+
const input = renderer.children[0] as HTMLInputElement;
207207
dataService.notifyAboutDataChange(
208208
{
209209
scope: {
@@ -222,7 +222,7 @@ test('BooleanControl dataService notification value null', t => {
222222
renderer.setDataSchema(t.context.schema);
223223
renderer.setUiSchema(t.context.uiSchema);
224224
renderer.connectedCallback();
225-
const input = renderer.children[1] as HTMLInputElement;
225+
const input = renderer.children[0] as HTMLInputElement;
226226
dataService.notifyAboutDataChange({scope: {$ref: '#/properties/foo'}}, null);
227227
t.is(input.checked, false);
228228
});
@@ -234,7 +234,7 @@ test('BooleanControl dataService notification wrong ref', t => {
234234
renderer.setDataSchema(t.context.schema);
235235
renderer.setUiSchema(t.context.uiSchema);
236236
renderer.connectedCallback();
237-
const input = renderer.children[1] as HTMLInputElement;
237+
const input = renderer.children[0] as HTMLInputElement;
238238
dataService.notifyAboutDataChange({scope: {$ref: '#/properties/bar'}}, 'Bar');
239239
t.is(input.checked, true);
240240
});
@@ -246,7 +246,7 @@ test('BooleanControl dataService notification null ref', t => {
246246
renderer.setDataSchema(t.context.schema);
247247
renderer.setUiSchema(t.context.uiSchema);
248248
renderer.connectedCallback();
249-
const input = renderer.children[1] as HTMLInputElement;
249+
const input = renderer.children[0] as HTMLInputElement;
250250
dataService.notifyAboutDataChange(null, false);
251251
t.is(input.checked, true);
252252
});
@@ -258,7 +258,7 @@ test('BooleanControl dataService notification undefined ref', t => {
258258
renderer.setDataSchema(t.context.schema);
259259
renderer.setUiSchema(t.context.uiSchema);
260260
renderer.connectedCallback();
261-
const input = renderer.children[1] as HTMLInputElement;
261+
const input = renderer.children[0] as HTMLInputElement;
262262
dataService.notifyAboutDataChange(undefined, false);
263263
t.is(input.checked, true);
264264
});
@@ -271,7 +271,7 @@ test('BooleanControl dataService no notification after disconnect', t => {
271271
renderer.setUiSchema(t.context.uiSchema);
272272
renderer.connectedCallback();
273273
renderer.disconnectedCallback();
274-
const input = renderer.children[1] as HTMLInputElement;
274+
const input = renderer.children[0] as HTMLInputElement;
275275
dataService.notifyAboutDataChange({scope: {$ref: '#/properties/foo'}}, 'Bar');
276276
t.is(input.checked, true);
277277
});
@@ -285,11 +285,11 @@ test('BooleanControl notify visible true', t => {
285285
});
286286

287287
test('BooleanControl notify disabled', t => {
288-
testDisable(t, new BooleanControl());
288+
testDisable(t, new BooleanControl(), 0);
289289
});
290290

291291
test('BooleanControl notify enabled', t => {
292-
testEnable(t, new BooleanControl());
292+
testEnable(t, new BooleanControl(), 0);
293293
});
294294

295295
test('BooleanControl notify one error', t => {
@@ -318,7 +318,7 @@ test('BooleanControl disconnected no notify visible', t => {
318318
});
319319

320320
test('BooleanControl disconnected no notify enabled', t => {
321-
testNotifyAboutEnablementWhenDisconnected(t, new BooleanControl());
321+
testNotifyAboutEnablementWhenDisconnected(t, new BooleanControl(), 0);
322322
});
323323

324324
test('BooleanControl disconnected no notify error', t => {

0 commit comments

Comments
 (0)