-
Notifications
You must be signed in to change notification settings - Fork 388
/
geopoint.test.ts
45 lines (40 loc) · 1.31 KB
/
geopoint.test.ts
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
import {describe, it} from '@jest/globals'
/* eslint-disable @typescript-eslint/no-unused-vars */
/**
* Some of these tests have no expect statement;
* use of ts-expect-error serves the same purpose - TypeScript is the testrunner here
*/
import {type GeopointDefinition, type StringDefinition} from '../definition'
import {defineType} from '../types'
describe('geopoint types', () => {
describe('defineType', () => {
it('should define geopoint schema', () => {
const geopointDef = defineType({
type: 'geopoint',
name: 'custom-geopoint',
title: 'Custom',
icon: () => null,
description: 'Description',
initialValue: () =>
Promise.resolve({
lat: 1,
lng: 2,
alt: 2,
}),
validation: (Rule) => [
Rule.required()
.required()
.custom((value) => (value?.alt === 2 ? 'Error' : true))
.warning(),
// @ts-expect-error greaterThan does not exist on geopointRule
Rule.greaterThan(5).error(),
],
hidden: () => false,
})
const assignableToGeopoint: GeopointDefinition = geopointDef
// @ts-expect-error geopoint is not assignable to string
const notAssignableToString: StringDefinition = geopointDef
})
})
})
export {}