sr-npm 1.7.398 → 1.7.400
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -32,13 +32,11 @@ async function fetchPositionsFromSRAPI(companyID=undefined) {
|
|
|
32
32
|
let totalFound = 0;
|
|
33
33
|
let page = 0;
|
|
34
34
|
const MAX_PAGES = 30 // Safety limit to prevent infinite loops
|
|
35
|
-
console.log('companyID =', companyID);
|
|
36
35
|
let companyId=companyID
|
|
37
36
|
if(!companyID)
|
|
38
37
|
{
|
|
39
38
|
companyId = await getCompanyIdFromCMS();
|
|
40
39
|
}
|
|
41
|
-
console.log('companyId =', companyId);
|
|
42
40
|
console.log('Starting to fetch all positions with pagination...');
|
|
43
41
|
let offset=0;
|
|
44
42
|
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { executeApiRequest } = require('tests-utils');
|
|
2
|
-
const { getRandomPosition } = require('./testsUtils');
|
|
2
|
+
const { getRandomPosition, executeRequestAndTest } = require('./testsUtils');
|
|
3
3
|
|
|
4
4
|
describe('Job details fetch from SR API Tests', () => {
|
|
5
5
|
|
|
@@ -33,29 +33,27 @@ describe('Job details fetch from SR API Tests', () => {
|
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
describe('fetchPositionsFromSRAPI error handling', () => {
|
|
36
|
-
test('should
|
|
37
|
-
try{
|
|
36
|
+
test('should throw error if invalid companyId is found', async () => {
|
|
38
37
|
const requestBody = `fetchPositionsFromSRAPI('invalid_company_id');`;
|
|
39
|
-
|
|
40
|
-
expect(response.status).not.toBe(500);
|
|
41
|
-
}catch(error){
|
|
42
|
-
console.log(error);
|
|
43
|
-
|
|
44
|
-
expect(error.message).toBe('Request failed with status code 500');
|
|
45
|
-
}
|
|
38
|
+
executeRequestAndTest(requestBody)
|
|
46
39
|
});
|
|
47
40
|
|
|
48
|
-
test('throw error when bad
|
|
41
|
+
test('should throw error when a bad URL is used', async () => {
|
|
49
42
|
const requestBody = `makeSmartRecruitersRequest('/v1/error/companyId/postings');`;
|
|
50
|
-
|
|
51
|
-
response = await executeApiRequest(requestBody);
|
|
52
|
-
expect(response.status).not.toBe(500);
|
|
53
|
-
}catch(error){
|
|
54
|
-
console.log(error);
|
|
55
|
-
expect(error.message).toBe('Request failed with status code 500');
|
|
56
|
-
}
|
|
43
|
+
executeRequestAndTest(requestBody)
|
|
57
44
|
});
|
|
58
45
|
|
|
59
46
|
|
|
60
47
|
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe('fetchJobDescription error handling', () => {
|
|
51
|
+
test('should throw error if invalid jobId is found', async () => {
|
|
52
|
+
const requestBody = `fetchJobDescription('invalid_job_id');`;
|
|
53
|
+
executeRequestAndTest(requestBody)
|
|
54
|
+
});
|
|
55
|
+
test('should throw error when given a valid jobId but no jobAdId is found', async () => {
|
|
56
|
+
const requestBody = `fetchJobDescription('1234567890');`;
|
|
57
|
+
executeRequestAndTest(requestBody)
|
|
58
|
+
});
|
|
61
59
|
});
|
package/tests/testsUtils.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
function getRandomPosition(positions) {
|
|
2
2
|
return positions[Math.floor(Math.random() * positions.length)];
|
|
3
3
|
}
|
|
4
|
+
async function executeRequestAndTest(requestBody) {
|
|
5
|
+
try{
|
|
6
|
+
response = await executeApiRequest(requestBody);
|
|
7
|
+
expect(response.status).not.toBe(500);
|
|
8
|
+
}catch(error){
|
|
9
|
+
expect(error.message).toBe('Request failed with status code 500');
|
|
10
|
+
}
|
|
11
|
+
}
|
|
4
12
|
|
|
5
13
|
module.exports = {
|
|
6
|
-
getRandomPosition
|
|
14
|
+
getRandomPosition, executeRequestAndTest
|
|
7
15
|
}
|