Fix frontend config tests for strict type narrowing
This commit is contained in:
@@ -26,7 +26,7 @@ describe("RegexList", () => {
|
||||
name: /Remove Test patterns pattern \d+$/i,
|
||||
});
|
||||
expect(deleteButtons).toHaveLength(2);
|
||||
const [firstDeleteButton] = deleteButtons;
|
||||
const firstDeleteButton = deleteButtons[0]!;
|
||||
|
||||
fireEvent.click(firstDeleteButton);
|
||||
expect(handleChange).toHaveBeenLastCalledWith(["foo"]);
|
||||
|
||||
@@ -16,7 +16,8 @@ describe("StringListEditor", () => {
|
||||
|
||||
const inputs = screen.getAllByRole("textbox");
|
||||
expect(inputs).toHaveLength(2);
|
||||
const [firstInput, secondInput] = inputs;
|
||||
const firstInput = inputs[0]!;
|
||||
const secondInput = inputs[1]!;
|
||||
expect(firstInput).toHaveValue("foo");
|
||||
expect(secondInput).toHaveValue("foo");
|
||||
|
||||
@@ -36,7 +37,7 @@ describe("StringListEditor", () => {
|
||||
|
||||
const deleteButtons = screen.getAllByRole("button", { name: /Remove entry/i });
|
||||
expect(deleteButtons).toHaveLength(3);
|
||||
const [, secondDeleteButton] = deleteButtons;
|
||||
const secondDeleteButton = deleteButtons[1]!;
|
||||
|
||||
fireEvent.click(secondDeleteButton);
|
||||
expect(handleChange).toHaveBeenLastCalledWith(["one", "three"]);
|
||||
|
||||
@@ -13,12 +13,15 @@ describe("reconcileStableStringEntries", () => {
|
||||
|
||||
expect(next).toHaveLength(3);
|
||||
if (next.length !== 3) throw new Error("expected three entries");
|
||||
const first = next[0]!;
|
||||
const second = next[1]!;
|
||||
const third = next[2]!;
|
||||
|
||||
expect(next[0].id).toBe("a");
|
||||
expect(next[0].value).toBe("foo");
|
||||
expect(next[1].value).toBe("baz");
|
||||
expect(next[1].id).not.toBe("b");
|
||||
expect(next[2].id).toBe("c");
|
||||
expect(first.id).toBe("a");
|
||||
expect(first.value).toBe("foo");
|
||||
expect(second.value).toBe("baz");
|
||||
expect(second.id).not.toBe("b");
|
||||
expect(third.id).toBe("c");
|
||||
});
|
||||
|
||||
it("reuses ids when string values move positions", () => {
|
||||
@@ -31,8 +34,11 @@ describe("reconcileStableStringEntries", () => {
|
||||
const next = reconcileStableStringEntries(previous, ["bar", "foo", "baz"]);
|
||||
|
||||
if (next.length !== 3) throw new Error("expected three entries");
|
||||
expect(next[0].id).toBe("b");
|
||||
expect(next[1].id).toBe("a");
|
||||
expect(next[2].id).toBe("c");
|
||||
const first = next[0]!;
|
||||
const second = next[1]!;
|
||||
const third = next[2]!;
|
||||
expect(first.id).toBe("b");
|
||||
expect(second.id).toBe("a");
|
||||
expect(third.id).toBe("c");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user