UNPKG

type-fns

Version:

A set of types, type checks, and type guards for simpler, safer, and easier to read code.

37 lines 1.93 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const test_fns_1 = require("test-fns"); describe('ArrayWith', () => { (0, test_fns_1.given)('desire for array with min length', () => { (0, test_fns_1.then)('we can declare the type', () => { let products; }); (0, test_fns_1.then)('it allows arrays of exactly the min length to it', () => { const products = ['doughnut']; // 🍩 }); (0, test_fns_1.then)('it allows arrays with more than the min length to it', () => { const products = ['doughnut', 'waffle']; // 🍩, 🧇 }); (0, test_fns_1.then)('it blocks arrays with less than the min length to it', () => { // @ts-expect-error; Type '[]' is not assignable to type '[string, ...string[]]'. Source has 0 element(s) but target requires 1.ts(2322) const products = []; // 🍩, 🧇 }); }); (0, test_fns_1.given)('desire for array with exact length', () => { (0, test_fns_1.then)('we can declare the type', () => { let products; }); (0, test_fns_1.then)('it allows arrays of exactly the desired length to it', () => { const products = ['doughnut']; // 🍩 }); (0, test_fns_1.then)('it allows arrays with more than the desired length to it', () => { // @ts-expect-error; Type '[string, string]' is not assignable to type '[string]'.Source has 2 element(s) but target allows only 1. const products = ['doughnut', 'waffle']; // 🍩, 🧇 }); (0, test_fns_1.then)('it blocks arrays with less than the desired length to it', () => { // @ts-expect-error; Type '[]' is not assignable to type '[string]'. Source has 0 element(s) but target requires 1.ts(2322) const products = []; }); }); }); //# sourceMappingURL=ArrayWith.test.js.map