Skip to content

armgit / ODS

Public Imported from GitHub
0

ODS V3 Pre-Release: Public testing and refinement ahead of the official V3 launch. Turn your PC, Mac, or Linux box into a private AI server.

1.1 KB
Raw Blame
import assert from "node:assert/strict";
import { pageEmail, queryTerms, searchEmail } from "./email-query.js";

const records = [
  { id: "in-1", mailboxes: ["inbox"], labelIds: ["INBOX", "UNREAD"], from: "Lead <[email protected]>", to: "[email protected]", subject: "Workload inquiry", summary: "Needs a private AI deployment." },
  { id: "sent-1", mailboxes: ["sent"], labelIds: ["SENT"], from: "[email protected]", to: "Lead <[email protected]>", subject: "Re: Workload inquiry", summary: "" },
];

assert.deepEqual(queryTerms("in:sent to:[email protected]").mailboxes, ["sent"]);
assert.deepEqual(searchEmail(records, "in:inbox is:unread").map(({ id }) => id), ["in-1"]);
assert.deepEqual(searchEmail(records, "in:sent to:[email protected]").map(({ id }) => id), ["sent-1"]);
assert.deepEqual(searchEmail(records, "in:sent subject:workload").map(({ id }) => id), ["sent-1"]);
assert.deepEqual(searchEmail(records, "in:inbox in:sent"), []);
assert.deepEqual(pageEmail(records, "", 1, 1), {
  totalMatches: 2,
  offset: 1,
  limit: 1,
  count: 1,
  hasMore: false,
  messages: [records[1]],
});