-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathcreate-case.test.js
More file actions
57 lines (54 loc) · 1.76 KB
/
create-case.test.js
File metadata and controls
57 lines (54 loc) · 1.76 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
/*
* Your installation or use of this SugarCRM file is subject to the applicable
* terms available at
* http://support.sugarcrm.com/Resources/Master_Subscription_Agreements/.
* If you do not agree to all of the applicable terms or do not have the
* authority to bind the entity as an authorized representative, then do not
* install or use this SugarCRM file.
*
* Copyright (C) SugarCRM Inc. All rights reserved.
*/
// Import all functions from createCase.js
const lambda = require('../../../src/handlers/create-case.js');
// Defined Constants
const SuccessMessages = require('../../../src/constants/messages/success');
// Mock bean.js
jest.mock('../../../src/core/bean.js', () => () => ({
save: function() {
return {
id: 1,
case_number: 1
};
},
get: function() {
return 1;
}
}));
// This includes all tests for createCaseHandler()
describe('Test for create-case', function() {
// This test invokes createCaseHandler() and compare the result
it('Verifies successful response', async () => {
// Input
const evt = {
Details: {
Parameters: {
contactName: 'John',
contactId: 'JohnId',
caseDescription: 'test',
caseSource: 'Phone'
}
}
};
// Invoke helloFromLambdaHandler()
const result = await lambda.createCaseHandler(evt);
// The expected result
const expectedResult = {
statusCode: 200,
caseId: 1,
caseNumber: 1,
body: SuccessMessages.LAMBDA_FUNCTION_SUCCESS
};
// Compare the result with the expected result
expect(result).toEqual(expectedResult);
});
});