|
| 1 | +"use strict"; |
| 2 | +//Helpers |
| 3 | +const { |
| 4 | + dynamoDBClient, |
| 5 | +} = require("../../../../helpers/dynamodb/config/client"); |
| 6 | +//Const |
| 7 | +const MOCK_OBJECT = {}; |
| 8 | +//Vars |
| 9 | +let msg; |
| 10 | +let dynamoDBClientResult; |
| 11 | + |
| 12 | +describe("- dynamoDBClient helper (Unit Test)", () => { |
| 13 | + describe("1) Check cases for arguments.", () => { |
| 14 | + msg = |
| 15 | + "Should return a object type if no arguments are passed (This function does not expect arguments)"; |
| 16 | + it(msg, async () => { |
| 17 | + dynamoDBClientResult = await dynamoDBClient(); |
| 18 | + await expect(typeof dynamoDBClientResult == "object").toBe(true); |
| 19 | + }); |
| 20 | + |
| 21 | + msg = |
| 22 | + "Should return a object type if one argument is passed (This function does not expect arguments)"; |
| 23 | + it(msg, async () => { |
| 24 | + dynamoDBClientResult = await dynamoDBClient(MOCK_OBJECT); |
| 25 | + await expect(typeof dynamoDBClientResult == "object").toBe(true); |
| 26 | + }); |
| 27 | + |
| 28 | + msg = |
| 29 | + "Should return a object type if two argument are passed (This function does not expect arguments)"; |
| 30 | + it(msg, async () => { |
| 31 | + dynamoDBClientResult = await dynamoDBClient(MOCK_OBJECT, MOCK_OBJECT); |
| 32 | + await expect(typeof dynamoDBClientResult == "object").toBe(true); |
| 33 | + }); |
| 34 | + |
| 35 | + msg = |
| 36 | + "Should return a object type if a null value is passed (This function does not expect arguments)"; |
| 37 | + it(msg, async () => { |
| 38 | + dynamoDBClientResult = await dynamoDBClient(null); |
| 39 | + await expect(typeof dynamoDBClientResult == "object").toBe(true); |
| 40 | + }); |
| 41 | + |
| 42 | + msg = |
| 43 | + "Should return a object type if a undefined value is passed (This function does not expect arguments)"; |
| 44 | + it(msg, async () => { |
| 45 | + dynamoDBClientResult = await dynamoDBClient(undefined); |
| 46 | + await expect(typeof dynamoDBClientResult == "object").toBe(true); |
| 47 | + }); |
| 48 | + }); |
| 49 | + |
| 50 | + describe("2) Check cases for error.", () => { |
| 51 | + msg = |
| 52 | + "Should not return a error message and not throw an Error if no argument is passed to the function (This function does not expect arguments)."; |
| 53 | + it(msg, async () => { |
| 54 | + await expect(async () => await dynamoDBClient()).not.toThrow(Error); |
| 55 | + }); |
| 56 | + msg = |
| 57 | + "Should not return a error message and not throw an Error if a new Error is passed to the function (This function does not expect arguments)."; |
| 58 | + it(msg, async () => { |
| 59 | + await expect(async () => await dynamoDBClient(new Error())).not.toThrow( |
| 60 | + Error |
| 61 | + ); |
| 62 | + }); |
| 63 | + }); |
| 64 | +}); |
0 commit comments