-
-
Notifications
You must be signed in to change notification settings - Fork 938
Expand file tree
/
Copy pathSnapshotOptions.test.js
More file actions
77 lines (68 loc) · 2.1 KB
/
SnapshotOptions.test.js
File metadata and controls
77 lines (68 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { NativeModules } from 'react-native';
import SnapshotOptions from '../../../src/modules/snapshot/SnapshotOptions';
import { makePoint, makeFeatureCollection } from '../../../src/utils/geoUtils';
describe('SnapshotOptions', () => {
it('should throw error if no centerCoordinate or bounds are provided', () => {
expect(() => new SnapshotOptions()).toThrow();
expect(() => new SnapshotOptions({ styleURL: 'test' })).toThrow();
});
it('should create options with valid defaults', () => {
const centerCoordinate = [1, 2];
const options = new SnapshotOptions({ centerCoordinate });
expect(options.toJSON()).toEqual({
styleURL: NativeModules.RNMBXModule.StyleURL.Street,
heading: 0.0,
pitch: 0.0,
zoomLevel: 16.0,
width: 50.0,
height: 50.0,
writeToDisk: false,
centerCoordinate: JSON.stringify(makePoint(centerCoordinate)),
withLogo: true,
});
});
it('should create options with centerCoordinate', () => {
const expectedOptions = {
centerCoordinate: [1, 2],
heading: 60.0,
pitch: 45.0,
zoomLevel: 2.0,
width: 314,
height: 600,
writeToDisk: true,
withLogo: true,
styleURL: NativeModules.RNMBXModule.StyleURL.Dark,
};
const options = new SnapshotOptions(expectedOptions);
expect(options.toJSON()).toEqual({
...expectedOptions,
centerCoordinate: JSON.stringify(
makePoint(expectedOptions.centerCoordinate),
),
});
});
it('should create options with bounds', () => {
const expectedOptions = {
bounds: [
[1, 2],
[3, 4],
],
width: 400,
height: 600,
styleURL: NativeModules.RNMBXModule.StyleURL.Light,
writeToDisk: false,
withLogo: true,
};
const geoJSONBounds = JSON.stringify(
makeFeatureCollection(expectedOptions.bounds.map(c => makePoint(c))),
);
const options = new SnapshotOptions(expectedOptions);
expect(options.toJSON()).toEqual({
...expectedOptions,
heading: 0,
pitch: 0,
zoomLevel: 16,
bounds: geoJSONBounds,
});
});
});