Release 2.6.2-rc1
This commit is contained in:
@@ -61,4 +61,46 @@ describe("maintenance command", () => {
|
||||
output.mockRestore();
|
||||
}
|
||||
});
|
||||
|
||||
test("wildcard host requires a second call before posting the normalized host", async () => {
|
||||
const calls: Array<{ path: string; init?: ApiRequestInit }> = [];
|
||||
const confirmations: string[] = [];
|
||||
const output = spyOn(console, "log").mockImplementation(() => {});
|
||||
try {
|
||||
const request = async <T>(path: string, init?: ApiRequestInit): Promise<T> => {
|
||||
calls.push({ path, init });
|
||||
return {
|
||||
host: "*.example.com",
|
||||
enabled: init?.method === "POST",
|
||||
hosts: init?.method === "POST" ? ["*.example.com"] : [],
|
||||
} as T;
|
||||
};
|
||||
const confirm = async (host: string) => {
|
||||
confirmations.push(host);
|
||||
return confirmations.length === 2;
|
||||
};
|
||||
|
||||
await runMaintenance("*.EXAMPLE.COM.", request, confirm);
|
||||
expect(calls).toEqual([{ path: "/maintenance/*.EXAMPLE.COM.", init: undefined }]);
|
||||
expect(output).toHaveBeenCalledWith(
|
||||
expect.stringContaining("*.example.com maintenance is currently"),
|
||||
);
|
||||
|
||||
await runMaintenance("*.EXAMPLE.COM.", request, confirm);
|
||||
expect(confirmations).toEqual(["*.example.com", "*.example.com"]);
|
||||
expect(calls).toEqual([
|
||||
{ path: "/maintenance/*.EXAMPLE.COM.", init: undefined },
|
||||
{ path: "/maintenance/*.EXAMPLE.COM.", init: undefined },
|
||||
{
|
||||
path: "/maintenance/*.example.com",
|
||||
init: { method: "POST", json: { enabled: true } },
|
||||
},
|
||||
]);
|
||||
expect(output).toHaveBeenCalledWith(
|
||||
"*.example.com maintenance is now \x1b[31mON\x1b[0m",
|
||||
);
|
||||
} finally {
|
||||
output.mockRestore();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user