Skip to content

Commit eb480fd

Browse files
committed
fix: type errors in tests caused by noUncheckedIndexedAccess
1 parent abd0983 commit eb480fd

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

__tests__/formsField.spec.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,32 @@ const generateFormWithOptionalParameter = (initialText = "default") =>
2121
describe("formsField", () => {
2222
test("initialize formsField with generateForm function", () => {
2323
const formsFieldObject1 = formsField(generateFormWithNoParameter, 3);
24-
expect(formsFieldObject1.$forms[0].text.$value).toBe("");
25-
expect(formsFieldObject1.$forms[1].text.$value).toBe("");
26-
expect(formsFieldObject1.$forms[2].text.$value).toBe("");
24+
expect(formsFieldObject1.$forms[0]!.text.$value).toBe("");
25+
expect(formsFieldObject1.$forms[1]!.text.$value).toBe("");
26+
expect(formsFieldObject1.$forms[2]!.text.$value).toBe("");
2727

2828
const formsFieldObject2 = formsField(generateFormWithRequiredParameter, [
2929
"A",
3030
"B",
3131
"C",
3232
]);
33-
expect(formsFieldObject2.$forms[0].text.$value).toBe("A");
34-
expect(formsFieldObject2.$forms[1].text.$value).toBe("B");
35-
expect(formsFieldObject2.$forms[2].text.$value).toBe("C");
33+
expect(formsFieldObject2.$forms[0]!.text.$value).toBe("A");
34+
expect(formsFieldObject2.$forms[1]!.text.$value).toBe("B");
35+
expect(formsFieldObject2.$forms[2]!.text.$value).toBe("C");
3636

3737
const formsFieldObject3 = formsField(generateFormWithOptionalParameter, 3);
38-
expect(formsFieldObject3.$forms[0].text.$value).toBe("default");
39-
expect(formsFieldObject3.$forms[1].text.$value).toBe("default");
40-
expect(formsFieldObject3.$forms[2].text.$value).toBe("default");
38+
expect(formsFieldObject3.$forms[0]!.text.$value).toBe("default");
39+
expect(formsFieldObject3.$forms[1]!.text.$value).toBe("default");
40+
expect(formsFieldObject3.$forms[2]!.text.$value).toBe("default");
4141

4242
const formsFieldObject4 = formsField(generateFormWithOptionalParameter, [
4343
"A",
4444
undefined,
4545
"C",
4646
]);
47-
expect(formsFieldObject4.$forms[0].text.$value).toBe("A");
48-
expect(formsFieldObject4.$forms[1].text.$value).toBe("default");
49-
expect(formsFieldObject4.$forms[2].text.$value).toBe("C");
47+
expect(formsFieldObject4.$forms[0]!.text.$value).toBe("A");
48+
expect(formsFieldObject4.$forms[1]!.text.$value).toBe("default");
49+
expect(formsFieldObject4.$forms[2]!.text.$value).toBe("C");
5050
});
5151

5252
test("no schema was given", () => {
@@ -82,7 +82,7 @@ describe("formsField", () => {
8282
);
8383
expect(formsFieldObject.$error).toBeUndefined();
8484

85-
formsFieldObject.$forms[2].text.$value += "k";
85+
formsFieldObject.$forms[2]!.text.$value += "k";
8686
expect(formsFieldObject.$error).toBeInstanceOf(yup.ValidationError);
8787
});
8888

@@ -191,36 +191,36 @@ describe("formsField", () => {
191191

192192
formsFieldObject.$initialize(["A", "B", "C"]);
193193
expect(formsFieldObject.$forms).toHaveLength(3);
194-
expect(formsFieldObject.$forms[0].text.$value).toBe("A");
195-
expect(formsFieldObject.$forms[1].text.$value).toBe("B");
196-
expect(formsFieldObject.$forms[2].text.$value).toBe("C");
194+
expect(formsFieldObject.$forms[0]!.text.$value).toBe("A");
195+
expect(formsFieldObject.$forms[1]!.text.$value).toBe("B");
196+
expect(formsFieldObject.$forms[2]!.text.$value).toBe("C");
197197

198198
formsFieldObject.$initialize();
199199
expect(formsFieldObject.$forms).toHaveLength(0);
200200

201201
formsFieldObject.$initialize(3);
202202
expect(formsFieldObject.$forms).toHaveLength(3);
203-
expect(formsFieldObject.$forms[0].text.$value).toBe("default");
204-
expect(formsFieldObject.$forms[1].text.$value).toBe("default");
205-
expect(formsFieldObject.$forms[2].text.$value).toBe("default");
203+
expect(formsFieldObject.$forms[0]!.text.$value).toBe("default");
204+
expect(formsFieldObject.$forms[1]!.text.$value).toBe("default");
205+
expect(formsFieldObject.$forms[2]!.text.$value).toBe("default");
206206
});
207207
test("parameter of $append()", async () => {
208208
const formsFieldObject = formsField(generateFormWithOptionalParameter);
209209

210210
formsFieldObject.$append();
211-
expect(formsFieldObject.$forms[0].text.$value).toBe("default");
211+
expect(formsFieldObject.$forms[0]!.text.$value).toBe("default");
212212

213213
formsFieldObject.$append("hello");
214-
expect(formsFieldObject.$forms[1].text.$value).toBe("hello");
214+
expect(formsFieldObject.$forms[1]!.text.$value).toBe("hello");
215215
});
216216
test("parameter of $prepend()", async () => {
217217
const formsFieldObject = formsField(generateFormWithOptionalParameter);
218218

219219
formsFieldObject.$prepend();
220-
expect(formsFieldObject.$forms[0].text.$value).toBe("default");
220+
expect(formsFieldObject.$forms[0]!.text.$value).toBe("default");
221221

222222
formsFieldObject.$prepend("hello");
223-
expect(formsFieldObject.$forms[0].text.$value).toBe("hello");
223+
expect(formsFieldObject.$forms[0]!.text.$value).toBe("hello");
224224
});
225225
test("parameter of $remove()", async () => {
226226
const formsFieldObject = formsField(generateFormWithOptionalParameter, 5);

__tests__/isValidForm.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ describe("isValidForm", () => {
7070
form.a.$append();
7171
expect(isValidForm(form)).toBe(false);
7272

73-
form.a.$forms[1].text.$value = "world";
73+
form.a.$forms[1]!.text.$value = "world";
7474
expect(isValidForm(form)).toBe(true);
7575
});
7676
});

0 commit comments

Comments
 (0)