Skip to content

Commit

Permalink
test: unit tests for layoutsize
Browse files Browse the repository at this point in the history
  • Loading branch information
kanitw committed Jul 4, 2019
1 parent f08f043 commit b6bb8e6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/compile/layoutsize/init.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as log from '../../../src/log';
import {parseUnitModelWithScaleAndLayoutSize} from '../../util';

describe('compile/layout', () => {
describe('initLayoutSize', () => {
it(
'should have step-based width/height for ordinal x,y',
log.wrap(localLogger => {
const model = parseUnitModelWithScaleAndLayoutSize({
mark: 'point',
width: {step: 20},
encoding: {
x: {field: 'a', type: 'quantitative'}
}
});

expect(localLogger.warns[0]).toEqual(log.message.cannotUseStepWithContinuous('width'));

expect(model.component.layoutSize.get('width')).toBe(200);
})
);
});
});
12 changes: 12 additions & 0 deletions test/compile/layoutsize/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,17 @@ describe('compile/layout', () => {
expect(model.component.layoutSize.get('width')).toBe('step');
expect(model.component.layoutSize.get('height')).toBe('step');
});

it('should have step-based width/height for ordinal x,y', () => {
const model = parseUnitModelWithScaleAndLayoutSize({
mark: 'point',
encoding: {
x: {field: 'a', type: 'ordinal'},
y: {field: 'b', type: 'ordinal'}
}
});

expect(model.component.layoutSize.get('width')).toBe('step');
});
});
});

0 comments on commit b6bb8e6

Please sign in to comment.