39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { createImapFlowOptions, type EmailImportConfig } from "./emailImportService";
|
|
|
|
const baseConfig: EmailImportConfig = {
|
|
userId: 2,
|
|
emailAddress: "compta@example.org",
|
|
password: "secret",
|
|
host: "outlook.office365.com",
|
|
port: 993,
|
|
};
|
|
|
|
describe("createImapFlowOptions", () => {
|
|
it("transmet le jeton brut à ImapFlow pour une authentification OAuth2", () => {
|
|
const options = createImapFlowOptions(
|
|
{ ...baseConfig, authMode: "oauth2" },
|
|
"access-token-value",
|
|
);
|
|
|
|
expect(options.secure).toBe(true);
|
|
expect(options.auth).toEqual({
|
|
user: "compta@example.org",
|
|
accessToken: "access-token-value",
|
|
});
|
|
expect(options.auth).not.toHaveProperty("pass");
|
|
expect(options.tls?.rejectUnauthorized).toBe(true);
|
|
expect(options.disableAutoIdle).toBe(true);
|
|
});
|
|
|
|
it("conserve le mot de passe uniquement pour le mode basique", () => {
|
|
const options = createImapFlowOptions({ ...baseConfig, authMode: "basic" });
|
|
|
|
expect(options.auth).toEqual({
|
|
user: "compta@example.org",
|
|
pass: "secret",
|
|
});
|
|
expect(options.auth).not.toHaveProperty("accessToken");
|
|
});
|
|
});
|