Skip to content

Commit

Permalink
test: fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz committed Mar 11, 2021
1 parent 6357ba5 commit 42c4ae1
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 35 deletions.
36 changes: 1 addition & 35 deletions test/compile/mark/encode/position-point.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {getSizeChannel, X, Y} from '../../../../src/channel';
import {X, Y} from '../../../../src/channel';
import {pointPosition} from '../../../../src/compile/mark/encode';
import {parseUnitModelWithScaleAndLayoutSize} from '../../../util';

Expand Down Expand Up @@ -29,38 +29,4 @@ describe('compile/mark/encode/position-point', () => {
expect(mixins[channel]['field']).toEqual(model.getName(channel));
});
});

it('should return correctly for lat/lng with size', () => {
const model = parseUnitModelWithScaleAndLayoutSize({
data: {
url: 'data/zipcodes.csv',
format: {
type: 'csv'
}
},
mark: {
type: 'image',
width: 42,
height: 42
},
encoding: {
longitude: {
field: 'longitude',
type: 'quantitative'
},
latitude: {
field: 'latitude',
type: 'quantitative'
}
}
});

[X, Y].forEach(channel => {
const mixins = pointPosition(channel, model, {defaultPos: 'zeroOrMin'});
expect(mixins[channel]['field']).toEqual(model.getName(channel));

const sizeChannel = getSizeChannel(channel);
expect(mixins[sizeChannel]).toEqual({[sizeChannel]: 42});
});
});
});
39 changes: 39 additions & 0 deletions test/compile/mark/encode/position-range.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import {getSizeChannel, X, Y} from '../../../../src/channel';
import {rangePosition} from '../../../../src/compile/mark/encode';
import {parseUnitModelWithScaleAndLayoutSize} from '../../../util';

describe('compile/mark/encode/position-range', () => {
it('should return correctly for lat/lng with size', () => {
const model = parseUnitModelWithScaleAndLayoutSize({
data: {
url: 'data/zipcodes.csv',
format: {
type: 'csv'
}
},
mark: {
type: 'image',
width: 42,
height: 42
},
encoding: {
longitude: {
field: 'longitude',
type: 'quantitative'
},
latitude: {
field: 'latitude',
type: 'quantitative'
}
}
});

[X, Y].forEach(channel => {
const mixins = rangePosition(channel, model, {defaultPos: 'zeroOrMin', defaultPos2: 'zeroOrMin'});
expect(mixins[channel + 'c']['field']).toEqual(model.getName(channel));

const sizeChannel = getSizeChannel(channel);
expect(mixins[sizeChannel]).toEqual({value: 42});
});
});
});

0 comments on commit 42c4ae1

Please sign in to comment.