-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Computed To Type and Kind Guards * Version * ChangeLog
- Loading branch information
1 parent
3bd7217
commit 2c5dbab
Showing
8 changed files
with
37 additions
and
11 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,28 +1,36 @@ | ||
import { KindGuard } from '@sinclair/typebox' | ||
import { TypeGuard } from '@sinclair/typebox' | ||
import { Type } from '@sinclair/typebox' | ||
import { Assert } from '../../../assert/index' | ||
|
||
describe('guard/type/TComputed', () => { | ||
// ---------------------------------------------------------------- | ||
// Schema | ||
// ---------------------------------------------------------------- | ||
it('Should guard for Schema', () => { | ||
const T = Type.Partial(Type.Ref('A')) | ||
Assert.IsTrue(TypeGuard.IsComputed(T)) | ||
Assert.IsTrue(TypeGuard.IsSchema(T)) | ||
}) | ||
// ---------------------------------------------------------------- | ||
// Record | ||
// ---------------------------------------------------------------- | ||
it('Should guard for Record 1', () => { | ||
const T = Type.Record(Type.String(), Type.String()) | ||
Assert.IsTrue(KindGuard.IsRecord(T)) | ||
Assert.IsTrue(TypeGuard.IsRecord(T)) | ||
}) | ||
// TRecord<TRecordKey, TRef<...>> is not computed. | ||
it('Should guard for Record 3', () => { | ||
const T = Type.Record(Type.String(), Type.Ref('A')) | ||
Assert.IsTrue(KindGuard.IsRecord(T)) | ||
Assert.IsTrue(TypeGuard.IsRecord(T)) | ||
}) | ||
// TRecord<TRecordKey, TComputed<..., [TRef<...>]> is computed due to interior computed. | ||
it('Should guard for Record 3', () => { | ||
const T = Type.Record(Type.String(), Type.Partial(Type.Ref('A'))) | ||
Assert.IsTrue(KindGuard.IsComputed(T)) | ||
Assert.IsTrue(TypeGuard.IsComputed(T)) | ||
}) | ||
// TRecord<TRef<...>, TSchema> is computed as schematics may be transformed to TObject if finite | ||
it('Should guard for Record 4', () => { | ||
const T = Type.Record(Type.Ref('A'), Type.String()) | ||
Assert.IsTrue(KindGuard.IsComputed(T)) | ||
Assert.IsTrue(TypeGuard.IsComputed(T)) | ||
}) | ||
}) |