-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathorganization-user-accept-init.request.spec.ts
More file actions
60 lines (51 loc) · 1.98 KB
/
organization-user-accept-init.request.spec.ts
File metadata and controls
60 lines (51 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { OrganizationKeysRequest } from "@bitwarden/common/admin-console/models/request/organization-keys.request";
import { OrganizationUserAcceptInitRequest } from "./organization-user-accept-init.request";
describe("OrganizationUserAcceptInitRequest", () => {
const validToken = "invite-token";
const validKey = "encrypted-org-key";
const validKeys = new OrganizationKeysRequest("public-key", "encrypted-private-key");
const validCollectionName = "encrypted-collection-name";
it("should create a request with all required parameters", () => {
const request = new OrganizationUserAcceptInitRequest(
validToken,
validKey,
validKeys,
validCollectionName,
);
expect(request.token).toBe(validToken);
expect(request.key).toBe(validKey);
expect(request.keys).toBe(validKeys);
expect(request.collectionName).toBe(validCollectionName);
});
it("should throw when token is empty", () => {
expect(
() => new OrganizationUserAcceptInitRequest("", validKey, validKeys, validCollectionName),
).toThrow("Token is required");
});
it("should throw when key is empty", () => {
expect(
() => new OrganizationUserAcceptInitRequest(validToken, "", validKeys, validCollectionName),
).toThrow("Organization key is required");
});
it("should throw when keys is null", () => {
expect(
() => new OrganizationUserAcceptInitRequest(validToken, validKey, null!, validCollectionName),
).toThrow("Organization keys are required");
});
it("should throw when keys is undefined", () => {
expect(
() =>
new OrganizationUserAcceptInitRequest(
validToken,
validKey,
undefined!,
validCollectionName,
),
).toThrow("Organization keys are required");
});
it("should throw when collectionName is empty", () => {
expect(
() => new OrganizationUserAcceptInitRequest(validToken, validKey, validKeys, ""),
).toThrow("Collection name is required");
});
});