UNPKG

@sgohlke/funpara

Version:

Function parameter library for coding and testing

79 lines 2.56 kB
// 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; export { aggregateErrorFetchFunction, badRequestFetchFunction, brokenJSONFetchFunction, doNotExitFunction, fixedDateFunction, fixedResponseFetchFunction, graphQLIntrospectionDisabledFetchFunction, graphQLInvalidBodyFetchFunction, graphQLInvalidSchemaFetchFunction, internalServerErrorFetchFunction, noCallbackTimeoutFunction, notFoundFetchFunction, nowDateFunction, testDateFunction, testDateString, timeoutFetchFunction, unknownContentTypeFetchFunction }; //# sourceMappingURL=index.js.map