diff --git a/tests/random/draw.test-d.ts b/tests/random/draw.test-d.ts index 3264a1d7..4e127fb0 100644 --- a/tests/random/draw.test-d.ts +++ b/tests/random/draw.test-d.ts @@ -2,30 +2,27 @@ import * as _ from 'radashi' import { expectTypeOf } from 'vitest' describe('draw types', () => { - test('returns null given empty input', () => { - const list: unknown[] = [] - const result = _.draw(list) - expect(result).toBeNull() - }) - test('return type is null for empty array literal', () => { + test('return type with literal argument', () => { expectTypeOf(_.draw([])).toBeNull() - }) - test('return type is not null for non-empty array literal', () => { expectTypeOf(_.draw([1, 2, 3])).toBeNumber() }) - test('return type is possibly null for mutable array variables', () => { + test('return type with mutable variable', () => { + const neverList: never[] = [] const emptyList: number[] = [] const filledList = [1, 2, 3] + + expectTypeOf(_.draw(neverList)).toEqualTypeOf() expectTypeOf(_.draw(emptyList)).toEqualTypeOf() expectTypeOf(_.draw(filledList)).toEqualTypeOf() }) - test('return type is possibly null for immutable empty array variables', () => { + test('return type with immutable variable', () => { + const neverList: never[] = [] as const const emptyList: number[] = [] as const - // FIXME: Can be narrowed to `null` + const filledList = [1, 2, 3] as const + + expectTypeOf(_.draw(neverList)).toBeNull() + // FIXME: Can this be narrowed to `null`? expectTypeOf(_.draw(emptyList)).toEqualTypeOf() - }) - test('return type is not null for immutable non-empty array variables', () => { - const filledList = [1, 2, 4] as const - expectTypeOf(_.draw(filledList)).toEqualTypeOf<1 | 2 | 4>() + expectTypeOf(_.draw(filledList)).toEqualTypeOf<1 | 2 | 3>() }) })