Skip to content

Commit

Permalink
Additional Object Conversion Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sinclairzx81 committed Apr 24, 2024
1 parent 94924b7 commit a08332b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion test/runtime/value/convert/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Value } from '@sinclair/typebox/value'
import { Type } from '@sinclair/typebox'
import { Assert } from '../../assert/index'

// prettier-ignore
describe('value/convert/Object', () => {
it('Should convert properties', () => {
// prettier-ignore
const T = Type.Object({
x: Type.Number(),
y: Type.Boolean(),
Expand All @@ -13,4 +13,21 @@ describe('value/convert/Object', () => {
const R = Value.Convert(T, { x: '42', y: 'true', z: 'hello' })
Assert.IsEqual(R, { x: 42, y: true, z: 'hello' })
})
it('Should convert known properties', () => {
const T = Type.Object({
x: Type.Number(),
y: Type.Boolean()
})
const R = Value.Convert(T, { x: '42', y: 'true', z: 'hello' })
Assert.IsEqual(R, { x: 42, y: true, z: 'hello' })
})
it('Should mutate object on conversion', () => {
const T = Type.Object({
x: Type.Number(),
y: Type.Boolean()
})
const value = { x: '42', y: 'true', z: 'hello' }
Value.Convert(T, value)
Assert.IsEqual(value, { x: 42, y: true, z: 'hello' })
})
})

0 comments on commit a08332b

Please sign in to comment.