@remit/data-ports 0.0.69 → 0.0.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/conformance/account.ts +82 -0
- package/src/conformance/index.ts +1 -0
- package/src/types.ts +2 -0
package/package.json
CHANGED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { after, before, describe, test } from "node:test";
|
|
3
|
+
import { AccountService, ConnectionState } from "@remit/domain-enums";
|
|
4
|
+
import type { IAccountRepository } from "../interfaces/account.js";
|
|
5
|
+
import type { CreateAccountInput } from "../types.js";
|
|
6
|
+
import type { RepositoryConformanceHarness } from "./harness.js";
|
|
7
|
+
|
|
8
|
+
const accountInput = (accountConfigId: string): CreateAccountInput => ({
|
|
9
|
+
accountConfigId,
|
|
10
|
+
username: "person@example.com",
|
|
11
|
+
email: "person@example.com",
|
|
12
|
+
imapHost: "imap.example.com",
|
|
13
|
+
imapPort: 993,
|
|
14
|
+
imapTls: true,
|
|
15
|
+
imapStartTls: false,
|
|
16
|
+
isActive: true,
|
|
17
|
+
connectionState: ConnectionState.NotAuthenticated,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export function accountRepositoryConformance(
|
|
21
|
+
harness: RepositoryConformanceHarness<IAccountRepository>,
|
|
22
|
+
): void {
|
|
23
|
+
describe("IAccountRepository conformance", () => {
|
|
24
|
+
let repo: IAccountRepository;
|
|
25
|
+
|
|
26
|
+
before(async () => {
|
|
27
|
+
repo = await harness.createRepository();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
after(() => harness.teardown());
|
|
31
|
+
|
|
32
|
+
test("an account created without a service selection syncs mail", async () => {
|
|
33
|
+
const created = await repo.create(accountInput(harness.makeId()));
|
|
34
|
+
|
|
35
|
+
assert.deepEqual(created.syncedServices, [AccountService.Mail]);
|
|
36
|
+
assert.deepEqual((await repo.get(created.accountId)).syncedServices, [
|
|
37
|
+
AccountService.Mail,
|
|
38
|
+
]);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test("an account keeps the selection it was created with", async () => {
|
|
42
|
+
const created = await repo.create({
|
|
43
|
+
...accountInput(harness.makeId()),
|
|
44
|
+
syncedServices: [AccountService.Calendar],
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
assert.deepEqual((await repo.get(created.accountId)).syncedServices, [
|
|
48
|
+
AccountService.Calendar,
|
|
49
|
+
]);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test("an update replaces the selection outright", async () => {
|
|
53
|
+
const created = await repo.create(accountInput(harness.makeId()));
|
|
54
|
+
|
|
55
|
+
const updated = await repo.update(created.accountId, {
|
|
56
|
+
syncedServices: [AccountService.Mail, AccountService.Calendar],
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
assert.deepEqual(updated.syncedServices, [
|
|
60
|
+
AccountService.Mail,
|
|
61
|
+
AccountService.Calendar,
|
|
62
|
+
]);
|
|
63
|
+
assert.deepEqual((await repo.get(created.accountId)).syncedServices, [
|
|
64
|
+
AccountService.Mail,
|
|
65
|
+
AccountService.Calendar,
|
|
66
|
+
]);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test("an update that leaves the selection out keeps it", async () => {
|
|
70
|
+
const created = await repo.create({
|
|
71
|
+
...accountInput(harness.makeId()),
|
|
72
|
+
syncedServices: [AccountService.Calendar],
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
await repo.update(created.accountId, { lastError: "timeout" });
|
|
76
|
+
|
|
77
|
+
assert.deepEqual((await repo.get(created.accountId)).syncedServices, [
|
|
78
|
+
AccountService.Calendar,
|
|
79
|
+
]);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
}
|
package/src/conformance/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { accountRepositoryConformance } from "./account.js";
|
|
1
2
|
export { calendarCollectionRepositoryConformance } from "./calendar-collection.js";
|
|
2
3
|
export { calendarEventIndexRepositoryConformance } from "./calendar-event-index.js";
|
|
3
4
|
export { calendarFeedTokenRepositoryConformance } from "./calendar-feed-token.js";
|
package/src/types.ts
CHANGED
|
@@ -207,9 +207,11 @@ export type CreateAccountInput = Omit<
|
|
|
207
207
|
| "smtpTls"
|
|
208
208
|
| "smtpStartTls"
|
|
209
209
|
| "smtpUsername"
|
|
210
|
+
| "syncedServices"
|
|
210
211
|
> & {
|
|
211
212
|
accountId?: string;
|
|
212
213
|
authType?: AccountItem["authType"];
|
|
214
|
+
syncedServices?: AccountItem["syncedServices"];
|
|
213
215
|
smtpEnabled?: AccountItem["smtpEnabled"];
|
|
214
216
|
smtpHost?: AccountItem["smtpHost"];
|
|
215
217
|
smtpPort?: AccountItem["smtpPort"];
|