@thisisagile/easy-test
Version:
Straightforward library for testing microservices built with @thisisagile/easy
1 lines • 1.43 kB
Source Map (JSON)
{"version":3,"sources":["../../src/matchers/toBeArrayOfWithLength.ts"],"sourcesContent":["import { Constructor as Ctor } from '../utils/Types';\nimport { match } from './Match';\n\nexport const toBeArrayOfWithLength = <T>(items: unknown, ctor: Ctor<T>, length: number): jest.CustomMatcherResult =>\n match<unknown>(items)\n .undefined(it => it, 'Subject is undefined.')\n .not(it => it instanceof Array, 'Subject is not an array.')\n .not(\n it => (it as []).length === length,\n it => `Subject does not have ${length} elements, but ${(it as []).length}.`\n )\n .not(it => (it as []).every((i: any) => i instanceof ctor), `Not all elements are of type '${ctor.name}'.`)\n .else(`Subject has ${length} elements, which are all of type '${ctor.name}'`);\n\nexpect.extend({\n toBeArrayOfWithLength,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toBeArrayOfWithLength<Z>(ctor: Ctor<Z>, length: number): R;\n }\n }\n}\n"],"mappings":";;;;;;;AAGO,IAAM,wBAAwB,CAAI,OAAgB,MAAe,WACtE,MAAe,KAAK,EACjB,UAAU,QAAM,IAAI,uBAAuB,EAC3C,IAAI,QAAM,cAAc,OAAO,0BAA0B,EACzD;AAAA,EACC,QAAO,GAAU,WAAW;AAAA,EAC5B,QAAM,yBAAyB,MAAM,kBAAmB,GAAU,MAAM;AAC1E,EACC,IAAI,QAAO,GAAU,MAAM,CAAC,MAAW,aAAa,IAAI,GAAG,iCAAiC,KAAK,IAAI,IAAI,EACzG,KAAK,eAAe,MAAM,qCAAqC,KAAK,IAAI,GAAG;AAEhF,OAAO,OAAO;AAAA,EACZ;AACF,CAAC;","names":[]}