Skip to content

Commit

Permalink
fix: cartesian utils unit test, remove demo,src from files array
Browse files Browse the repository at this point in the history
  • Loading branch information
Coltin Kifer authored and ckifer committed Jan 12, 2023
1 parent bcb199c commit 1216e06
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@
"sideEffects": false,
"files": [
"*.md",
"demo",
"es6",
"lib",
"umd",
"src",
"types"
],
"keywords": [
Expand Down
16 changes: 8 additions & 8 deletions test-jest/util/CartesianUtils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ describe('ScaleHelper', () => {

it('apply() should return the expected value for band scale', () => {
const scale = new ScaleHelper(scaleBand().domain(['0', '1', '2', '3']).range([0, 100]));
expect(scale.apply(2)).toEqual(50);
expect(scale.apply('2')).toEqual(50);
});

it('apply() should return the expected value for band scale when bandAware = true', () => {
const scale = new ScaleHelper(scaleBand().domain(['0', '1', '2', '3']).range([0, 100]));
expect(scale.apply(2, { bandAware: true })).toEqual(50 + 25 / 2);
expect(scale.apply('2', { bandAware: true })).toEqual(50 + 25 / 2);
});

it('apply() should return undefined for undefined', () => {
Expand All @@ -43,17 +43,17 @@ describe('ScaleHelper', () => {
});
});

describe('createLabeldScales', () => {
describe('createLabeledScales', () => {
it('apply() should return the expected values', () => {
const scales = createLabeledScales({
x: scaleBand().domain(['0', '1', '2', '3']).range([0, 100]),
y: scaleLinear().domain([-200, 200]).range([0, 50]),
});
expect(scales.apply({ x: 2 }, { bandAware: true })).toEqual({ x: 50 + 25 / 2 });
expect(scales.apply({ x: 2 }, { bandAware: true, position: 'start' })).toEqual({ x: 50 });
expect(scales.apply({ x: 2 }, { bandAware: true, position: 'middle' })).toEqual({ x: 50 + 25 / 2.0 });
expect(scales.apply({ x: 2 }, { bandAware: true, position: 'end' })).toEqual({ x: 50 + 25 });
expect(scales.apply({ y: 100 }, { bandAware: true })).toEqual({ y: 37.5 });
expect(scales.apply({ x: '2' }, { bandAware: true })).toEqual({ x: 50 + 25 / 2 });
expect(scales.apply({ x: '2' }, { bandAware: true, position: 'start' })).toEqual({ x: 50 });
expect(scales.apply({ x: '2' }, { bandAware: true, position: 'middle' })).toEqual({ x: 50 + 25 / 2.0 });
expect(scales.apply({ x: '2' }, { bandAware: true, position: 'end' })).toEqual({ x: 50 + 25 });
expect(scales.apply({ y: '100' }, { bandAware: true })).toEqual({ y: 37.5 });
});

it('isInRange() should return the expected values', () => {
Expand Down

0 comments on commit 1216e06

Please sign in to comment.