Skip to content

Commit

Permalink
0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nknapp committed May 30, 2024
1 parent 6d85f76 commit 32a5282
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

# Upcoming

# v0.6.0

Date: 2024-05-30T13:40:22.393Z

- Expose `Queries` type

# v0.5.0
Expand Down
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -44,18 +44,20 @@ interface Request {
body?: Record<string, unknown>;
}

function byMethodAndUrl(method: Method, url: string): QueryDefinition<Request> {
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<Request>({ 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<Request>;

const requests = new QueryBin<Request, typeof queries>(queries);

// Let's assume we have a component under test here.
describe("The Login component", () => {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 32a5282

Please sign in to comment.