-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finalize First Pass Default and Clean Tests
- Loading branch information
1 parent
c9be830
commit 6dd19d3
Showing
8 changed files
with
192 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Value } from '@sinclair/typebox/value' | ||
import { Type } from '@sinclair/typebox' | ||
import { Assert } from '../../assert/index' | ||
|
||
describe('value/clean/Uint8Array', () => { | ||
it('Should clean 1', () => { | ||
const T = Type.Uint8Array() | ||
const R = Value.Clean(T, null) | ||
Assert.IsEqual(R, null) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Value } from '@sinclair/typebox/value' | ||
import { Type } from '@sinclair/typebox' | ||
import { Assert } from '../../assert/index' | ||
|
||
describe('value/clean/Undefined', () => { | ||
it('Should clean 1', () => { | ||
const T = Type.Undefined() | ||
const R = Value.Clean(T, null) | ||
Assert.IsEqual(R, null) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
import { Value } from '@sinclair/typebox/value' | ||
import { Type } from '@sinclair/typebox' | ||
import { Assert } from '../../assert/index' | ||
|
||
describe('value/clean/Union', () => { | ||
// ---------------------------------------------------------------- | ||
// Clean | ||
// ---------------------------------------------------------------- | ||
it('Should clean 1', () => { | ||
const T = Type.Union([Type.Number(), Type.Boolean()]) | ||
const R = Value.Clean(T, null) | ||
Assert.IsEqual(R, null) | ||
}) | ||
it('Should clean 2', () => { | ||
const T = Type.Union([Type.Number(), Type.Boolean()]) | ||
const R = Value.Clean(T, 1) | ||
Assert.IsEqual(R, 1) | ||
}) | ||
it('Should clean 2', () => { | ||
const T = Type.Union([Type.Number(), Type.Boolean()]) | ||
const R = Value.Clean(T, true) | ||
Assert.IsEqual(R, true) | ||
}) | ||
// ---------------------------------------------------------------- | ||
// Clean Select | ||
// ---------------------------------------------------------------- | ||
it('Should clean select 1', () => { | ||
const X = Type.Object({ x: Type.Number() }) | ||
const Y = Type.Object({ y: Type.Number() }) | ||
const T = Type.Union([X, Y]) | ||
const R = Value.Clean(T, null) | ||
Assert.IsEqual(R, null) | ||
}) | ||
it('Should clean select 2', () => { | ||
const X = Type.Object({ x: Type.Number() }) | ||
const Y = Type.Object({ y: Type.Number() }) | ||
const T = Type.Union([X, Y]) | ||
const R = Value.Clean(T, {}) | ||
Assert.IsEqual(R, {}) | ||
}) | ||
it('Should clean select 3', () => { | ||
const X = Type.Object({ x: Type.Number() }) | ||
const Y = Type.Object({ y: Type.Number() }) | ||
const T = Type.Union([X, Y]) | ||
const R = Value.Clean(T, { x: null }) | ||
Assert.IsEqual(R, { x: null }) | ||
}) | ||
it('Should clean select 4', () => { | ||
const X = Type.Object({ x: Type.Number() }) | ||
const Y = Type.Object({ y: Type.Number() }) | ||
const T = Type.Union([X, Y]) | ||
const R = Value.Clean(T, { y: null }) | ||
Assert.IsEqual(R, { y: null }) | ||
}) | ||
// ---------------------------------------------------------------- | ||
// Clean Select Discard | ||
// ---------------------------------------------------------------- | ||
it('Should clean select discard 1', () => { | ||
const X = Type.Object({ x: Type.Number() }) | ||
const Y = Type.Object({ y: Type.Number() }) | ||
const T = Type.Union([X, Y]) | ||
const R = Value.Clean(T, null) | ||
Assert.IsEqual(R, null) | ||
}) | ||
it('Should clean select discard 2', () => { | ||
const X = Type.Object({ x: Type.Number() }) | ||
const Y = Type.Object({ y: Type.Number() }) | ||
const T = Type.Union([X, Y]) | ||
const R = Value.Clean(T, { u: null }) | ||
Assert.IsEqual(R, { u: null }) // no match | ||
}) | ||
it('Should clean select discard 3', () => { | ||
const X = Type.Object({ x: Type.Number() }) | ||
const Y = Type.Object({ y: Type.Number() }) | ||
const T = Type.Union([X, Y]) | ||
const R = Value.Clean(T, { u: null, x: 1 }) | ||
Assert.IsEqual(R, { x: 1 }) | ||
}) | ||
it('Should clean select discard 4', () => { | ||
const X = Type.Object({ x: Type.Number() }) | ||
const Y = Type.Object({ y: Type.Number() }) | ||
const T = Type.Union([X, Y]) | ||
const R = Value.Clean(T, { u: null, y: 1 }) | ||
Assert.IsEqual(R, { y: 1 }) | ||
}) | ||
// ---------------------------------------------------------------- | ||
// Clean Select Retain | ||
// ---------------------------------------------------------------- | ||
it('Should clean select retain 1', () => { | ||
const X = Type.Object({ x: Type.Number() }, { additionalProperties: Type.Null() }) | ||
const Y = Type.Object({ y: Type.Number() }, { additionalProperties: Type.Null() }) | ||
const T = Type.Union([X, Y]) | ||
const R = Value.Clean(T, null) | ||
Assert.IsEqual(R, null) | ||
}) | ||
it('Should clean select retain 2', () => { | ||
const X = Type.Object({ x: Type.Number() }, { additionalProperties: Type.Null() }) | ||
const Y = Type.Object({ y: Type.Number() }, { additionalProperties: Type.Null() }) | ||
const T = Type.Union([X, Y]) | ||
const R = Value.Clean(T, { u: null }) | ||
Assert.IsEqual(R, { u: null }) | ||
}) | ||
it('Should clean select retain 3', () => { | ||
const X = Type.Object({ x: Type.Number() }, { additionalProperties: Type.Null() }) | ||
const Y = Type.Object({ y: Type.Number() }, { additionalProperties: Type.Null() }) | ||
const T = Type.Union([X, Y]) | ||
const R = Value.Clean(T, { u: null, x: 1 }) | ||
Assert.IsEqual(R, { u: null, x: 1 }) | ||
}) | ||
it('Should clean select retain 4', () => { | ||
const X = Type.Object({ x: Type.Number() }, { additionalProperties: Type.Null() }) | ||
const Y = Type.Object({ y: Type.Number() }, { additionalProperties: Type.Null() }) | ||
const T = Type.Union([X, Y]) | ||
const R = Value.Clean(T, { u: null, y: 1 }) | ||
Assert.IsEqual(R, { u: null, y: 1 }) | ||
}) | ||
// ---------------------------------------------------------------- | ||
// Clean Select First and Discard | ||
// ---------------------------------------------------------------- | ||
it('Should clean select first and discard 1', () => { | ||
const X = Type.Object({ x: Type.Number() }) | ||
const Y = Type.Object({ y: Type.Number() }, { additionalProperties: Type.Null() }) | ||
const T = Type.Union([X, Y]) | ||
const R = Value.Clean(T, { u: null, x: 1 }) | ||
Assert.IsEqual(R, { x: 1 }) | ||
}) | ||
it('Should clean select first and discard 2', () => { | ||
const X = Type.Object({ x: Type.Number() }) | ||
const Y = Type.Object({ y: Type.Number() }, { additionalProperties: Type.Null() }) | ||
const T = Type.Union([X, Y]) | ||
const R = Value.Clean(T, { u: null, y: 1 }) | ||
Assert.IsEqual(R, { u: null, y: 1 }) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Value } from '@sinclair/typebox/value' | ||
import { Type } from '@sinclair/typebox' | ||
import { Assert } from '../../assert/index' | ||
|
||
describe('value/clean/Unknown', () => { | ||
it('Should clean 1', () => { | ||
const T = Type.Unknown() | ||
const R = Value.Clean(T, null) | ||
Assert.IsEqual(R, null) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Value } from '@sinclair/typebox/value' | ||
import { Type } from '@sinclair/typebox' | ||
import { Assert } from '../../assert/index' | ||
|
||
describe('value/clean/Void', () => { | ||
it('Should clean 1', () => { | ||
const T = Type.Void() | ||
const R = Value.Clean(T, null) | ||
Assert.IsEqual(R, null) | ||
}) | ||
}) |