Skip to content

Commit c54176a

Browse files
committed
test indicator-only public builder
1 parent 07dfcf6 commit c54176a

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { readFileSync } from "node:fs";
2+
import { describe, expect, it } from "vitest";
3+
import { compilePine } from "../lib/compiler";
4+
import { defaultConfig } from "../lib/defaults";
5+
import { toPublicIndicatorConfig } from "../lib/public-indicator-config";
6+
7+
const clone = <T,>(value: T): T => JSON.parse(JSON.stringify(value));
8+
9+
describe("public indicator-only product", () => {
10+
it("forces stale Strategy mode state back to Indicator before generation", () => {
11+
const stale = clone(defaultConfig);
12+
stale.outputMode = "strategy";
13+
const publicConfig = toPublicIndicatorConfig(stale);
14+
const code = compilePine(publicConfig);
15+
16+
expect(publicConfig.outputMode).toBe("indicator");
17+
expect(code).toContain("indicator(");
18+
expect(code).not.toContain("strategy(");
19+
expect(code).not.toContain("strategy.entry");
20+
expect(code).not.toContain("strategy.exit");
21+
});
22+
23+
it("does not expose an Output or Strategy Tester selector in the public page", () => {
24+
const page = readFileSync("app/page.tsx", "utf8");
25+
26+
expect(page).not.toContain('label="Output"');
27+
expect(page).not.toContain("Strategy Tester");
28+
expect(page).toContain("Indicator only:");
29+
expect(page).toContain("toPublicIndicatorConfig(clone(preset))");
30+
});
31+
});

0 commit comments

Comments
 (0)