-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(jest-snapshot): add type tests for
SnapshotResolver
(#12788)
- Loading branch information
1 parent
dd690ca
commit 1dee273
Showing
5 changed files
with
115 additions
and
4 deletions.
There are no files selected for viewing
92 changes: 92 additions & 0 deletions
92
packages/jest-snapshot/__typetests__/jest-snapshot.test.ts
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,92 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import {expectError, expectType} from 'tsd-lite'; | ||
import type {SnapshotResolver} from 'jest-snapshot'; | ||
|
||
// SnapshotResolver | ||
|
||
const snapshotResolver: SnapshotResolver = { | ||
resolveSnapshotPath: (testPath, snapshotExtension) => { | ||
expectType<string>(testPath); | ||
expectType<string | undefined>(snapshotExtension); | ||
return 'snapshot/path'; | ||
}, | ||
|
||
resolveTestPath: (snapshotPath, snapshotExtension) => { | ||
expectType<string>(snapshotPath); | ||
expectType<string | undefined>(snapshotExtension); | ||
return 'test/path'; | ||
}, | ||
|
||
testPathForConsistencyCheck: 'test/path/example', | ||
}; | ||
|
||
// resolveSnapshotPath | ||
|
||
expectError<SnapshotResolver>({ | ||
resolveSnapshotPath: (testPath: string, snapshotExtension: boolean) => | ||
'snapshot/path', | ||
resolveTestPath: () => 'test/path', | ||
testPathForConsistencyCheck: 'test/path/example', | ||
}); | ||
|
||
expectError<SnapshotResolver>({ | ||
resolveSnapshotPath: (testPath: boolean) => 'snapshot/path', | ||
resolveTestPath: () => 'test/path', | ||
testPathForConsistencyCheck: 'test/path/example', | ||
}); | ||
|
||
expectError<SnapshotResolver>({ | ||
resolveSnapshotPath: () => true, | ||
resolveTestPath: () => 'test/path', | ||
testPathForConsistencyCheck: 'test/path/example', | ||
}); | ||
|
||
expectError<SnapshotResolver>({ | ||
resolveTestPath: () => 'test/path', | ||
testPathForConsistencyCheck: 'test/path/example', | ||
}); | ||
|
||
// resolveTestPath | ||
|
||
expectError<SnapshotResolver>({ | ||
resolveSnapshotPath: () => 'snapshot/path', | ||
resolveTestPath: (snapshotPath: string, snapshotExtension: boolean) => | ||
'test/path', | ||
testPathForConsistencyCheck: 'test/path/example', | ||
}); | ||
|
||
expectError<SnapshotResolver>({ | ||
resolveSnapshotPath: () => 'snapshot/path', | ||
resolveTestPath: (snapshotPath: boolean) => 'test/path', | ||
testPathForConsistencyCheck: 'test/path/example', | ||
}); | ||
|
||
expectError<SnapshotResolver>({ | ||
resolveSnapshotPath: () => 'snapshot/path', | ||
resolveTestPath: () => true, | ||
testPathForConsistencyCheck: 'test/path/example', | ||
}); | ||
|
||
expectError<SnapshotResolver>({ | ||
resolveSnapshotPath: () => 'snapshot/path', | ||
testPathForConsistencyCheck: 'test/path/example', | ||
}); | ||
|
||
// testPathForConsistencyCheck | ||
|
||
expectError<SnapshotResolver>({ | ||
resolveSnapshotPath: () => 'snapshot/path', | ||
resolveTestPath: () => 'test/path', | ||
testPathForConsistencyCheck: true, | ||
}); | ||
|
||
expectError<SnapshotResolver>({ | ||
resolveSnapshotPath: () => 'snapshot/path', | ||
resolveTestPath: () => 'test/path', | ||
}); |
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,12 @@ | ||
{ | ||
"extends": "../../../tsconfig.json", | ||
"compilerOptions": { | ||
"composite": false, | ||
"noUnusedLocals": false, | ||
"noUnusedParameters": false, | ||
"skipLibCheck": true, | ||
|
||
"types": [] | ||
}, | ||
"include": ["./**/*"] | ||
} |
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