Skip to content

Commit 70e0e7e

Browse files
committed
testing(legend): add unit test for preserving the gradientLength property at compile time
1 parent 6c93f78 commit 70e0e7e

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/compile/legend/parse.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,34 @@ describe('compile/legend', () => {
153153
expect(def.title).toBe('foo');
154154
});
155155

156+
it('should produce a Vega legend with gradientLength for color with a discrete scale type', () => {
157+
const model = parseUnitModelWithScale({
158+
mark: 'point',
159+
encoding: {
160+
x: {field: 'a', type: 'nominal'},
161+
color: {
162+
field: 'a',
163+
type: 'quantitative',
164+
scale: {type: 'quantile'},
165+
legend: {
166+
gradientLength: 100
167+
}
168+
}
169+
}
170+
});
171+
172+
const def = parseLegendForChannel(model, COLOR).combine();
173+
// TODO: Check if we are open to enabling toMatchSnapshot testing instead?
174+
expect(def).toEqual({
175+
disable: false,
176+
gradientLength: 100,
177+
labelOverlap: 'greedy',
178+
stroke: 'color',
179+
title: 'a',
180+
type: 'discrete'
181+
});
182+
});
183+
156184
[SIZE, SHAPE, OPACITY, STROKEWIDTH].forEach(channel => {
157185
it(`should produce a Vega legend object with correct type and scale for ${channel}`, () => {
158186
const spec: NormalizedUnitSpec = {

0 commit comments

Comments
 (0)