Skip to content

Commit e1da50c

Browse files
committed
tests
1 parent 4decda6 commit e1da50c

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

src/util/interpolate.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ describe('interpolate', () => {
125125

126126
const i11nFn = (t: number) => interpolate.projection(Globe, Mercator, t);
127127
expect(i11nFn(0.5)).toBeInstanceOf(Projection);
128-
expect(i11nFn(0.5)).toEqual(['globe', 'mercator', 0.5]);
128+
expect(i11nFn(0.5).from).toEqual({"from": "globe", "transition": 1, "to": "globe"});
129+
expect(i11nFn(0.5).to).toEqual({"from": "mercator", "transition": 1, "to": "mercator"});
130+
expect(i11nFn(0.5).transition).toEqual(0.5);
129131
});
130132

131133
describe('interpolate variableAnchorOffsetCollection', () => {

src/util/projection.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ const Mercator = pureProjFactory('mercator');
55

66
describe('Projection class', () => {
77
test('should serialize transition to string format', () => {
8-
expect(`${new Projection(Mercator, Globe, 0.2)}`).toBe('["mercator", "globe", 0.2]');
9-
expect(`${new Projection(Globe, Mercator, 0.1)}`).toBe('["globe", "mercator", 0.1]');
8+
expect(new Projection(Mercator, Globe, 0.2)).toEqual({'from': {'from': 'mercator', 'to': 'mercator', 'transition': 1}, 'to': {'from': 'globe', 'to': 'globe', 'transition': 1}, 'transition': 0.2});
9+
expect(new Projection(Globe, Mercator, 0.1)).toEqual({'from': {'from': 'globe', 'to': 'globe', 'transition': 1}, 'to': {'from': 'mercator', 'to': 'mercator', 'transition': 1}, 'transition': 0.1});
1010
});
1111

1212
test('should serialize single projection to string format', () => {
13-
expect(Mercator.toString()).toBe('mercator');
14-
expect(Globe.toString()).toBe('globe');
13+
expect(Mercator).toEqual({'from': 'mercator', 'transition': 1, 'to': 'mercator'});
14+
expect(Globe).toEqual({'from': 'globe', 'transition': 1, 'to': 'globe'});
1515
});
1616

1717
});

src/util/projection.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ export class Projection {
66

77
from: string | Projection;
88
to: string | Projection;
9-
interpolation: number;
9+
transition: number;
1010

1111
constructor(from: string | Projection, to: string | Projection, interpolation: number) {
1212
this.from = from;
1313
this.to = to;
14-
this.interpolation = interpolation;
14+
this.transition = interpolation;
1515
}
1616

1717
toString(): string {
18-
return `["${this.from}", "${this.to}", ${this.interpolation}]`;
18+
return `["${this.from}", "${this.to}", ${this.transition}]`;
1919
}
2020
}
2121

0 commit comments

Comments
 (0)