-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathcreate-provider-organization.request.spec.ts
More file actions
82 lines (69 loc) · 2.98 KB
/
create-provider-organization.request.spec.ts
File metadata and controls
82 lines (69 loc) · 2.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import { PlanType } from "../../../billing/enums";
import { CreateProviderOrganizationRequest } from "./create-provider-organization.request";
import { OrganizationKeysRequest } from "./organization-keys.request";
describe("CreateProviderOrganizationRequest", () => {
const validName = "Test Org";
const validOwnerEmail = "owner@example.com";
const validPlanType = PlanType.TeamsAnnually;
const validSeats = 10;
const validKey = "encrypted-org-key";
const validKeyPair = new OrganizationKeysRequest("public-key", "encrypted-private-key");
const validCollectionName = "encrypted-collection-name";
const createRequest = (
overrides: Partial<{
name: string;
ownerEmail: string;
planType: PlanType;
seats: number;
key: string;
keyPair: OrganizationKeysRequest;
collectionName: string;
}> = {},
) => {
return new CreateProviderOrganizationRequest(
"name" in overrides ? overrides.name! : validName,
"ownerEmail" in overrides ? overrides.ownerEmail! : validOwnerEmail,
"planType" in overrides ? overrides.planType! : validPlanType,
"seats" in overrides ? overrides.seats! : validSeats,
"key" in overrides ? overrides.key! : validKey,
"keyPair" in overrides ? overrides.keyPair! : validKeyPair,
"collectionName" in overrides ? overrides.collectionName! : validCollectionName,
);
};
it("should create a request with all required parameters", () => {
const request = createRequest();
expect(request.name).toBe(validName);
expect(request.ownerEmail).toBe(validOwnerEmail);
expect(request.planType).toBe(validPlanType);
expect(request.seats).toBe(validSeats);
expect(request.key).toBe(validKey);
expect(request.keyPair).toBe(validKeyPair);
expect(request.collectionName).toBe(validCollectionName);
});
it("should throw when name is empty", () => {
expect(() => createRequest({ name: "" })).toThrow("Name is required");
});
it("should throw when ownerEmail is empty", () => {
expect(() => createRequest({ ownerEmail: "" })).toThrow("Owner email is required");
});
it("should throw when planType is null", () => {
expect(() => createRequest({ planType: null! })).toThrow("Plan type is required");
});
it("should throw when seats is null", () => {
expect(() => createRequest({ seats: null! })).toThrow("Seats is required");
});
it("should throw when key is empty", () => {
expect(() => createRequest({ key: "" })).toThrow("Organization key is required");
});
it("should throw when keyPair is null", () => {
expect(() => createRequest({ keyPair: null! })).toThrow("Organization key pair is required");
});
it("should throw when keyPair is undefined", () => {
expect(() => createRequest({ keyPair: undefined })).toThrow(
"Organization key pair is required",
);
});
it("should throw when collectionName is empty", () => {
expect(() => createRequest({ collectionName: "" })).toThrow("Collection name is required");
});
});