UNPKG

msw-request-assertions

Version:
32 lines (30 loc) 920 B
import { jest, expect } from '@jest/globals'; import { http, graphql } from 'msw'; import { h as httpAssertions, g as graphqlAssertions } from '../index-hb7DUK3-.mjs'; for (const key in http) { const original = http[key]; http[key] = httpAssertions.reduce( (fn, { interceptHttp }) => interceptHttp ? interceptHttp(jest.fn, fn) : fn, original ); } const originalQuery = graphql.query; const originalMutation = graphql.mutation; graphql.query = graphqlAssertions.reduce( (fn, { interceptGql }) => interceptGql ? interceptGql(jest.fn, fn) : fn, originalQuery ); graphql.mutation = graphqlAssertions.reduce( (fn, { interceptGql }) => interceptGql ? interceptGql(jest.fn, fn) : fn, originalMutation ); expect.extend( [...httpAssertions, ...graphqlAssertions].reduce( (acc, { name, assert }) => { acc[name] = assert; return acc; }, {} ) ); //# sourceMappingURL=index.mjs.map