mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-09 03:22:40 +00:00
test(cli): add banner emission reset helper (#87121)
This commit is contained in:
@@ -132,4 +132,29 @@ describe("emitCliBanner", () => {
|
||||
expect(writeSpy).toHaveBeenCalledWith("\n🦞 OpenClaw 2026.3.7 (abc1234)\n\n");
|
||||
expect(hasEmittedCliBanner()).toBe(true);
|
||||
});
|
||||
|
||||
it("can reset banner emission state for same-module tests", async () => {
|
||||
const { emitCliBanner, hasEmittedCliBanner, testing } = await importFreshBannerModule();
|
||||
setStdoutIsTty(true);
|
||||
const writeSpy = vi.spyOn(process.stdout, "write").mockImplementation(() => true);
|
||||
|
||||
const options = {
|
||||
argv: ["node", "openclaw"],
|
||||
commit: "abc1234",
|
||||
env: { LANG: "en_US.UTF-8" },
|
||||
isTty: true,
|
||||
mode: "off" as const,
|
||||
platform: "darwin" as const,
|
||||
richTty: false,
|
||||
};
|
||||
|
||||
emitCliBanner("2026.3.7", options);
|
||||
expect(hasEmittedCliBanner()).toBe(true);
|
||||
|
||||
testing.resetBannerEmittedForTests();
|
||||
expect(hasEmittedCliBanner()).toBe(false);
|
||||
|
||||
emitCliBanner("2026.3.7", options);
|
||||
expect(writeSpy).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -117,3 +117,10 @@ export function emitCliBanner(version: string, options: BannerOptions = {}) {
|
||||
export function hasEmittedCliBanner(): boolean {
|
||||
return bannerEmitted;
|
||||
}
|
||||
|
||||
export const testing = {
|
||||
resetBannerEmittedForTests(): void {
|
||||
bannerEmitted = false;
|
||||
},
|
||||
};
|
||||
export { testing as __testing };
|
||||
|
||||
Reference in New Issue
Block a user