Skip to content

Commit

Permalink
adding two more tests (#768)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasoppermann authored Oct 16, 2023
1 parent c773fcb commit 277faaf
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/schemas/baseTokenSchema.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {baseToken} from './baseToken'

describe('Schema: baseToken', () => {
const validToken = {
$description: 'a base token',
}

it('passes on valid values', () => {
expect(baseToken.safeParse(validToken).success).toStrictEqual(true)
})

it('fails on invalid property', () => {
expect(baseToken.safeParse({...validToken, $type: 'stroke'}).success).toStrictEqual(false)
expect(baseToken.safeParse({...validToken, $value: 'wrong'}).success).toStrictEqual(false)
expect(baseToken.safeParse({...validToken, $additional: undefined}).success).toStrictEqual(false)
})
})
27 changes: 27 additions & 0 deletions src/schemas/colorTokenSchema.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {colorToken} from './colorToken'

describe('Schema: colorToken', () => {
const validToken = {
$value: '#00ff88',
$type: 'color',
$description: 'a color token',
}

it('passes on valid values', () => {
expect(colorToken.safeParse(validToken).success).toStrictEqual(true)
expect(colorToken.safeParse({...validToken, $value: '#000'}).success).toStrictEqual(true)
expect(colorToken.safeParse({...validToken, $value: '#11223366'}).success).toStrictEqual(true)
})

it('fails on invalid type', () => {
expect(colorToken.safeParse({...validToken, $type: 'stroke'}).success).toStrictEqual(false)
})

it('fails on invalid value', () => {
expect(colorToken.safeParse({...validToken, $value: 'wrong'}).success).toStrictEqual(false)
expect(colorToken.safeParse({...validToken, $value: undefined}).success).toStrictEqual(false)
expect(colorToken.safeParse({...validToken, $value: ''}).success).toStrictEqual(false)
expect(colorToken.safeParse({...validToken, $value: false}).success).toStrictEqual(false)
expect(colorToken.safeParse({...validToken, $value: 1}).success).toStrictEqual(false)
})
})

0 comments on commit 277faaf

Please sign in to comment.