mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 18:34:09 +00:00
fix(mail-ingest): create missing IMAP archive parent on demand
This commit is contained in:
@@ -139,6 +139,20 @@ describe('MailIngestImapClient', () => {
|
||||
expect(reason).toBe('Could not create IMAP folder TREK/processed. The IMAP server answered: CREATE failed');
|
||||
});
|
||||
|
||||
it('creates a missing parent when the server refuses to create the child first', async () => {
|
||||
const session = await new MailIngestImapClient().connect(CONFIG);
|
||||
flow.status
|
||||
.mockRejectedValueOnce(missingFolder())
|
||||
.mockRejectedValueOnce(missingFolder())
|
||||
.mockRejectedValueOnce(missingFolder());
|
||||
flow.mailboxCreate
|
||||
.mockRejectedValueOnce(new Error('CREATE failed'))
|
||||
.mockResolvedValueOnce({ path: 'TREK', created: true });
|
||||
|
||||
await expect(session.ensureFolder(['TREK', 'processed'])).resolves.toBe('TREK.processed');
|
||||
expect(flow.mailboxCreate.mock.calls).toEqual([[['TREK', 'processed']], [['TREK']], [['TREK', 'processed']]]);
|
||||
});
|
||||
|
||||
it('does not ask an empty folder for a range', async () => {
|
||||
flow.mailboxOpen.mockResolvedValueOnce({ uidValidity: 5n, exists: 0 });
|
||||
const session = await new MailIngestImapClient().connect(CONFIG);
|
||||
|
||||
Reference in New Issue
Block a user