UNPKG

@sgohlke/funpara

Version:

Function parameter library for coding and testing

79 lines (61 loc) 3.2 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/index.ts function nowDateFunction() { return () => /* @__PURE__ */ new Date(); } function fixedDateFunction(dateString) { return () => new Date(dateString); } var testDateString = "1001-01-01T00:00:00.000Z"; var testDateFunction = fixedDateFunction(testDateString); function fixedResponseFetchFunction(bodyInit, init) { return () => Promise.resolve(new Response(bodyInit, init)); } var badRequestFetchFunction = fixedResponseFetchFunction(void 0, { status: 400 }); var notFoundFetchFunction = fixedResponseFetchFunction( void 0, { status: 404 } ); var internalServerErrorFetchFunction = fixedResponseFetchFunction(void 0, { status: 500 }); var brokenJSONFetchFunction = fixedResponseFetchFunction( '{"data": {"message": "Missing bracket"}', { headers: { "Content-Type": "application/json" }, status: 200 } ); var unknownContentTypeFetchFunction = fixedResponseFetchFunction(void 0, { headers: { "Content-Type": "application/unknown" }, status: 200 }); var timeoutFetchFunction = () => new Promise(() => { throw new Error("Connection failed ETIMEDOUT"); }); var aggregateErrorFetchFunction = fixedResponseFetchFunction( '{"errors":[{"message":"aaa The first error!, The second error!", "originalError": {"errors": [{"message":"The first error!"}, {"message":"The second error!"} ] } }]}', { headers: { "Content-Type": "application/json" }, status: 200 } ); var graphQLIntrospectionDisabledFetchFunction = fixedResponseFetchFunction( '{"errors": [ { "message": "Introspection is disabled"}],"data": null}', { status: 200 } ); var graphQLInvalidSchemaFetchFunction = fixedResponseFetchFunction( '{"data": {"__schema":"NotAGraphQLSchema", "_service": {"sdl":"NotAGraphQLSchema"}}}', { status: 200 } ); var graphQLInvalidBodyFetchFunction = fixedResponseFetchFunction( '{"message": "I am not GraphQL!"}', { status: 200 } ); var doNotExitFunction = (code) => { throw new Error(`Exit function was called with code ${code}`); }; var noCallbackTimeoutFunction = () => 1; exports.aggregateErrorFetchFunction = aggregateErrorFetchFunction; exports.badRequestFetchFunction = badRequestFetchFunction; exports.brokenJSONFetchFunction = brokenJSONFetchFunction; exports.doNotExitFunction = doNotExitFunction; exports.fixedDateFunction = fixedDateFunction; exports.fixedResponseFetchFunction = fixedResponseFetchFunction; exports.graphQLIntrospectionDisabledFetchFunction = graphQLIntrospectionDisabledFetchFunction; exports.graphQLInvalidBodyFetchFunction = graphQLInvalidBodyFetchFunction; exports.graphQLInvalidSchemaFetchFunction = graphQLInvalidSchemaFetchFunction; exports.internalServerErrorFetchFunction = internalServerErrorFetchFunction; exports.noCallbackTimeoutFunction = noCallbackTimeoutFunction; exports.notFoundFetchFunction = notFoundFetchFunction; exports.nowDateFunction = nowDateFunction; exports.testDateFunction = testDateFunction; exports.testDateString = testDateString; exports.timeoutFetchFunction = timeoutFetchFunction; exports.unknownContentTypeFetchFunction = unknownContentTypeFetchFunction; //# sourceMappingURL=index.cjs.map