Skip to content

Commit

Permalink
test(type-utils): add conditional type tests to isTypeReadonly
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaStevens committed Jan 10, 2022
1 parent bb209f4 commit 1983d52
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions packages/type-utils/tests/isTypeReadonly.test.ts
Expand Up @@ -109,6 +109,34 @@ describe('isTypeReadonly', () => {
])('handles non fully readonly sets and maps', runTests);
});
});

describe('Conditional Types', () => {
describe('is readonly', () => {
const runTests = runTestIsReadonly;

it.each([
[
'type Test<T> = T extends readonly number[] ? readonly string[] : readonly number[];',
],
])('handles conditional type that are fully readonly', runTests);

it.each([
[
'type Test<T> = T extends number[] ? readonly string[] : readonly number[];',
],
])('should ignore mutable conditions', runTests);
});
});

describe('is not readonly', () => {
const runTests = runTestIsNotReadonly;

it.each([
['type Test<T> = T extends number[] ? string[] : number[];'],
['type Test<T> = T extends number[] ? string[] : readonly number[];'],
['type Test<T> = T extends number[] ? readonly string[] : number[];'],
])('handles non fully readonly conditional types', runTests);
});
});

describe('treatMethodsAsReadonly', () => {
Expand Down

0 comments on commit 1983d52

Please sign in to comment.