Skip to content

Commit 82c6dd6

Browse files
committed
Merge branch 'master' of https://github.com/andresWeitzel/gRPC_Netflix_CRUD_Nodejs into documentation-01-add-readme-en-sp
2 parents 74f414a + 8718a2d commit 82c6dd6

File tree

6 files changed

+41
-34
lines changed

6 files changed

+41
-34
lines changed

.env

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# App config General
32
APP_FIRST_PORT = "3200"
43
APP_SECOND_PORT = "4200"

jest.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//For using environment variables with .envs
2+
/** @type {import('jest').Config} */
3+
const config = {
4+
setupFilesAfterEnv: ['./src/test/mock/set-env-vars.js'],
5+
};
6+
7+
module.exports = config;

src/api-integration/data/address/data-from-specific-address.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
"continent_code": "NA",
77
"country": "United States",
88
"country_code": "US",
9-
"region": "California",
10-
"region_code": "CA",
11-
"city": "San Jose",
12-
"latitude": 37.3382082,
13-
"longitude": -121.8863286,
9+
"region": "District of Columbia",
10+
"region_code": "DC",
11+
"city": "Washington",
12+
"latitude": 38.9071923,
13+
"longitude": -77.0368707,
1414
"is_eu": false,
15-
"postal": "95113",
15+
"postal": "20500",
1616
"calling_code": "1",
1717
"capital": "Washington D.C.",
1818
"borders": "CA,MX",
@@ -28,11 +28,11 @@
2828
"domain": "cloudflare.com"
2929
},
3030
"timezone": {
31-
"id": "America/Los_Angeles",
32-
"abbr": "PDT",
33-
"is_dst": true,
34-
"offset": -25200,
35-
"utc": "-07:00",
36-
"current_time": "2023-10-17T19:27:04-07:00"
31+
"id": "America/New_York",
32+
"abbr": "EST",
33+
"is_dst": false,
34+
"offset": -18000,
35+
"utc": "-05:00",
36+
"current_time": "2024-01-25T16:38:46-05:00"
3737
}
3838
}

src/test/mock/set-env-vars.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Mock testing
2+
process.env.MOCK_STRING_01 = ""
3+
process.env.MOCK_NUMBER_01 = 8123891273812
4+
process.env.MOCK_INVALID_IP_01 = "192.77"
5+
process.env.MOCK_VALID_IP_01 = "8.8.8.8"
6+
process.env.MOCK_OBJECT_VALUE_01 = "mock_object_value"

src/test/unit-test/api-integration/helpers/format/address.test.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ const {
44
splitAddressByLastDot,
55
} = require("../../../../../api-integration/helpers/format/address");
66
//Const
7-
const MOCK_STRING_VALUE = "";
7+
const MOCK_STRING_01 = process.env.MOCK_STRING_01;
8+
const MOCK_NUMBER_01 = parseInt(process.env.MOCK_NUMBER_01);
89
//Vars
910
let msg;
1011
let splitAddressByLastDotResult;
@@ -20,26 +21,24 @@ describe("- splitAddressByLastDot helper (Unit Test)", () => {
2021
msg =
2122
"Should return a object type if a valid argument is passed (This function expects a single argument)";
2223
it(msg, async () => {
23-
splitAddressByLastDotResult = await splitAddressByLastDot(
24-
MOCK_STRING_VALUE
25-
);
24+
splitAddressByLastDotResult = await splitAddressByLastDot(MOCK_STRING_01);
2625
await expect(typeof splitAddressByLastDotResult == "object").toBe(true);
2726
});
2827

2928
msg =
3029
"Should return a object type if two valid arguments are passed (This function expects a single argument)";
3130
it(msg, async () => {
3231
splitAddressByLastDotResult = await splitAddressByLastDot(
33-
MOCK_STRING_VALUE,
34-
MOCK_STRING_VALUE
32+
MOCK_STRING_01,
33+
MOCK_STRING_01
3534
);
3635
await expect(typeof splitAddressByLastDotResult == "object").toBe(true);
3736
});
38-
37+
3938
msg =
4039
"Should return a string type if an invalid argument is passed (This function expects a single argument)";
4140
it(msg, async () => {
42-
splitAddressByLastDotResult = await splitAddressByLastDot(122212131);
41+
splitAddressByLastDotResult = await splitAddressByLastDot(MOCK_NUMBER_01);
4342
await expect(typeof splitAddressByLastDotResult == "string").toBe(true);
4443
});
4544

src/test/unit-test/api-integration/helpers/request/get-data-from-address.test.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ const {
44
getDataFromSpecificAddress,
55
} = require("../../../../../api-integration/helpers/request/get-data-from-address");
66
//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_VALUE_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;
1011
//Vars
1112
let msg;
1213
let getDataFromSpecificAddressResult;
@@ -26,7 +27,7 @@ describe("- getDataFromSpecificAddress helper (Unit Test)", () => {
2627
"Should return a string type if not string argument is passed (This function expects a single argument of string type)";
2728
it(msg, async () => {
2829
getDataFromSpecificAddressResult = await getDataFromSpecificAddress(
29-
MOCK_OBJECT_VALUE
30+
MOCK_OBJECT_01
3031
);
3132
await expect(typeof getDataFromSpecificAddressResult == "string").toBe(
3233
true
@@ -37,7 +38,7 @@ describe("- getDataFromSpecificAddress helper (Unit Test)", () => {
3738
"Should return a string type if an invalid ip is passed (This function expects a single argument of string type)";
3839
it(msg, async () => {
3940
getDataFromSpecificAddressResult = await getDataFromSpecificAddress(
40-
MOCK_INVALID_IP_VALUE
41+
MOCK_INVALID_IP_VALUE_01
4142
);
4243
await expect(typeof getDataFromSpecificAddressResult == "string").toBe(
4344
true
@@ -48,7 +49,7 @@ describe("- getDataFromSpecificAddress helper (Unit Test)", () => {
4849
"Should return a string type if a valid ip is passed (This function expects a single argument of string type)";
4950
it(msg, async () => {
5051
getDataFromSpecificAddressResult = await getDataFromSpecificAddress(
51-
MOCK_VALID_IP_VALUE
52+
MOCK_VALID_IP_VALUE_01
5253
);
5354
await expect(typeof getDataFromSpecificAddressResult == "string").toBe(
5455
true
@@ -119,18 +120,13 @@ describe("- getDataFromSpecificAddress helper (Unit Test)", () => {
119120
});
120121

121122
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.";
123124
it(msg, async () => {
124125
let newError = new Error();
125-
const GET_DATA_FROM_SPECIFIC_ADDRESS_ERROR_NAME =
126-
"ERROR in getDataFromSpecificAddress helper function.";
127-
128126
getDataFromSpecificAddressResult = await getDataFromSpecificAddress(
129127
newError
130128
);
131-
await expect(getDataFromSpecificAddressResult).toMatch(
132-
GET_DATA_FROM_SPECIFIC_ADDRESS_ERROR_NAME
133-
);
129+
await expect(typeof getDataFromSpecificAddressResult == "object");
134130
});
135131
});
136132
});

0 commit comments

Comments
 (0)