-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ján Naništa
committed
Apr 24, 2021
1 parent
86e240d
commit dae92d9
Showing
8 changed files
with
100 additions
and
10 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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
4.2.3 | ||
4.1.5 | ||
4.0.7 | ||
3.9.2 | ||
3.8.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 @@ | ||
module.exports = require('../../jest.config'); |
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 @@ | ||
{ | ||
"name": "@ts-type-checked/test--typescript--4.2.3", | ||
"version": "0.0.1", | ||
"private": true, | ||
"peerDependencies": { | ||
"typescript": ">=4.2.3" | ||
}, | ||
"dependencies": { | ||
"ts-type-checked": "file:../../../dist" | ||
}, | ||
"devDependencies": { | ||
"ts-reflection": "^0.3.0" | ||
} | ||
} |
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,45 @@ | ||
import 'jest'; | ||
|
||
import { assert, notAnArray, notAnEmptyArray, notOfType, numeric, oneOf, primitive } from '../../../utils/utils.v2'; | ||
import { isA, typeCheckFor } from 'ts-type-checked'; | ||
import fc from 'fast-check'; | ||
|
||
describe('Tuples', () => { | ||
// test('With optional elements', () => { | ||
// type TypeReference1 = [string, number, boolean?]; | ||
|
||
// const validArbitrary: fc.Arbitrary<TypeReference1> = oneOf<TypeReference1>( | ||
// fc.tuple(fc.string(), numeric()), | ||
// fc.tuple(fc.string(), numeric(), fc.boolean()), | ||
// ); | ||
// const invalidArbitrary = oneOf<unknown>( | ||
// primitive(), | ||
// fc.anything().filter(notAnArray), | ||
// fc.array(numeric()), | ||
// fc.tuple(fc.string(), fc.string()), | ||
// fc.tuple(numeric(), numeric()), | ||
// fc.tuple(fc.string(), numeric(), fc.anything().filter(notOfType('boolean'))), | ||
// fc.constantFrom(["string", "string"], [6, 6], ["string", 7, 7]), | ||
// ); | ||
|
||
// assert(validArbitrary, invalidArbitrary, [typeCheckFor<TypeReference1>(), (value) => isA<TypeReference1>(value)]); | ||
// }); | ||
|
||
test('With rest elements at the beginning', () => { | ||
type TypeReference1 = [...boolean[], string]; | ||
|
||
const validArbitrary: fc.Arbitrary<TypeReference1> = oneOf<TypeReference1>( | ||
fc.tuple(fc.string()), | ||
fc.array(fc.boolean()).chain((booleans) => fc.string().map((string) => [...booleans, string])), | ||
); | ||
const invalidArbitrary = oneOf<unknown>( | ||
primitive(), | ||
fc | ||
.array(fc.anything().filter(notOfType('boolean')).filter(notAnEmptyArray)) | ||
.chain((values) => fc.string().map((string) => [...values, string])), | ||
fc.constantFrom([6, 'string']), | ||
); | ||
|
||
assert(validArbitrary, invalidArbitrary, [typeCheckFor<TypeReference1>(), (value) => isA<TypeReference1>(value)]); | ||
}); | ||
}); |
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,7 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"target": "ESNext" | ||
} | ||
} |