-
Notifications
You must be signed in to change notification settings - Fork 0
/
handler.test.js
59 lines (56 loc) · 1.53 KB
/
handler.test.js
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
'use strict';
require('dotenv').config();
const handler = require('./handler');
jest.mock('google-spreadsheet', () => {
return {
GoogleSpreadsheet: jest.fn().mockImplementation(() => {
return {
useServiceAccountAuth: jest.fn(() => Promise.resolve()),
loadInfo: jest.fn(() => Promise.resolve()),
sheetsByTitle: {
CFP: {
loadHeaderRow: jest.fn(() => Promise.resolve()),
addRow: jest.fn(() => Promise.resolve()),
},
},
};
}),
};
});
describe('cfp', () => {
beforeEach(() => {
jest.clearAllMocks();
});
test('should return a 422 statusCode when the body is not valid', async () => {
const event = {
body: JSON.stringify({
name: '',
title: '',
description: '',
duration: '',
format: '',
bio: '',
social: '',
email: '',
}),
};
const result = await handler.cfp(event);
expect(result.statusCode).toBe(422);
});
test('should return a 200 statusCode when the body is valid', async () => {
const event = {
body: JSON.stringify({
name: '@bmacabeus',
title: 'gameboy advance',
description: 'kekekekek kekek sdf sdf sjfshjk shfjk fdsafsfsf fsafsdfs',
duration: 30,
format: 'in-person',
bio: 'fdfsd fsfsd fsf sfda fsafdfs',
social: 'twitter\nfacebook\ninstagram',
email: process.env.EMAIL,
}),
};
const result = await handler.cfp(event);
expect(result.statusCode).toBe(200);
});
});