Skip to content

Commit

Permalink
fix(vega-lite): Improve test util types for test keys
Browse files Browse the repository at this point in the history
  • Loading branch information
hydrosquall committed Feb 19, 2025
1 parent c0f94a8 commit 3083392
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions test-runtime/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,19 +306,25 @@ export function clear(idx: number, parent?: string, targetBrush?: boolean) {
return `pureClear(${idx}, ${stringValue(parent)}, ${!!targetBrush})`;
}

export function clearRegion(idx: number, parent?: string, targetBrush?: boolean) {
export function clearRegion(idx: number | {
id: number;
count?: number;
}, parent?: string, targetBrush?: boolean) {
return `clear(${idx}, ${stringValue(parent)}, ${!!targetBrush})`;
}

export function circleRegion(idx: number, parent?: string, targetBrush?: boolean, radius = 40, segments = 20) {
export function circleRegion(idx: number | {
id: number;
count?: number;
}, parent?: string, targetBrush?: boolean, radius = 40, segments = 20) {
return `circleRegion(${idx}, ${radius}, ${segments}, ${stringValue(parent)}, ${!!targetBrush})`;
}

export function polygonRegion(idx: number, polygon: number[][], parent?: string, targetBrush?: boolean) {
return `polygonRegion(${idx}, ${JSON.stringify(polygon)}, ${stringValue(parent)}, ${!!targetBrush})`;
}

export function multiviewRegion(key: string, idx: number, parent?: string, targetBrush?: boolean) {
export function multiviewRegion(key: keyof typeof hits.region, idx: number, parent?: string, targetBrush?: boolean) {
return key.match('_clear')
? clearRegion(hits.region[key][idx], parent, targetBrush)
: circleRegion(hits.region[key][idx], parent, targetBrush, 10);
Expand All @@ -329,7 +335,7 @@ export function brush(key: BrushKeys, idx: number, parent?: string, targetBrush?
return `${fn}(${hits.interval[key][idx].join(', ')}, ${stringValue(parent)}, ${!!targetBrush})`;
}

export function pt(key: string, idx: number, parent?: string) {
export function pt(key: keyof typeof hits.point, idx: number, parent?: string) {
const fn = key.match('_clear') ? 'clear' : 'pt';
return `${fn}(${hits.point[key][idx]}, ${stringValue(parent)})`;
}
Expand Down

0 comments on commit 3083392

Please sign in to comment.