mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:40:44 +00:00
test: stabilize directory id sorting
This commit is contained in:
@@ -36,7 +36,17 @@ async function expectDirectoryIds(
|
||||
) {
|
||||
const entries = await listDirectoryEntriesWithDefaults(listFn, cfg);
|
||||
const ids = entries.map((entry) => entry.id);
|
||||
expect(options?.sorted ? ids.toSorted((a, b) => a.localeCompare(b)) : ids).toEqual(expected);
|
||||
expect(options?.sorted ? sortDirectoryIds(ids) : ids).toEqual(
|
||||
options?.sorted ? sortDirectoryIds(expected) : expected,
|
||||
);
|
||||
}
|
||||
|
||||
function compareDirectoryIds(left: string, right: string) {
|
||||
return left < right ? -1 : left > right ? 1 : 0;
|
||||
}
|
||||
|
||||
function sortDirectoryIds(values: string[]) {
|
||||
return values.toSorted(compareDirectoryIds);
|
||||
}
|
||||
|
||||
describe("Discord directory contract", () => {
|
||||
|
||||
@@ -31,7 +31,17 @@ async function expectDirectoryIds(
|
||||
) {
|
||||
const entries = await listDirectoryEntriesWithDefaults(listFn, cfg);
|
||||
const ids = entries.map((entry) => entry.id);
|
||||
expect(options?.sorted ? ids.toSorted((a, b) => a.localeCompare(b)) : ids).toEqual(expected);
|
||||
expect(options?.sorted ? sortDirectoryIds(ids) : ids).toEqual(
|
||||
options?.sorted ? sortDirectoryIds(expected) : expected,
|
||||
);
|
||||
}
|
||||
|
||||
function compareDirectoryIds(left: string, right: string) {
|
||||
return left < right ? -1 : left > right ? 1 : 0;
|
||||
}
|
||||
|
||||
function sortDirectoryIds(values: string[]) {
|
||||
return values.toSorted(compareDirectoryIds);
|
||||
}
|
||||
|
||||
describe("Slack directory contract", () => {
|
||||
|
||||
@@ -36,12 +36,19 @@ async function expectDirectoryIds(
|
||||
) {
|
||||
const entries = await listDirectoryEntriesWithDefaults(listFn, cfg);
|
||||
const ids = entries.map((entry) => entry.id);
|
||||
const sortIds = (values: string[]) => values.toSorted((a, b) => a.localeCompare(b));
|
||||
expect(options?.sorted ? sortIds(ids) : ids).toEqual(
|
||||
options?.sorted ? sortIds(expected) : expected,
|
||||
expect(options?.sorted ? sortDirectoryIds(ids) : ids).toEqual(
|
||||
options?.sorted ? sortDirectoryIds(expected) : expected,
|
||||
);
|
||||
}
|
||||
|
||||
function compareDirectoryIds(left: string, right: string) {
|
||||
return left < right ? -1 : left > right ? 1 : 0;
|
||||
}
|
||||
|
||||
function sortDirectoryIds(values: string[]) {
|
||||
return values.toSorted(compareDirectoryIds);
|
||||
}
|
||||
|
||||
describe("Telegram directory contract", () => {
|
||||
it("keeps public probe and token resolution aligned with base contracts", () => {
|
||||
expectTypeOf<TelegramProbe>().toMatchTypeOf<BaseProbeResult>();
|
||||
|
||||
Reference in New Issue
Block a user