Skip to content

Commit 78d0aa9

Browse files
committed
fix: import type
1 parent f662da8 commit 78d0aa9

1 file changed

Lines changed: 107 additions & 79 deletions

File tree

Lines changed: 107 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,188 +1,216 @@
1-
import { EmailRecipient } from "../../src/internal/model/emailRecipient";
2-
import { JunoError, JunoValidationError } from "../../src/lib/errors";
3-
import { validateEmailRecipient, validateProjectIdentifier, validateSendGridKey, validateString, validateUserIdentifier } from "../../src/lib/validators";
4-
5-
describe("Email validation tests", () => {
6-
it("throws an error if a recipient is null", () => {
1+
import { EmailRecipient } from '../../src/internal/models/emailRecipient';
2+
import { JunoError, JunoValidationError } from '../../src/lib/errors';
3+
import {
4+
validateEmailRecipient,
5+
validateProjectIdentifier,
6+
validateSendGridKey,
7+
validateString,
8+
validateUserIdentifier,
9+
} from '../../src/lib/validators';
10+
11+
describe('Email validation tests', () => {
12+
it('throws an error if a recipient is null', () => {
713
let validEmailRecipient: unknown = null;
814

915
expect(() => {
1016
validateEmailRecipient(validEmailRecipient as EmailRecipient);
1117
}).toThrow(JunoError);
1218
});
1319

14-
it("throws an error if a recipient email is null", () => {
20+
it('throws an error if a recipient email is null', () => {
1521
let validEmailRecipient: unknown = {};
1622

1723
expect(() => {
1824
validateEmailRecipient(validEmailRecipient as EmailRecipient);
1925
}).toThrow(JunoError);
2026

2127
validEmailRecipient = {
22-
email: null
23-
}
28+
email: null,
29+
};
2430

2531
expect(() => {
2632
validateEmailRecipient(validEmailRecipient as EmailRecipient);
2733
}).toThrow(JunoError);
2834
});
2935

30-
31-
it("throws an error if a recipient email is blank", () => {
36+
it('throws an error if a recipient email is blank', () => {
3237
let validEmailRecipient: unknown = {
33-
email: " "
38+
email: ' ',
3439
};
3540

3641
expect(() => {
3742
validateEmailRecipient(validEmailRecipient as EmailRecipient);
3843
}).toThrow(JunoError);
3944
});
4045

41-
it("does not throw an error if a recipient name is null", () => {
46+
it('does not throw an error if a recipient name is null', () => {
4247
let validEmailRecipient: unknown = {
43-
email: "someEmail"
48+
email: 'someEmail',
4449
};
4550

4651
validateEmailRecipient(validEmailRecipient as EmailRecipient);
4752
});
4853

49-
it("does not throw an error if a recipient name is blank", () => {
54+
it('does not throw an error if a recipient name is blank', () => {
5055
let validEmailRecipient: unknown = {
51-
email: "someEmail",
52-
name: " "
56+
email: 'someEmail',
57+
name: ' ',
5358
};
5459

5560
validateEmailRecipient(validEmailRecipient as EmailRecipient);
5661
});
57-
5862
});
5963

60-
61-
describe("String validation tests", () => {
62-
it("throws an error if the string is empty or null", () => {
63-
let str = "";
64+
describe('String validation tests', () => {
65+
it('throws an error if the string is empty or null', () => {
66+
let str = '';
6467

6568
expect(() => {
66-
validateString(str)
69+
validateString(str);
6770
}).toThrow(JunoError);
6871

69-
7072
let nullStr: unknown = null;
7173

7274
expect(() => {
73-
validateString(nullStr as string)
75+
validateString(nullStr as string);
7476
}).toThrow(JunoError);
75-
})
77+
});
7678

77-
it("throws an error if the string is not actually a string", () => {
79+
it('throws an error if the string is not actually a string', () => {
7880
let fakeStr: any = 3;
7981

8082
expect(() => {
81-
validateString(fakeStr)
83+
validateString(fakeStr);
8284
}).toThrow(JunoError);
83-
})
85+
});
8486

85-
it("throws an error if the string is blank", () => {
86-
let str = " ";
87+
it('throws an error if the string is blank', () => {
88+
let str = ' ';
8789

8890
expect(() => {
89-
validateString(str)
91+
validateString(str);
9092
}).toThrow(JunoError);
91-
})
93+
});
9294
});
9395

94-
describe("Validate user identifier tests", () => {
95-
it("validates against null input", () => {
96+
describe('Validate user identifier tests', () => {
97+
it('validates against null input', () => {
9698
expect(() => validateUserIdentifier(null as any)).toThrow(JunoError);
9799
});
98100

99-
it("validates against having both inputs", () => {
100-
expect(() => validateUserIdentifier({ email: "a", id: 4 } as any)).toThrow(JunoError);
101+
it('validates against having both inputs', () => {
102+
expect(() => validateUserIdentifier({ email: 'a', id: 4 } as any)).toThrow(
103+
JunoError
104+
);
101105
});
102106

103-
it("validates against negative id", () => {
104-
expect(() => validateUserIdentifier({ email: "a", id: -4 } as any)).toThrow(JunoError);
107+
it('validates against negative id', () => {
108+
expect(() => validateUserIdentifier({ email: 'a', id: -4 } as any)).toThrow(
109+
JunoError
110+
);
105111
});
106112

107-
it("validates against empty email", () => {
108-
expect(() => validateUserIdentifier({ email: "" } as any)).toThrow(JunoError);
113+
it('validates against empty email', () => {
114+
expect(() => validateUserIdentifier({ email: '' } as any)).toThrow(
115+
JunoError
116+
);
109117
});
110118

111-
it("validates against null email", () => {
112-
expect(() => validateUserIdentifier({ email: null } as any)).toThrow(JunoError);
119+
it('validates against null email', () => {
120+
expect(() => validateUserIdentifier({ email: null } as any)).toThrow(
121+
JunoError
122+
);
113123
});
114124

115-
it("validates against null id", () => {
116-
expect(() => validateUserIdentifier({ id: null } as any)).toThrow(JunoError);
125+
it('validates against null id', () => {
126+
expect(() => validateUserIdentifier({ id: null } as any)).toThrow(
127+
JunoError
128+
);
117129
});
118130

119-
it("validates against valid id", () => {
120-
expect(() => validateUserIdentifier({ id: 3 } as any)).not.toThrow(JunoError);
131+
it('validates against valid id', () => {
132+
expect(() => validateUserIdentifier({ id: 3 } as any)).not.toThrow(
133+
JunoError
134+
);
121135
});
122136

123-
it("validates against valid email", () => {
124-
expect(() => validateUserIdentifier({ email: "email" })).not.toThrow(JunoError);
137+
it('validates against valid email', () => {
138+
expect(() => validateUserIdentifier({ email: 'email' })).not.toThrow(
139+
JunoError
140+
);
125141
expect(() => validateUserIdentifier({ id: 3 })).not.toThrow(JunoError);
126142
});
127143
});
128144

129-
describe("Validate project identifier tests", () => {
130-
it("validates against null input", () => {
145+
describe('Validate project identifier tests', () => {
146+
it('validates against null input', () => {
131147
expect(() => validateProjectIdentifier(null as any)).toThrow(JunoError);
132148
});
133149

134-
it("validates against having both inputs", () => {
135-
expect(() => validateProjectIdentifier({ name: "a", id: 4 } as any)).toThrow(JunoError);
150+
it('validates against having both inputs', () => {
151+
expect(() =>
152+
validateProjectIdentifier({ name: 'a', id: 4 } as any)
153+
).toThrow(JunoError);
136154
});
137155

138-
it("validates against negative id", () => {
139-
expect(() => validateProjectIdentifier({ name: "a", id: -4 } as any)).toThrow(JunoError);
156+
it('validates against negative id', () => {
157+
expect(() =>
158+
validateProjectIdentifier({ name: 'a', id: -4 } as any)
159+
).toThrow(JunoError);
140160
});
141161

142-
it("validates against empty name", () => {
143-
expect(() => validateProjectIdentifier({ name: "" } as any)).toThrow(JunoError);
162+
it('validates against empty name', () => {
163+
expect(() => validateProjectIdentifier({ name: '' } as any)).toThrow(
164+
JunoError
165+
);
144166
});
145167

146-
it("validates against null name", () => {
147-
expect(() => validateProjectIdentifier({ name: null } as any)).toThrow(JunoError);
168+
it('validates against null name', () => {
169+
expect(() => validateProjectIdentifier({ name: null } as any)).toThrow(
170+
JunoError
171+
);
148172
});
149173

150-
it("validates against null id", () => {
151-
expect(() => validateProjectIdentifier({ id: null } as any)).toThrow(JunoError);
174+
it('validates against null id', () => {
175+
expect(() => validateProjectIdentifier({ id: null } as any)).toThrow(
176+
JunoError
177+
);
152178
});
153179

154-
it("validates against valid id", () => {
155-
expect(() => validateProjectIdentifier({ id: 3 } as any)).not.toThrow(JunoError);
180+
it('validates against valid id', () => {
181+
expect(() => validateProjectIdentifier({ id: 3 } as any)).not.toThrow(
182+
JunoError
183+
);
156184
});
157185

158-
it("validates against valid name", () => {
159-
expect(() => validateProjectIdentifier({ name: "name" })).not.toThrow(JunoError);
186+
it('validates against valid name', () => {
187+
expect(() => validateProjectIdentifier({ name: 'name' })).not.toThrow(
188+
JunoError
189+
);
160190
expect(() => validateProjectIdentifier({ id: 3 })).not.toThrow(JunoError);
161191
});
162192
});
163193

164-
165-
166-
describe("Validate sendgrid key tests", () => {
167-
it("fails validation against null (missing) sendgrid key", () => {
194+
describe('Validate sendgrid key tests', () => {
195+
it('fails validation against null (missing) sendgrid key', () => {
168196
expect(() => validateSendGridKey(null as any)).toThrow(JunoValidationError);
169197
});
170198

171-
it("fails validation against empty sendgrid key", () => {
172-
expect(() => validateSendGridKey("")).toThrow(JunoValidationError);
199+
it('fails validation against empty sendgrid key', () => {
200+
expect(() => validateSendGridKey('')).toThrow(JunoValidationError);
173201
});
174202

175-
it("fails validation against providing a sendgrid key without prefix of SG", () => {
176-
expect(() => validateSendGridKey("awdiojawiodj")).toThrow(JunoValidationError);
203+
it('fails validation against providing a sendgrid key without prefix of SG', () => {
204+
expect(() => validateSendGridKey('awdiojawiodj')).toThrow(
205+
JunoValidationError
206+
);
177207
});
178208

179-
it("fails validation a sendgrid key that is non-string", () => {
209+
it('fails validation a sendgrid key that is non-string', () => {
180210
expect(() => validateSendGridKey(3 as any)).toThrow(JunoValidationError);
181211
});
182212

183-
184-
it("validates a sendgrid key that is valid", () => {
185-
expect(() => validateSendGridKey("SG.aiwjdiowa")).not.toThrow(JunoError);
213+
it('validates a sendgrid key that is valid', () => {
214+
expect(() => validateSendGridKey('SG.aiwjdiowa')).not.toThrow(JunoError);
186215
});
187-
188-
})
216+
});

0 commit comments

Comments
 (0)