Update unit test
This commit is contained in:
@@ -835,21 +835,21 @@ describe("findMatchingFieldAndFile", () => {
|
||||
describe("findSectionIdsByQuery", () => {
|
||||
it("throws when sections is empty", () => {
|
||||
expect(() => findSectionIdsByQuery([], "section-1")).toThrow(
|
||||
/section section-1 could not be found/,
|
||||
/Item has no sections; cannot resolve section "section-1"/,
|
||||
);
|
||||
});
|
||||
|
||||
it("throws when sections is null/undefined", () => {
|
||||
expect(() =>
|
||||
findSectionIdsByQuery(undefined as unknown as FullItem["sections"], "x"),
|
||||
).toThrow(/could not be found/);
|
||||
).toThrow(/Item has no sections; cannot resolve section "x"/);
|
||||
});
|
||||
|
||||
it("returns section id when section matches by id", () => {
|
||||
const sections = [{ id: "sec-1", label: "Section 1" }];
|
||||
expect(
|
||||
findSectionIdsByQuery(sections as FullItem["sections"], "sec-1"),
|
||||
).toEqual(["sec-1"]);
|
||||
it("throws when section query matches no section", () => {
|
||||
const sections = [{ id: "sec-1", label: "Other" }];
|
||||
expect(() =>
|
||||
findSectionIdsByQuery(sections as FullItem["sections"], "nonexistent"),
|
||||
).toThrow(/No section matching "nonexistent" found in specified item/);
|
||||
});
|
||||
|
||||
it("returns section id when section matches by label", () => {
|
||||
@@ -863,7 +863,7 @@ describe("findSectionIdsByQuery", () => {
|
||||
const sections = [{ id: "sec-1", label: "Other" }];
|
||||
expect(() =>
|
||||
findSectionIdsByQuery(sections as FullItem["sections"], "nonexistent"),
|
||||
).toThrow(/could not be found/);
|
||||
).toThrow(/No section matching "nonexistent" found in specified item/);
|
||||
});
|
||||
|
||||
it("returns multiple ids when multiple sections match", () => {
|
||||
|
||||
@@ -113,7 +113,6 @@ const getFileContentWithRetry = async (
|
||||
itemId: string,
|
||||
fileId: string,
|
||||
): Promise<string> => {
|
||||
|
||||
const maxAttempts = 3;
|
||||
const retryDelayMs = 2000;
|
||||
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
||||
@@ -299,7 +298,9 @@ const validateSecretRefs = (envNames: string[]): void => {
|
||||
|
||||
// Throw an error if any secret references are invalid
|
||||
if (invalid.length > 0) {
|
||||
const details = invalid.map(({ name, message }) => `${name}: ${message}`).join("; ");
|
||||
const details = invalid
|
||||
.map(({ name, message }) => `${name}: ${message}`)
|
||||
.join("; ");
|
||||
throw new Error(`Invalid secret reference(s): ${details}`);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user