-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjest.setup.js
More file actions
83 lines (80 loc) · 2.19 KB
/
Copy pathjest.setup.js
File metadata and controls
83 lines (80 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Jest setup file for Chrome extension environment
// Mock Chrome APIs
global.chrome = {
runtime: {
getURL: jest.fn((path) => `chrome-extension://test-extension-id/${path}`),
sendMessage: jest.fn(() => Promise.resolve()),
onMessage: {
addListener: jest.fn()
},
lastError: null,
onInstalled: {
addListener: jest.fn()
}
},
storage: {
local: {
get: jest.fn(() => Promise.resolve({})),
set: jest.fn(() => Promise.resolve())
}
},
downloads: {
download: jest.fn((options, callback) => {
if (callback) callback(1);
return 1;
})
},
tabs: {
query: jest.fn(() => Promise.resolve([{ id: 1, url: 'https://mail.google.com/' }])),
sendMessage: jest.fn(() => Promise.resolve()),
create: jest.fn(() => Promise.resolve({ id: 2 }))
}
};
// Mock fetch for config loading
global.fetch = jest.fn((url) => {
// Return mock configs based on URL
if (url.includes('gc-list.json')) {
return Promise.resolve({
ok: true,
json: () => Promise.resolve({
contractors: ['turner', 'skanska', 'mortenson']
})
});
}
if (url.includes('keywords.json')) {
return Promise.resolve({
ok: true,
json: () => Promise.resolve({
highValueKeywords: ['hospital', 'data center', 'stadium']
})
});
}
if (url.includes('priority-weights.json')) {
return Promise.resolve({
ok: true,
json: () => Promise.resolve({
maxScore: 100,
weights: {
deadline: { maxPoints: 40 },
gcReputation: { maxPoints: 20, majorGcPoints: 20, knownGcPoints: 10 },
projectValue: { maxPoints: 20, pointsPerKeyword: 5 },
dataCompleteness: { maxPoints: 10, pointsPerField: 1.5, fields: ['project', 'gc', 'bidDate'] },
attachments: { maxPoints: 10, pointsPerAttachment: 2 }
},
priorityLevels: {
high: { minScore: 70, label: 'HIGH' },
medium: { minScore: 40, label: 'MED' },
low: { minScore: 0, label: 'LOW' }
}
})
});
}
return Promise.resolve({
ok: true,
json: () => Promise.resolve({})
});
});
// Reset mocks before each test
beforeEach(() => {
jest.clearAllMocks();
});