-
Notifications
You must be signed in to change notification settings - Fork 389
/
boolean.test.ts
43 lines (38 loc) · 1.23 KB
/
boolean.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
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 BooleanDefinition} from '../definition'
import {defineType} from '../types'
describe('boolean types', () => {
describe('defineType', () => {
it('should define boolean schema', () => {
const booleanDef = defineType({
type: 'boolean',
name: 'custom-boolean',
title: 'Custom',
icon: () => null,
description: 'Description',
initialValue: () => Promise.resolve(true),
validation: (Rule) => [
Rule.required()
.required()
.custom(() => true)
.warning(),
// @ts-expect-error greaterThan does not exist on BooleanRule
Rule.greaterThan(5).error(),
],
hidden: () => false,
options: {
layout: 'checkbox',
},
})
const assignableToBoolean: BooleanDefinition = booleanDef
// @ts-expect-error boolean is not assignable to string
const notAssignableToString: StringDefinition = booleanDef
})
})
})
export {}