test(site): replace toThrowError with toThrow (#32833)
> 🤖 This PR was written by Codex on behalf of Jake Howell. Replace the 22 remaining `toThrowError` calls in `site/` tests with `toThrow`. Vitest registers both names for the same matcher, so the existing error expectations and negations carry over. https://vitest.dev/api/expect.html#tothrow Depends on #32832
This commit is contained in:
1 parent
f06e1aeae6
commit
f1fd4f7f78
4 files changed
+22
-26
No files matched your search
@@ -39,17 +39,17 @@ describe("docsRedirects", () => {
|
||||
});
|
||||
|
||||
it("throws a TypeError when given a non-array (e.g. object)", () => {
|
||||
expect(() => docsRedirects({})).toThrowError(TypeError);
|
||||
expect(() => docsRedirects({})).toThrowError(/got object/);
|
||||
expect(() => docsRedirects({})).toThrow(TypeError);
|
||||
expect(() => docsRedirects({})).toThrow(/got object/);
|
||||
});
|
||||
|
||||
it("throws a TypeError when given a non-array (e.g. string)", () => {
|
||||
expect(() => docsRedirects("hello")).toThrowError(TypeError);
|
||||
expect(() => docsRedirects("hello")).toThrowError(/got string/);
|
||||
expect(() => docsRedirects("hello")).toThrow(TypeError);
|
||||
expect(() => docsRedirects("hello")).toThrow(/got string/);
|
||||
});
|
||||
|
||||
it("throws a TypeError when given null", () => {
|
||||
expect(() => docsRedirects(null)).toThrowError(TypeError);
|
||||
expect(() => docsRedirects(null)).toThrow(TypeError);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -476,7 +476,7 @@ describe("providerFormValuesToCreate", () => {
|
||||
// to refuse to send a malformed payload if a caller bypasses it.
|
||||
expect(() =>
|
||||
providerFormValuesToCreate({ ...baseOpenAIFormValues, type: "" }),
|
||||
).toThrowError(/provider type is required/);
|
||||
).toThrow(/provider type is required/);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ describe("TemplateSettingsPage", () => {
|
||||
"The quick brown fox jumps over the lazy dog repeatedly, enjoying the weather of the bright, summer day in the lush, scenic park.",
|
||||
};
|
||||
const validate = () => validationSchema.validateSync(values);
|
||||
expect(validate).not.toThrowError();
|
||||
expect(validate).not.toThrow();
|
||||
});
|
||||
|
||||
it("disallows a description of 128 + 1 chars", () => {
|
||||
|
||||
+15
-19
@@ -300,7 +300,7 @@ describe("TemplateSchedulePage", () => {
|
||||
default_ttl_ms: 24 * 7,
|
||||
};
|
||||
const validate = () => getValidationSchema().validateSync(values);
|
||||
expect(validate).not.toThrowError();
|
||||
expect(validate).not.toThrow();
|
||||
});
|
||||
|
||||
it("allows default ttl of 0", () => {
|
||||
@@ -309,7 +309,7 @@ describe("TemplateSchedulePage", () => {
|
||||
default_ttl_ms: 0,
|
||||
};
|
||||
const validate = () => getValidationSchema().validateSync(values);
|
||||
expect(validate).not.toThrowError();
|
||||
expect(validate).not.toThrow();
|
||||
});
|
||||
|
||||
it("allows a default ttl of 30 days", () => {
|
||||
@@ -318,7 +318,7 @@ describe("TemplateSchedulePage", () => {
|
||||
default_ttl_ms: 24 * 30,
|
||||
};
|
||||
const validate = () => getValidationSchema().validateSync(values);
|
||||
expect(validate).not.toThrowError();
|
||||
expect(validate).not.toThrow();
|
||||
});
|
||||
|
||||
it("disallows a default ttl of 30 days + 1 hour", () => {
|
||||
@@ -327,7 +327,7 @@ describe("TemplateSchedulePage", () => {
|
||||
default_ttl_ms: 24 * 30 + 1,
|
||||
};
|
||||
const validate = () => getValidationSchema().validateSync(values);
|
||||
expect(validate).toThrowError(
|
||||
expect(validate).toThrow(
|
||||
"Please enter a limit that is less than or equal to 720 hours (30 days).",
|
||||
);
|
||||
});
|
||||
@@ -338,7 +338,7 @@ describe("TemplateSchedulePage", () => {
|
||||
failure_ttl_ms: 86400000 * 7,
|
||||
};
|
||||
const validate = () => getValidationSchema().validateSync(values);
|
||||
expect(validate).not.toThrowError();
|
||||
expect(validate).not.toThrow();
|
||||
});
|
||||
|
||||
it("allows failure ttl of 0", () => {
|
||||
@@ -347,7 +347,7 @@ describe("TemplateSchedulePage", () => {
|
||||
failure_ttl_ms: 0,
|
||||
};
|
||||
const validate = () => getValidationSchema().validateSync(values);
|
||||
expect(validate).not.toThrowError();
|
||||
expect(validate).not.toThrow();
|
||||
});
|
||||
|
||||
it("disallows a negative failure ttl", () => {
|
||||
@@ -356,9 +356,7 @@ describe("TemplateSchedulePage", () => {
|
||||
failure_ttl_ms: -1,
|
||||
};
|
||||
const validate = () => getValidationSchema().validateSync(values);
|
||||
expect(validate).toThrowError(
|
||||
"Failure cleanup days must not be less than 0.",
|
||||
);
|
||||
expect(validate).toThrow("Failure cleanup days must not be less than 0.");
|
||||
});
|
||||
|
||||
it("allows an inactivity ttl of 7 days", () => {
|
||||
@@ -367,7 +365,7 @@ describe("TemplateSchedulePage", () => {
|
||||
time_til_dormant_ms: 86400000 * 7,
|
||||
};
|
||||
const validate = () => getValidationSchema().validateSync(values);
|
||||
expect(validate).not.toThrowError();
|
||||
expect(validate).not.toThrow();
|
||||
});
|
||||
|
||||
it("allows an inactivity ttl of 0", () => {
|
||||
@@ -376,7 +374,7 @@ describe("TemplateSchedulePage", () => {
|
||||
time_til_dormant_ms: 0,
|
||||
};
|
||||
const validate = () => getValidationSchema().validateSync(values);
|
||||
expect(validate).not.toThrowError();
|
||||
expect(validate).not.toThrow();
|
||||
});
|
||||
|
||||
it("disallows a negative inactivity ttl", () => {
|
||||
@@ -385,9 +383,7 @@ describe("TemplateSchedulePage", () => {
|
||||
time_til_dormant_ms: -1,
|
||||
};
|
||||
const validate = () => getValidationSchema().validateSync(values);
|
||||
expect(validate).toThrowError(
|
||||
"Dormancy threshold must not be less than 0.",
|
||||
);
|
||||
expect(validate).toThrow("Dormancy threshold must not be less than 0.");
|
||||
});
|
||||
|
||||
it("allows a dormancy ttl of 7 days", () => {
|
||||
@@ -396,7 +392,7 @@ describe("TemplateSchedulePage", () => {
|
||||
time_til_dormant_autodelete_ms: 86400000 * 7,
|
||||
};
|
||||
const validate = () => getValidationSchema().validateSync(values);
|
||||
expect(validate).not.toThrowError();
|
||||
expect(validate).not.toThrow();
|
||||
});
|
||||
|
||||
it("allows a dormancy ttl of 0", () => {
|
||||
@@ -405,7 +401,7 @@ describe("TemplateSchedulePage", () => {
|
||||
time_til_dormant_autodelete_ms: 0,
|
||||
};
|
||||
const validate = () => getValidationSchema().validateSync(values);
|
||||
expect(validate).not.toThrowError();
|
||||
expect(validate).not.toThrow();
|
||||
});
|
||||
|
||||
it("disallows a negative inactivity ttl", () => {
|
||||
@@ -414,7 +410,7 @@ describe("TemplateSchedulePage", () => {
|
||||
time_til_dormant_autodelete_ms: -1,
|
||||
};
|
||||
const validate = () => getValidationSchema().validateSync(values);
|
||||
expect(validate).toThrowError(
|
||||
expect(validate).toThrow(
|
||||
"Dormancy auto-deletion days must not be less than 0.",
|
||||
);
|
||||
});
|
||||
@@ -426,7 +422,7 @@ describe("TemplateSchedulePage", () => {
|
||||
autostop_requirement_weeks: 1,
|
||||
};
|
||||
const validate = () => getValidationSchema().validateSync(values);
|
||||
expect(validate).not.toThrowError();
|
||||
expect(validate).not.toThrow();
|
||||
});
|
||||
|
||||
it("allows a autostop requirement weeks of 16", () => {
|
||||
@@ -435,7 +431,7 @@ describe("TemplateSchedulePage", () => {
|
||||
autostop_requirement_weeks: 16,
|
||||
};
|
||||
const validate = () => getValidationSchema().validateSync(values);
|
||||
expect(validate).not.toThrowError();
|
||||
expect(validate).not.toThrow();
|
||||
});
|
||||
|
||||
it("disallows a autostop requirement weeks of 0", () => {
|
||||
|
||||
Reference in new issue
Block a user