-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgeospatial.test.js
More file actions
55 lines (41 loc) · 1.7 KB
/
geospatial.test.js
File metadata and controls
55 lines (41 loc) · 1.7 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
import { validState } from '~/src/server/plugins/engine/components/helpers/__stubs__/geospatial.js'
import { geospatialSchema } from '~/src/server/plugins/engine/components/helpers/geospatial.js'
describe('Geospatial validation helpers', () => {
test('it should not have errors for valid geojson object', () => {
const result = geospatialSchema.validate(validState)
expect(result.error).toBeUndefined()
expect(result.value).toBeDefined()
expect(result.value).toHaveLength(4)
})
test('it should not have errors for valid geojson string', () => {
const result = geospatialSchema.validate(JSON.stringify(validState))
expect(result.error).toBeUndefined()
expect(result.value).toBeDefined()
expect(result.value).toHaveLength(4)
})
test('it should have errors for invalid json string', () => {
const result = geospatialSchema.validate('{')
expect(result.error).toBeDefined()
expect(result.value).toBe('{')
})
test('it should have errors for invalid geojson string', () => {
const result = geospatialSchema.validate('[')
expect(result.error).toBeDefined()
expect(result.value).toBe('[')
})
test('it should validate an empty array', () => {
const result = geospatialSchema.validate('[]')
expect(result.error).toBeUndefined()
expect(result.value).toEqual([])
})
test('it should not validate an empty object', () => {
const result = geospatialSchema.validate('{}')
expect(result.error).toBeDefined()
expect(result.value).toBeUndefined()
})
test('it should validate an empty string', () => {
const result = geospatialSchema.validate('')
expect(result.error).toBeDefined()
expect(result.value).toBeUndefined()
})
})