test(cli): add banner emission reset helper (#87121) · openclaw/openclaw@8c366bf
lizuju
·
2026-06-23
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -132,4 +132,29 @@ describe("emitCliBanner", () => {
|
132 | 132 | expect(writeSpy).toHaveBeenCalledWith("\n🦞 OpenClaw 2026.3.7 (abc1234)\n\n"); |
133 | 133 | expect(hasEmittedCliBanner()).toBe(true); |
134 | 134 | }); |
| 135 | + |
| 136 | +it("can reset banner emission state for same-module tests", async () => { |
| 137 | +const { emitCliBanner, hasEmittedCliBanner, testing } = await importFreshBannerModule(); |
| 138 | +setStdoutIsTty(true); |
| 139 | +const writeSpy = vi.spyOn(process.stdout, "write").mockImplementation(() => true); |
| 140 | + |
| 141 | +const options = { |
| 142 | +argv: ["node", "openclaw"], |
| 143 | +commit: "abc1234", |
| 144 | +env: { LANG: "en_US.UTF-8" }, |
| 145 | +isTty: true, |
| 146 | +mode: "off" as const, |
| 147 | +platform: "darwin" as const, |
| 148 | +richTty: false, |
| 149 | +}; |
| 150 | + |
| 151 | +emitCliBanner("2026.3.7", options); |
| 152 | +expect(hasEmittedCliBanner()).toBe(true); |
| 153 | + |
| 154 | +testing.resetBannerEmittedForTests(); |
| 155 | +expect(hasEmittedCliBanner()).toBe(false); |
| 156 | + |
| 157 | +emitCliBanner("2026.3.7", options); |
| 158 | +expect(writeSpy).toHaveBeenCalledTimes(2); |
| 159 | +}); |
135 | 160 | }); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。