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