1
0
forked from Kieran/snort
snort/packages/system/tests/outbox-model.test.ts

44 lines
988 B
TypeScript
Raw Normal View History

import { splitAllByWriteRelays } from "../src/outbox-model";
2023-06-13 10:40:09 +00:00
describe("OutboxModel", () => {
2023-07-22 18:37:46 +00:00
it("should not output empty", () => {
const Relays = {
getFromCache: (pk?: string) => {
if (pk) {
return {
pubkey: pk,
created: 0,
loaded: 0,
2023-07-22 18:37:46 +00:00
relays: [],
};
2023-06-13 10:40:09 +00:00
}
2023-07-22 18:37:46 +00:00
},
update: () => {
return Promise.resolve<"new" | "updated" | "refresh" | "no_change">("new");
},
buffer: () => {
return Promise.resolve<Array<string>>([]);
},
bulkSet: () => {
return Promise.resolve();
},
2023-07-22 18:37:46 +00:00
};
const a = [
{
until: 1686651693,
limit: 200,
kinds: [1, 6, 6969],
authors: ["3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d"],
},
];
2023-06-13 10:40:09 +00:00
2023-07-22 18:37:46 +00:00
const output = splitAllByWriteRelays(Relays, a);
expect(output).toEqual([
{
relay: "",
filters: a,
},
]);
});
});