diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f6df06..94d9218 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ # Upcoming +# v0.6.0 + +Date: 2024-05-30T13:40:22.393Z + - Expose `Queries` type # v0.5.0 diff --git a/README.md b/README.md index a3d6553..884d004 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ The [tests](./src/QueryBin.test.ts) give a broad overview over the functionality example. ```typescript -import { QueryBin, QueryDefinition } from "query-bin"; +import { Queries, QueryBin } from "query-bin"; import { describe, expect, it } from "vitest"; type Method = "GET" | "PUT" | "POST" | "PATCH" | "DELETE"; @@ -44,18 +44,20 @@ interface Request { body?: Record; } -function byMethodAndUrl(method: Method, url: string): QueryDefinition { - return { - test: (item) => item.method === method && item.url.includes(url), - noneFoundMessage: `Could not find requests with method ${method} and URL containing ${url}.`, - multipleFoundMessage: `Multiple requests found method ${method} and URL containing ${url}.`, - // optional - serializeForErrorMessage: (item) => JSON.stringify(item, null, 2), - }; -} - -// This might be something -const requests = new QueryBin({ byMethodAndUrl }); +const queries = { + byMethodAndUrl: function (method: Method, url: string) { + return { + test: (item) => item.method === method && item.url.includes(url), + noneFoundMessage: `Could not find requests with method ${method} and URL containing ${url}.`, + multipleFoundMessage: `Multiple requests found method ${method} and URL containing ${url}.`, + // optional + serializeForErrorMessage: (item) => JSON.stringify(item, null, 2), + }; + }, + // This typing should be improved. Consider this interface unstable... +} as const satisfies Queries; + +const requests = new QueryBin(queries); // Let's assume we have a component under test here. describe("The Login component", () => { diff --git a/package-lock.json b/package-lock.json index b395a6d..bc6928c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "query-bin", - "version": "0.5.0", + "version": "0.6.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "query-bin", - "version": "0.5.0", + "version": "0.6.0", "funding": [ { "type": "individual", diff --git a/package.json b/package.json index 1ea40de..31ecee4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "query-bin", - "version": "0.5.0", + "version": "0.6.0", "description": "A list with queries like in the 'testing-library'", "types": "index.d.s", "type": "module",