sr-npm 1.7.386 → 1.7.387
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.
|
@@ -34,7 +34,6 @@ async function fetchPositionsFromSRAPI() {
|
|
|
34
34
|
let page = 0;
|
|
35
35
|
const MAX_PAGES = 30 // Safety limit to prevent infinite loops
|
|
36
36
|
const companyId = await getCompanyIdFromCMS();
|
|
37
|
-
console.log('companyId = ', companyId);
|
|
38
37
|
console.log('Starting to fetch all positions with pagination...');
|
|
39
38
|
let offset=0;
|
|
40
39
|
|
|
@@ -102,7 +101,6 @@ async function fetchJobDescription(jobId) {
|
|
|
102
101
|
|
|
103
102
|
async function getCompanyIdFromCMS() {
|
|
104
103
|
const result = await wixData.query(COLLECTIONS.COMPANY_ID).limit(1).find();
|
|
105
|
-
console.log('result = ', result);
|
|
106
104
|
if (result.items.length > 0) {
|
|
107
105
|
return result.items[0].companyId;
|
|
108
106
|
} else {
|
package/package.json
CHANGED
|
@@ -10,7 +10,6 @@ describe('Job details fetch from SR API Tests', () => {
|
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
test('should successfully fetch job details from SR API', async () => {
|
|
13
|
-
|
|
14
13
|
const randomPosition = getRandomPosition(positions.data.result.content);
|
|
15
14
|
expect(positions.data.result.totalFound).toBeGreaterThan(0);
|
|
16
15
|
expect(positions.data.result.content.length).toBeGreaterThan(0);
|
|
@@ -31,6 +30,43 @@ describe('Job details fetch from SR API Tests', () => {
|
|
|
31
30
|
expect(jobFetchResponse.data.result.applyUrl.length).toBeGreaterThan(0);
|
|
32
31
|
expect(jobFetchResponse.data.result.location).toBeDefined();
|
|
33
32
|
});
|
|
33
|
+
|
|
34
|
+
|
|
34
35
|
|
|
35
36
|
|
|
36
|
-
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe('fetchPositionsFromSRAPI error handling', () => {
|
|
40
|
+
let mockFetch;
|
|
41
|
+
|
|
42
|
+
beforeEach(() => {
|
|
43
|
+
jest.resetModules();
|
|
44
|
+
mockFetch = jest.fn();
|
|
45
|
+
|
|
46
|
+
jest.doMock('wix-fetch', () => ({
|
|
47
|
+
fetch: mockFetch,
|
|
48
|
+
}));
|
|
49
|
+
|
|
50
|
+
jest.doMock('@wix/data', () => ({
|
|
51
|
+
items: {
|
|
52
|
+
query: () => ({
|
|
53
|
+
limit: () => ({
|
|
54
|
+
find: () => Promise.resolve({ items: [{ companyId: 'company-123' }] }),
|
|
55
|
+
}),
|
|
56
|
+
}),
|
|
57
|
+
},
|
|
58
|
+
}));
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('throws on 400 Bad Request from SmartRecruiters', async () => {
|
|
62
|
+
mockFetch.mockResolvedValue({ ok: false, status: 400 });
|
|
63
|
+
const { fetchPositionsFromSRAPI } = require('../backend/fetchPositionsFromSRAPI');
|
|
64
|
+
await expect(fetchPositionsFromSRAPI()).rejects.toThrow('HTTP error! status: 400');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('throws on network failure while fetching positions', async () => {
|
|
68
|
+
mockFetch.mockRejectedValue(new Error('Network failure'));
|
|
69
|
+
const { fetchPositionsFromSRAPI } = require('../backend/fetchPositionsFromSRAPI');
|
|
70
|
+
await expect(fetchPositionsFromSRAPI()).rejects.toThrow('Network failure');
|
|
71
|
+
});
|
|
72
|
+
});
|