Skip to content

Commit eeded8e

Browse files
committed
feat(scales): update tests due to the changes on scales' defaults
1 parent d3b964b commit eeded8e

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

packages/bullet/src/hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const useEnhancedData = (
2222
const min = minValue ?? Math.min(...all)
2323

2424
const scale = createLinearScale(
25-
{ clamp: true, min, max, type: 'linear' },
25+
{ clamp: true, min, max, type: 'linear', round: true },
2626
{ all, max, min },
2727
layout === 'horizontal' ? width : height,
2828
layout === 'horizontal' ? (reverse ? 'y' : 'x') : reverse ? 'x' : 'y'

packages/scales/tests/symlogScale.test.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
import { createSymlogScale } from '../src'
22

33
it(`should be able to build a symlog scale for x axis`, () => {
4-
const scale = createSymlogScale({ type: 'symlog' }, { all: [], min: 0, max: 1 }, 100, 'x')
4+
const scale = createSymlogScale(
5+
{ type: 'symlog', round: true },
6+
{ all: [], min: 0, max: 1 },
7+
100,
8+
'x'
9+
)
510

611
expect(scale(0)).toBe(0)
712
expect(scale(0.5)).toBe(58)
813
expect(scale(1)).toBe(100)
914
})
1015

1116
it(`should be able to build a symlog scale for y axis`, () => {
12-
const scale = createSymlogScale({ type: 'symlog' }, { all: [], min: 0, max: 1 }, 100, 'y')
17+
const scale = createSymlogScale(
18+
{ type: 'symlog', round: true },
19+
{ all: [], min: 0, max: 1 },
20+
100,
21+
'y'
22+
)
1323

1424
expect(scale(0)).toBe(100)
1525
expect(scale(0.5)).toBe(42)
@@ -18,7 +28,7 @@ it(`should be able to build a symlog scale for y axis`, () => {
1828

1929
it(`should allow to define min value for x axis`, () => {
2030
const scale = createSymlogScale(
21-
{ type: 'symlog', min: 0.5 },
31+
{ type: 'symlog', min: 0.5, round: true },
2232
{ all: [], min: 0, max: 1 },
2333
100,
2434
'x'
@@ -32,7 +42,7 @@ it(`should allow to define min value for x axis`, () => {
3242

3343
it(`should allow to define min value for y axis`, () => {
3444
const scale = createSymlogScale(
35-
{ type: 'symlog', min: 0.5 },
45+
{ type: 'symlog', min: 0.5, round: true },
3646
{ all: [], min: 0, max: 1 },
3747
100,
3848
'y'
@@ -46,7 +56,7 @@ it(`should allow to define min value for y axis`, () => {
4656

4757
it(`should allow to define max value for x axis`, () => {
4858
const scale = createSymlogScale(
49-
{ type: 'symlog', max: 2 },
59+
{ type: 'symlog', max: 2, round: true },
5060
{ all: [], min: 0, max: 1 },
5161
100,
5262
'x'
@@ -60,7 +70,7 @@ it(`should allow to define max value for x axis`, () => {
6070

6171
it(`should allow to define max value for y axis`, () => {
6272
const scale = createSymlogScale(
63-
{ type: 'symlog', max: 2 },
73+
{ type: 'symlog', max: 2, round: true },
6474
{ all: [], min: 0, max: 1 },
6575
100,
6676
'y'
@@ -74,7 +84,7 @@ it(`should allow to define max value for y axis`, () => {
7484

7585
it(`should allow to reverse domain`, () => {
7686
const scale = createSymlogScale(
77-
{ type: 'symlog', reverse: true },
87+
{ type: 'symlog', reverse: true, round: true },
7888
{ all: [], min: 0, max: 1 },
7989
100,
8090
'y'
@@ -87,7 +97,7 @@ it(`should allow to reverse domain`, () => {
8797

8898
it(`should allow to adjust the constant`, () => {
8999
const scale = createSymlogScale(
90-
{ type: 'symlog', constant: 0.1 },
100+
{ type: 'symlog', constant: 0.1, round: true },
91101
{ all: [], min: 0, max: 1 },
92102
100,
93103
'x'
@@ -100,7 +110,7 @@ it(`should allow to adjust the constant`, () => {
100110

101111
it(`should allow to toggle rounding`, () => {
102112
const roundedScale = createSymlogScale(
103-
{ type: 'symlog' },
113+
{ type: 'symlog', round: true },
104114
{ all: [], min: 0, max: 1 },
105115
100,
106116
'x'

packages/scatterplot/tests/ScatterPlot.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,8 @@ describe('annotations', () => {
633633
const wrapper = mount(
634634
<ScatterPlot<TestDatum>
635635
{...baseProps}
636+
xScale={{ type: 'linear', round: true, nice: false }}
637+
yScale={{ type: 'linear', round: true, nice: false }}
636638
markers={[
637639
{ axis: 'x', value: 22.5, legend: 'x marker' },
638640
{ axis: 'y', value: 15.5, legend: 'y marker' },

0 commit comments

Comments
 (0)