-
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.
Clean Tests | Updates to Default Handling
- Loading branch information
1 parent
4f6f41d
commit 959fc8e
Showing
22 changed files
with
275 additions
and
32 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/Any', () => { | ||
it('Should clean 1', () => { | ||
const T = Type.Any() | ||
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,21 @@ | ||
import { Value } from '@sinclair/typebox/value' | ||
import { Type } from '@sinclair/typebox' | ||
import { Assert } from '../../assert/index' | ||
|
||
describe('value/clean/Array', () => { | ||
it('Should clean 1', () => { | ||
const T = Type.Any() | ||
const R = Value.Clean(T, null) | ||
Assert.IsEqual(R, null) | ||
}) | ||
it('Should clean 2', () => { | ||
const T = Type.Array( | ||
Type.Object({ | ||
x: Type.Number(), | ||
y: Type.Number(), | ||
}), | ||
) | ||
const R = Value.Clean(T, [undefined, null, { x: 1 }, { x: 1, y: 2 }, { x: 1, y: 2, z: 3 }]) | ||
Assert.IsEqual(R, [undefined, null, { x: 1 }, { x: 1, y: 2 }, { x: 1, y: 2 }]) | ||
}) | ||
}) |
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/AsyncIterator', () => { | ||
it('Should clean 1', () => { | ||
const T = Type.AsyncIterator(Type.Number()) | ||
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/BigInt', () => { | ||
it('Should clean 1', () => { | ||
const T = Type.BigInt() | ||
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/Boolean', () => { | ||
it('Should clean 1', () => { | ||
const T = Type.Boolean() | ||
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/Composite', () => { | ||
it('Should clean 1', () => { | ||
const T = Type.Composite([Type.Object({ x: Type.Number() }), Type.Object({ y: Type.Number() })]) | ||
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/Constructor', () => { | ||
it('Should clean 1', () => { | ||
const T = Type.Constructor([Type.Object({ x: Type.Number() }), Type.Object({ y: Type.Number() })], Type.Object({ z: Type.Number() })) | ||
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/Enum', () => { | ||
it('Should clean 1', () => { | ||
const T = Type.Enum({ x: 1, y: 2 }) | ||
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/Function', () => { | ||
it('Should clean 1', () => { | ||
const T = Type.Function([Type.Object({ x: Type.Number() }), Type.Object({ y: Type.Number() })], Type.Object({ z: Type.Number() })) | ||
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,10 @@ | ||
import './any' | ||
import './array' | ||
import './async-iterator' | ||
import './bigint' | ||
import './boolean' | ||
import './composite' | ||
import './enum' | ||
import './function' | ||
import './integer' | ||
import './intersect' |
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/Integer', () => { | ||
it('Should clean 1', () => { | ||
const T = Type.Integer() | ||
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,26 @@ | ||
import { Value } from '@sinclair/typebox/value' | ||
import { Type } from '@sinclair/typebox' | ||
import { Assert } from '../../assert/index' | ||
|
||
describe('value/clean/Intersect', () => { | ||
it('Should clean 1', () => { | ||
const T = Type.Intersect([Type.Object({ x: Type.Number() }), Type.Object({ y: Type.Number() })]) | ||
const R = Value.Clean(T, null) | ||
Assert.IsEqual(R, null) | ||
}) | ||
it('Should clean 2', () => { | ||
const T = Type.Intersect([Type.Object({ x: Type.Number() }), Type.Object({ y: Type.Number() })]) | ||
const R = Value.Clean(T, {}) | ||
Assert.IsEqual(R, {}) | ||
}) | ||
it('Should clean 3', () => { | ||
const T = Type.Intersect([Type.Object({ x: Type.Number() }), Type.Object({ y: Type.Number() })]) | ||
const R = Value.Clean(T, { x: 1, y: 2 }) | ||
Assert.IsEqual(R, { x: 1, y: 2 }) | ||
}) | ||
it('Should clean 4', () => { | ||
const T = Type.Intersect([Type.Object({ x: Type.Number() }), Type.Object({ y: Type.Number() })]) | ||
const R = Value.Clean(T, { x: 1, y: 2, z: 3 }) | ||
Assert.IsEqual(R, { x: 1, y: 2 }) | ||
}) | ||
}) |
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,14 @@ | ||
import { Value } from '@sinclair/typebox/value' | ||
import { Type } from '@sinclair/typebox' | ||
import { Assert } from '../../assert/index' | ||
|
||
describe('value/create/Date', () => { | ||
it('Should create value', () => { | ||
const T = Type.Date() | ||
Assert.IsInstanceOf(Value.Create(T), Date) | ||
}) | ||
it('Should create default', () => { | ||
const T = Type.Date({ default: 1 }) | ||
Assert.IsEqual(Value.Create(T), 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
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,16 @@ | ||
import { Value } from '@sinclair/typebox/value' | ||
import { Type } from '@sinclair/typebox' | ||
import { Assert } from '../../assert/index' | ||
|
||
describe('value/default/Date', () => { | ||
it('Should use default', () => { | ||
const T = Type.Date({ default: 1 }) | ||
const R = Value.Default(T, undefined) | ||
Assert.IsEqual(R, 1) | ||
}) | ||
it('Should use value', () => { | ||
const T = Type.Date({ default: 1 }) | ||
const R = Value.Default(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
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,16 @@ | ||
import { Value } from '@sinclair/typebox/value' | ||
import { Type } from '@sinclair/typebox' | ||
import { Assert } from '../../assert/index' | ||
|
||
describe('value/default/Promise', () => { | ||
it('Should use default', () => { | ||
const T = Type.Any({ default: 1 }) | ||
const R = Value.Default(T, undefined) | ||
Assert.IsEqual(R, 1) | ||
}) | ||
it('Should use value', () => { | ||
const T = Type.Any({ default: 1 }) | ||
const R = Value.Default(T, null) | ||
Assert.IsEqual(R, null) | ||
}) | ||
}) |
Oops, something went wrong.