Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions packages/imap/tests/protocol/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,41 @@ describe("parseSearchCriteria", () => {
]);
});

// RFC 3501 Section 6.4.4 -- remaining flag-keyword criteria
it("parses DRAFT and UNDRAFT (RFC 3501 \u00a76.4.4)", () => {
expect(parseSearchCriteria("DRAFT")).toEqual([
{ type: "flag", flag: "\\Draft", negated: false },
]);
expect(parseSearchCriteria("UNDRAFT")).toEqual([
{ type: "flag", flag: "\\Draft", negated: true },
]);
});

it("parses FLAGGED and UNFLAGGED (RFC 3501 \u00a76.4.4)", () => {
expect(parseSearchCriteria("FLAGGED")).toEqual([
{ type: "flag", flag: "\\Flagged", negated: false },
]);
expect(parseSearchCriteria("UNFLAGGED")).toEqual([
{ type: "flag", flag: "\\Flagged", negated: true },
]);
});

it("parses RECENT and OLD (RFC 3501 \u00a76.4.4)", () => {
expect(parseSearchCriteria("RECENT")).toEqual([
{ type: "flag", flag: "\\Recent", negated: false },
]);
// OLD = messages that do not have the \Recent flag
expect(parseSearchCriteria("OLD")).toEqual([
{ type: "flag", flag: "\\Recent", negated: true },
]);
});

it("parses UNANSWERED (RFC 3501 \u00a76.4.4)", () => {
expect(parseSearchCriteria("UNANSWERED")).toEqual([
{ type: "flag", flag: "\\Answered", negated: true },
]);
});

it("throws on unknown criterion", () => {
expect(() => parseSearchCriteria("FOOBAR")).toThrow(ImapParseError);
});
Expand Down
Loading