sr-npm 1.7.399 → 1.7.401

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.399",
3
+ "version": "1.7.401",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -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
 
@@ -34,23 +34,13 @@ describe('Job details fetch from SR API Tests', () => {
34
34
 
35
35
  describe('fetchPositionsFromSRAPI error handling', () => {
36
36
  test('should throw error if invalid companyId is found', async () => {
37
- try{
38
37
  const requestBody = `fetchPositionsFromSRAPI('invalid_company_id');`;
39
- response = await executeApiRequest(requestBody);
40
- expect(response.status).not.toBe(500);
41
- }catch(error){
42
- expect(error.message).toBe('Request failed with status code 500');
43
- }
38
+ executeRequestAndTest(requestBody)
44
39
  });
45
40
 
46
41
  test('should throw error when a bad URL is used', async () => {
47
42
  const requestBody = `makeSmartRecruitersRequest('/v1/error/companyId/postings');`;
48
- try{
49
- response = await executeApiRequest(requestBody);
50
- expect(response.status).not.toBe(500);
51
- }catch(error){
52
- expect(error.message).toBe('Request failed with status code 500');
53
- }
43
+ executeRequestAndTest(requestBody)
54
44
  });
55
45
 
56
46
 
@@ -60,20 +50,10 @@ describe('fetchPositionsFromSRAPI error handling', () => {
60
50
  describe('fetchJobDescription error handling', () => {
61
51
  test('should throw error if invalid jobId is found', async () => {
62
52
  const requestBody = `fetchJobDescription('invalid_job_id');`;
63
- try{
64
- response = await executeApiRequest(requestBody);
65
- expect(response.status).not.toBe(500);
66
- }catch(error){
67
- expect(error.message).toBe('Request failed with status code 500');
68
- }
53
+ executeRequestAndTest(requestBody)
69
54
  });
70
55
  test('should throw error when given a valid jobId but no jobAdId is found', async () => {
71
56
  const requestBody = `fetchJobDescription('1234567890');`;
72
- try{
73
- response = await executeApiRequest(requestBody);
74
- expect(response.status).not.toBe(500);
75
- }catch(error){
76
- expect(error.message).toBe('Request failed with status code 500');
77
- }
57
+ executeRequestAndTest(requestBody)
78
58
  });
79
59
  });
@@ -1,7 +1,17 @@
1
+ const { executeApiRequest } = require('tests-utils');
2
+
1
3
  function getRandomPosition(positions) {
2
4
  return positions[Math.floor(Math.random() * positions.length)];
3
5
  }
6
+ async function executeRequestAndTest(requestBody) {
7
+ try{
8
+ response = await executeApiRequest(requestBody);
9
+ expect(response.status).not.toBe(500);
10
+ }catch(error){
11
+ expect(error.message).toBe('Request failed with status code 500');
12
+ }
13
+ }
4
14
 
5
15
  module.exports = {
6
- getRandomPosition
16
+ getRandomPosition, executeRequestAndTest
7
17
  }