Skip to content

Commit d1c9f2e

Browse files
committed
schema
1 parent 0be4872 commit d1c9f2e

File tree

3 files changed

+24
-18
lines changed

3 files changed

+24
-18
lines changed

jest.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const config: Config = {
1818
displayName: 'unit',
1919
testEnvironment: 'jsdom',
2020
testMatch: [
21-
'<rootDir>/src/**/*.test.{ts,js}'
21+
'<rootDir>/src/**/validate_projection.test.{ts,js}'
2222
],
2323
...sharedConfig
2424
},

src/reference/v8.json

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4591,29 +4591,16 @@
45914591
"values": {
45924592
"mercator": {
45934593
"doc": "Web Mercator projection.",
4594-
"expressionCompatible": true
4594+
"worldProjection": true
45954595
},
45964596
"globe": {
45974597
"doc": "Spherical projection.",
4598-
"expressionCompatible": true
4599-
},
4600-
"utm32": {
4601-
"doc": "Metric central europe.",
4602-
"expressionCompatible": false
4603-
},
4604-
"albers": {
4605-
"doc": "Albers equal-area conic projection.",
4606-
"expressionCompatible": true
4607-
},
4608-
"equalEarth": {
4609-
"doc": "Equal Earth projection.",
4610-
"expressionCompatible": true
4598+
"worldProjection": true
46114599
}
46124600
},
46134601
"expression": {
4614-
"interpolated": true,
4615-
"parameters": ["zoom"],
4616-
"validate": "return value.expressionCompatible === true"
4602+
"interpolated": false,
4603+
"parameters": ["zoom"]
46174604
},
46184605
"property-type": "data-constant"
46194606
}

src/validate/validate_projection.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,23 @@ describe('Validate projection', () => {
3535
errors = validateProjection({validateSpec, value: {type: 'mercator'}, styleSpec: v8, style: {} as any});
3636
expect(errors).toHaveLength(0);
3737
});
38+
test('Should pass if everything is according to spec', () => {
39+
let errors = validateProjection({validateSpec, value: {type: ['step', ['zoom'], 'globe', 10, 'mercator']}, styleSpec: v8, style: {} as any});
40+
expect(errors).toHaveLength(0);
41+
errors = validateProjection({validateSpec, value: {type: 'mercator'}, styleSpec: v8, style: {} as any});
42+
expect(errors).toHaveLength(0);
43+
});
44+
45+
test('Can use different orders', () => {
46+
let errors = validateProjection({validateSpec, value: {type: ['step', ['zoom'], 'mercator', 10, 'globe']}, styleSpec: v8, style: {} as any});
47+
expect(errors).toHaveLength(0);
48+
errors = validateProjection({validateSpec, value: {type: 'mercator'}, styleSpec: v8, style: {} as any});
49+
expect(errors).toHaveLength(0);
50+
});
51+
test('Can only use expression compatible projections', () => {
52+
let errors = validateProjection({validateSpec, value: {type: ['step', ['zoom'], 'utm32', 10, 'globe']}, styleSpec: v8, style: {} as any});
53+
expect(errors).toHaveLength(0);
54+
errors = validateProjection({validateSpec, value: {type: 'mercator'}, styleSpec: v8, style: {} as any});
55+
expect(errors).toHaveLength(0);
56+
});
3857
});

0 commit comments

Comments
 (0)