-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
46 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,39 @@ | ||
import {ProjectionDefinition} from './projection_definition'; | ||
|
||
describe('Projection class', () => { | ||
test('should parse projection with multiple inputs', () => { | ||
const projection = ProjectionDefinition.parse(['mercator', 'vertical-perspective', 0.5]); | ||
expect(projection.from).toBe('mercator'); | ||
expect(projection.to).toBe('vertical-perspective'); | ||
expect(projection.transition).toBe(0.5); | ||
}); | ||
|
||
test('should parse projection with single input', () => { | ||
const projection = ProjectionDefinition.parse('mercator'); | ||
expect(projection.from).toBe('mercator'); | ||
expect(projection.to).toBe('mercator'); | ||
expect(projection.transition).toBe(1); | ||
}); | ||
|
||
test('should return undefined when input is not an array or string', () => { | ||
const projection = ProjectionDefinition.parse({} as any); | ||
expect(projection).toBeUndefined(); | ||
}); | ||
|
||
test('should return undefined when input is an array with length not equal to 3', () => { | ||
const projection = ProjectionDefinition.parse(['mercator', 'vertical-perspective'] as any); | ||
expect(projection).toBeUndefined(); | ||
}); | ||
|
||
test('should return undefined when input is an array with non-string and non-number elements', () => { | ||
const projection = ProjectionDefinition.parse([1, 2, 3] as any); | ||
expect(projection).toBeUndefined(); | ||
}); | ||
|
||
test('should serialize projection, with [from, to, transition]', () => { | ||
expect(`${new ProjectionDefinition('mercator', 'vertical-perspective', 1)}`).toBe('["mercator", "vertical-perspective", 1]'); | ||
expect(`${new ProjectionDefinition('vertical-perspective', 'mercator', 0.3)}`).toBe('["vertical-perspective", "mercator", 0.3]'); | ||
test('should interpolate projections', () => { | ||
const projection = ProjectionDefinition.interpolate('mercator', 'vertical-perspective', 0.5); | ||
expect(projection.from).toBe('mercator'); | ||
expect(projection.to).toBe('vertical-perspective'); | ||
expect(projection.transition).toBe(0.5); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters