Skip to content

Commit

Permalink
testing(legend): add unit test for preserving the gradientLength prop…
Browse files Browse the repository at this point in the history
…erty at compile time
  • Loading branch information
hydrosquall committed Jul 31, 2024
1 parent c158c80 commit f13f69f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/compile/legend/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,34 @@ describe('compile/legend', () => {
expect(def.title).toBe('foo');
});

it('should produce a Vega legend with gradientLength for color with a discrete scale type', () => {
const model = parseUnitModelWithScale({
mark: 'point',
encoding: {
x: {field: 'a', type: 'nominal'},
color: {
field: 'a',
type: 'quantitative',
scale: {type: 'quantile'},
legend: {
gradientLength: 100
}
}
}
});

const def = parseLegendForChannel(model, COLOR).combine();
// TODO: Check if we are open to enabling toMatchSnapshot testing instead?
expect(def).toEqual({
disable: false,
gradientLength: 100,
labelOverlap: 'greedy',
stroke: 'color',
title: 'a',
type: 'discrete'
});
});

[SIZE, SHAPE, OPACITY, STROKEWIDTH].forEach(channel => {
it(`should produce a Vega legend object with correct type and scale for ${channel}`, () => {
const spec: NormalizedUnitSpec = {
Expand Down

0 comments on commit f13f69f

Please sign in to comment.