@thisisagile/easy-test
Version:
Straightforward library for testing microservices built with @thisisagile/easy
1 lines • 1.36 kB
Source Map (JSON)
{"version":3,"sources":["../../src/matchers/toMatchExactJson.ts"],"sourcesContent":["import { match } from './Match';\nimport { eq } from '../utils/Eq';\n\nexport const MatchesExactJson = {\n SubjectUndefined: 'Subject is undefined.',\n SubsetUndefined: 'Object to match with is undefined.',\n DoesNotMatch: 'Object does not exactly match subject.',\n Yes: 'Object matches subject exactly',\n};\n\nexport const toMatchExactJson = (value?: unknown, json?: unknown): jest.CustomMatcherResult =>\n match<unknown>(value)\n .undefined(v => v, MatchesExactJson.SubjectUndefined)\n .undefined(() => json, MatchesExactJson.SubsetUndefined)\n .not(v => eq.exact(v, json), MatchesExactJson.DoesNotMatch)\n .else(() => MatchesExactJson.Yes);\n\nexpect.extend({\n toMatchExactJson: toMatchExactJson,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toMatchExactJson(json?: unknown): R;\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAGO,IAAM,mBAAmB;AAAA,EAC9B,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,cAAc;AAAA,EACd,KAAK;AACP;AAEO,IAAM,mBAAmB,CAAC,OAAiB,SAChD,MAAe,KAAK,EACjB,UAAU,OAAK,GAAG,iBAAiB,gBAAgB,EACnD,UAAU,MAAM,MAAM,iBAAiB,eAAe,EACtD,IAAI,OAAK,GAAG,MAAM,GAAG,IAAI,GAAG,iBAAiB,YAAY,EACzD,KAAK,MAAM,iBAAiB,GAAG;AAEpC,OAAO,OAAO;AAAA,EACZ;AACF,CAAC;","names":[]}