@@ -4,73 +4,74 @@ const {
4
4
getDataFromSpecificAddress,
5
5
} = require ( "../../../../../api-integration/helpers/request/get-data-from-address" ) ;
6
6
//Const
7
- const MOCK_OBJECT_VALUE = { mock_object_key : "mock_object_value" } ;
8
- const MOCK_INVALID_IP_VALUE = "192.77" ;
9
- const MOCK_VALID_IP_VALUE = "8.8.8.8" ;
7
+ const MOCK_OBJECT_KEY_01 = process . env . MOCK_OBJECT_KEY_01 ;
8
+ const MOCK_OBJECT_01 = { mock_object_key : MOCK_OBJECT_KEY_01 } ;
9
+ const MOCK_INVALID_IP_VALUE_01 = process . env . MOCK_INVALID_IP_01 ;
10
+ const MOCK_VALID_IP_VALUE_01 = process . env . MOCK_VALID_IP_01 ;
10
11
//Vars
11
12
let msg ;
12
13
let getDataFromSpecificAddressResult ;
13
14
14
15
describe ( "- getDataFromSpecificAddress helper (Unit Test)" , ( ) => {
15
16
describe ( "1) Check cases for arguments." , ( ) => {
16
17
msg =
17
- "Should return a string type if no arguments are passed (This function expects a single argument of string type)" ;
18
+ "Should return a object type if no arguments are passed (This function expects a single argument of string type)" ;
18
19
it ( msg , async ( ) => {
19
20
getDataFromSpecificAddressResult = await getDataFromSpecificAddress ( ) ;
20
- await expect ( typeof getDataFromSpecificAddressResult == "string " ) . toBe (
21
+ await expect ( typeof getDataFromSpecificAddressResult == "object " ) . toBe (
21
22
true
22
23
) ;
23
24
} ) ;
24
25
25
26
msg =
26
- "Should return a string type if not string argument is passed (This function expects a single argument of string type)" ;
27
+ "Should return a object type if not string argument is passed (This function expects a single argument of string type)" ;
27
28
it ( msg , async ( ) => {
28
29
getDataFromSpecificAddressResult = await getDataFromSpecificAddress (
29
- MOCK_OBJECT_VALUE
30
+ MOCK_OBJECT_01
30
31
) ;
31
- await expect ( typeof getDataFromSpecificAddressResult == "string " ) . toBe (
32
+ await expect ( typeof getDataFromSpecificAddressResult == "object " ) . toBe (
32
33
true
33
34
) ;
34
35
} ) ;
35
36
36
37
msg =
37
- "Should return a string type if an invalid ip is passed (This function expects a single argument of string type)" ;
38
+ "Should return a object type if an invalid ip is passed (This function expects a single argument of string type)" ;
38
39
it ( msg , async ( ) => {
39
40
getDataFromSpecificAddressResult = await getDataFromSpecificAddress (
40
- MOCK_INVALID_IP_VALUE
41
+ MOCK_INVALID_IP_VALUE_01
41
42
) ;
42
- await expect ( typeof getDataFromSpecificAddressResult == "string " ) . toBe (
43
+ await expect ( typeof getDataFromSpecificAddressResult == "object " ) . toBe (
43
44
true
44
45
) ;
45
46
} ) ;
46
47
47
48
msg =
48
- "Should return a string type if a valid ip is passed (This function expects a single argument of string type)" ;
49
+ "Should return a object type if a valid ip is passed (This function expects a single argument of string type)" ;
49
50
it ( msg , async ( ) => {
50
51
getDataFromSpecificAddressResult = await getDataFromSpecificAddress (
51
- MOCK_VALID_IP_VALUE
52
+ MOCK_VALID_IP_VALUE_01
52
53
) ;
53
- await expect ( typeof getDataFromSpecificAddressResult == "string " ) . toBe (
54
+ await expect ( typeof getDataFromSpecificAddressResult == "object " ) . toBe (
54
55
true
55
56
) ;
56
57
} ) ;
57
58
58
59
msg =
59
- "Should return a string type if a null value is passed (This function expects a single argument of string type)" ;
60
+ "Should return a object type if a null value is passed (This function expects a single argument of string type)" ;
60
61
it ( msg , async ( ) => {
61
62
getDataFromSpecificAddressResult = await getDataFromSpecificAddress ( null ) ;
62
- await expect ( typeof getDataFromSpecificAddressResult == "string " ) . toBe (
63
+ await expect ( typeof getDataFromSpecificAddressResult == "object " ) . toBe (
63
64
true
64
65
) ;
65
66
} ) ;
66
67
67
68
msg =
68
- "Should return a string type if an undefined value is passed (This function expects a single argument of string type)" ;
69
+ "Should return a object type if an undefined value is passed (This function expects a single argument of string type)" ;
69
70
it ( msg , async ( ) => {
70
71
getDataFromSpecificAddressResult = await getDataFromSpecificAddress (
71
72
undefined
72
73
) ;
73
- await expect ( typeof getDataFromSpecificAddressResult == "string " ) . toBe (
74
+ await expect ( typeof getDataFromSpecificAddressResult == "object " ) . toBe (
74
75
true
75
76
) ;
76
77
} ) ;
@@ -119,18 +120,13 @@ describe("- getDataFromSpecificAddress helper (Unit Test)", () => {
119
120
} ) ;
120
121
121
122
msg =
122
- "Should return a string type with 'ERROR in getDataFromSpecificAddress helper function.' value if a new Error is passed for arguments." ;
123
+ "Should return a object type if a new Error is passed for arguments." ;
123
124
it ( msg , async ( ) => {
124
125
let newError = new Error ( ) ;
125
- const GET_DATA_FROM_SPECIFIC_ADDRESS_ERROR_NAME =
126
- "ERROR in getDataFromSpecificAddress helper function." ;
127
-
128
126
getDataFromSpecificAddressResult = await getDataFromSpecificAddress (
129
127
newError
130
128
) ;
131
- await expect ( getDataFromSpecificAddressResult ) . toMatch (
132
- GET_DATA_FROM_SPECIFIC_ADDRESS_ERROR_NAME
133
- ) ;
129
+ await expect ( typeof getDataFromSpecificAddressResult == "object" ) ;
134
130
} ) ;
135
131
} ) ;
136
132
} ) ;
0 commit comments