Skip to content

Commit

Permalink
add null edge case and requested test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
alliefeldman committed Dec 16, 2023
1 parent f0c7695 commit 2467935
Show file tree
Hide file tree
Showing 2 changed files with 221 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/compile/selection/interval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ const interval: SelectionCompiler<'interval'> = {
filters.push(filterExpr);
}
}
selCmpt.mark.cursor = 'move';
if (selCmpt.mark.cursor == null) {
selCmpt.mark.cursor = 'move';
}

Check warning on line 57 in src/compile/selection/interval.ts

View workflow job for this annotation

GitHub Actions / Runtime, Linting, and Coverage

Delete `⏎`
}
},

Expand Down
217 changes: 217 additions & 0 deletions test/compile/selection/interval.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,223 @@ describe('Interval Selections', () => {
}
]);
});

const brushSelCmpts = parseUnitSelection(model, [
{
name: 'crosshair',
select: {type: 'interval', clear: false, translate: true, zoom: false, mark: {cursor: 'crosshair'}}
},
{
name: 'disabled',
select: {type: 'interval', clear: false, translate: false, zoom: false}
}]

Check warning on line 848 in test/compile/selection/interval.test.ts

View workflow job for this annotation

GitHub Actions / Runtime, Linting, and Coverage

Delete `]`
);

Check warning on line 849 in test/compile/selection/interval.test.ts

View workflow job for this annotation

GitHub Actions / Runtime, Linting, and Coverage

Insert `]`

it('should not override manual cursor assignment', () => {
const nameModel = parseUnitModel({
mark: 'circle',
encoding: {
x: {field: 'x', type: 'quantitative'},
y: {field: 'y', type: 'quantitative'}
}
});
nameModel.parseScale();

const marks: any[] = [{hello: 'world'}];

Check warning on line 861 in test/compile/selection/interval.test.ts

View workflow job for this annotation

GitHub Actions / Runtime, Linting, and Coverage

Delete `⏎`


expect(interval.marks(nameModel, brushSelCmpts['crosshair'], marks)).toEqual([
{
name: 'crosshair_brush_bg',
type: 'rect',
clip: true,
encode: {
enter: {fill: {value: '#333'}, fillOpacity: {value: 0.125}},
update: {
x: [
{
test: 'data("crosshair_store").length && data("crosshair_store")[0].unit === ""',
signal: 'crosshair_x[0]'
},
{value: 0}
],
y: [
{
test: 'data("crosshair_store").length && data("crosshair_store")[0].unit === ""',
signal: 'crosshair_y[0]'
},
{value: 0}
],
x2: [
{
test: 'data("crosshair_store").length && data("crosshair_store")[0].unit === ""',
signal: 'crosshair_x[1]'
},
{value: 0}
],
y2: [
{
test: 'data("crosshair_store").length && data("crosshair_store")[0].unit === ""',
signal: 'crosshair_y[1]'
},
{value: 0}
]
}
}
},
{hello: 'world'},
{
name: 'crosshair_brush',
type: 'rect',
clip: true,
encode: {
enter: {cursor: {value: 'crosshair'}, fill: {value: 'transparent'}},
update: {
x: [
{
test: 'data("crosshair_store").length && data("crosshair_store")[0].unit === ""',
signal: 'crosshair_x[0]'
},
{value: 0}
],
y: [
{
test: 'data("crosshair_store").length && data("crosshair_store")[0].unit === ""',
signal: 'crosshair_y[0]'
},
{value: 0}
],
x2: [
{
test: 'data("crosshair_store").length && data("crosshair_store")[0].unit === ""',
signal: 'crosshair_x[1]'
},
{value: 0}
],
y2: [
{
test: 'data("crosshair_store").length && data("crosshair_store")[0].unit === ""',
signal: 'crosshair_y[1]'
},
{value: 0}
],
stroke: [
{
test: 'crosshair_x[0] !== crosshair_x[1] && crosshair_y[0] !== crosshair_y[1]',
value: 'white'
},
{value: null}
]
}
}
}
])

Check warning on line 949 in test/compile/selection/interval.test.ts

View workflow job for this annotation

GitHub Actions / Runtime, Linting, and Coverage

Insert `;`
});

it('should not change brush cursor when translate is set to "false"', () => {
const nameModel = parseUnitModel({
mark: 'circle',
encoding: {
x: {field: 'x', type: 'quantitative'},
y: {field: 'y', type: 'quantitative'}
}
});
nameModel.parseScale();
const marks: any[] = [{hello: 'world'}];

expect(interval.marks(model, brushSelCmpts['disabled'], marks)).toEqual([
{
name: 'disabled_brush_bg',
type: 'rect',
clip: true,
encode: {
enter: {
fill: {value: '#333'},
fillOpacity: {value: 0.125}
},
update: {
x: [
{
test: 'data("disabled_store").length && data("disabled_store")[0].unit === ""',
signal: 'disabled_x[0]'
},
{value: 0}
],
y: [
{
test: 'data("disabled_store").length && data("disabled_store")[0].unit === ""',
signal: 'disabled_y[0]'
},
{value: 0}
],
x2: [
{
test: 'data("disabled_store").length && data("disabled_store")[0].unit === ""',
signal: 'disabled_x[1]'
},
{value: 0}
],
y2: [
{
test: 'data("disabled_store").length && data("disabled_store")[0].unit === ""',
signal: 'disabled_y[1]'
},
{value: 0}
],

Check warning on line 1001 in test/compile/selection/interval.test.ts

View workflow job for this annotation

GitHub Actions / Runtime, Linting, and Coverage

Delete `,⏎`

}
}
},
{hello: 'world'},
{
name: 'disabled_brush',
type: 'rect',
clip: true,
encode: {
enter: {
fill: {value: 'transparent'}
},
update: {
x: [
{
test: 'data("disabled_store").length && data("disabled_store")[0].unit === ""',
signal: 'disabled_x[0]'
},
{value: 0}
],
y: [
{
test: 'data("disabled_store").length && data("disabled_store")[0].unit === ""',
signal: 'disabled_y[0]'
},
{value: 0}
],
x2: [
{
test: 'data("disabled_store").length && data("disabled_store")[0].unit === ""',
signal: 'disabled_x[1]'
},
{value: 0}
],
y2: [
{
test: 'data("disabled_store").length && data("disabled_store")[0].unit === ""',
signal: 'disabled_y[1]'
},
{value: 0}
],
stroke: [
{
test: 'disabled_x[0] !== disabled_x[1] && disabled_y[0] !== disabled_y[1]',
value: 'white'
},
{value: null}
]
}
}
}
]);
});
});

describe('Geo intervals', () => {
Expand Down

0 comments on commit 2467935

Please sign in to comment.