Skip to content

Commit

Permalink
feat: add generic filtering capabalities to getPubsWithRelatedValues
Browse files Browse the repository at this point in the history
  • Loading branch information
tefkah committed Feb 24, 2025
1 parent 5800782 commit 2cb8148
Show file tree
Hide file tree
Showing 6 changed files with 1,055 additions and 3 deletions.
8 changes: 6 additions & 2 deletions core/lib/__tests__/matchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import type { db } from "~/kysely/database";

const deepSortValues = (pub: ProcessedPub): ProcessedPub => {
pub.values
.sort((a, b) => (a.value as string).localeCompare(b.value as string))
.sort((a, b) => {
const aValue = String(a.value);
const bValue = String(b.value);
return aValue.localeCompare(bValue);
})
.map((item) => ({
...item,
relatedPub: item.relatedPub?.values ? deepSortValues(item.relatedPub) : item.relatedPub,
Expand Down Expand Up @@ -60,7 +64,7 @@ expect.extend({
message: () =>
pass
? `Expected pub ${isNot ? "not" : ""} to have values ${JSON.stringify(expected)}, and it does ${isNot ? "not" : ""}`
: `Expected pub ${isNot ? "not to" : "to"} match values ${this.utils.diff(sortedPubValues.values, expected)}`,
: `Expected pub ${isNot ? "not to" : "to"} match values ${this.utils.diff(expected, sortedPubValues.values)}`,
};
},
});
Loading

0 comments on commit 2cb8148

Please sign in to comment.