Skip to content

Commit

Permalink
fix(chart): validate includePrePost:false, interval:1m (fixes #812)
Browse files Browse the repository at this point in the history
  • Loading branch information
gadicc committed Oct 4, 2024
1 parent 7538e97 commit b272c48
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/modules/chart.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ describe("chart", () => {
).rejects.toThrow(/cannot share the same value/);
});

it("validates when includePrePost=false interval=1m", async () => {
await yf.chart(
"AAPL",
{
period1: "2024-10-02",
period2: "2024-10-03",
interval: "1m",
includePrePost: false,
},
{
devel: `chart-AAPL-2024-10-02-to-2024-10-03-includePrePost-false-interval-1m.json`,
},
);
});

describe("specific cases", () => {
it("optional fields, empty arrays", async () => {
/*
Expand Down
9 changes: 8 additions & 1 deletion src/modules/chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,14 @@ const ChartMeta = Type.Object(
additionalProperties: Type.Any(),
},
),
tradingPeriods: Type.Optional(ChartMetaTradingPeriods),
tradingPeriods: Type.Optional(
// TODO, would be great to use correct type as a generic based on
// `includePrePost` and `interval`, see #812.
Type.Union([
ChartMetaTradingPeriods,
Type.Array(Type.Array(ChartMetaTradingPeriod)),
]),
),
dataGranularity: Type.String(), // "1d",
range: Type.String(), // ""
validRanges: Type.Array(Type.String()), // ["1d", "5d", "1mo", "3mo", "6mo", "1y", "2y", "5y", "10y", "ytd", "max"]
Expand Down
Loading

0 comments on commit b272c48

Please sign in to comment.