-
Notifications
You must be signed in to change notification settings - Fork 389
/
email.test.ts
36 lines (31 loc) · 1.09 KB
/
email.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
import {describe, it} from '@jest/globals'
/* eslint-disable @typescript-eslint/no-unused-vars */
import {type BooleanDefinition, type EmailDefinition} from '../definition'
import {defineType} from '../types'
describe('email types', () => {
describe('defineType', () => {
it('should define email schema', () => {
const emailDef = defineType({
type: 'email',
name: 'custom-email',
title: 'Custom email',
description: 'Description',
placeholder: 'daff',
initialValue: () => Promise.resolve('email'),
validation: (Rule) => [
Rule.required()
.custom((value) => (value?.toUpperCase() == 'SHOUT' ? 'Error' : true))
.warning(),
// @ts-expect-error greaterThan is not on emailRule
Rule.greaterThan(5).error(),
],
hidden: () => false,
readOnly: () => false,
})
const assignableToEmail: EmailDefinition = emailDef
// @ts-expect-error email is not assignable to boolean
const notAssignableToBoolean: BooleanDefinition = emailDef
})
})
})
export {}