-
Notifications
You must be signed in to change notification settings - Fork 1
/
helloWorld.spec.ts
59 lines (50 loc) · 1.71 KB
/
helloWorld.spec.ts
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
import { helloWorld } from '../../../src/services/helloWorld';
import { ArgumentError } from '../../../src/utils/errors';
describe('helloWorld', () => {
describe('with no input', () => {
it('should not be null', async () => {
const result = await helloWorld();
expect(result).not.toBeNull();
});
it('should return generic message', async () => {
const result = await helloWorld();
expect(result).toEqual('Hello Lambda World!');
});
});
describe('with undefined input', () => {
it('should not be null', async () => {
const result = await helloWorld(undefined);
expect(result).not.toBeNull();
});
it('should return generic message', async () => {
const result = await helloWorld(undefined);
expect(result).toEqual('Hello Lambda World!');
});
});
describe('with blank input', () => {
it('should not be null', async () => {
const result = await helloWorld(' ');
expect(result).not.toBeNull();
});
it('should return generic message', async () => {
const result = await helloWorld(' ');
expect(result).toEqual('Hello Lambda World!');
});
});
describe('with word', () => {
it('should not be null', async () => {
const result = await helloWorld('Joe');
expect(result).not.toBeNull();
});
it('should return custom message', async () => {
const result = await helloWorld('Joe');
expect(result).toEqual('Hello Joe!');
});
});
describe('with bad input', () => {
it('should throw error', async () => {
await expect(helloWorld('BAD!')).rejects.toThrowError('Bad word given');
await expect(helloWorld('BAD!')).rejects.toThrowError('BAD!');
});
});
});