Skip to content

Commit 094fda4

Browse files
test: fix tests
1 parent c342a55 commit 094fda4

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

Diff for: config/init.sql

+8
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ CREATE TABLE IF NOT EXISTS directus_users (
3030
github VARCHAR(255)
3131
);
3232

33+
CREATE TABLE IF NOT EXISTS directus_notifications (
34+
id CHAR(10),
35+
recipient CHAR(36),
36+
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
37+
subject VARCHAR(255),
38+
message TEXT
39+
);
40+
3341
INSERT IGNORE INTO adopted_probes (
3442
userId,
3543
lastSyncDate,

Diff for: test/tests/unit/adopted-probes.test.ts

+7-9
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ const defaultConnectedProbe: Probe = {
3232
location: {
3333
continent: 'EU',
3434
region: 'Northern Europe',
35-
normalizedRegion: 'northern europe',
3635
country: 'IE',
3736
city: 'Dublin',
3837
normalizedCity: 'dublin',
@@ -59,7 +58,7 @@ const defaultConnectedProbe: Probe = {
5958
const selectStub = sinon.stub();
6059
const updateStub = sinon.stub();
6160
const deleteStub = sinon.stub();
62-
const insertStub = sinon.stub();
61+
const rawStub = sinon.stub();
6362
const whereStub = sinon.stub().returns({
6463
update: updateStub,
6564
delete: deleteStub,
@@ -70,8 +69,8 @@ const joinStub = sinon.stub().returns({
7069
const sqlStub = sinon.stub().returns({
7170
join: joinStub,
7271
where: whereStub,
73-
insert: insertStub,
74-
});
72+
}) as sinon.SinonStub<any[], any> & {raw: any};
73+
sqlStub.raw = rawStub;
7574
const fetchSocketsStub = sinon.stub().resolves([]);
7675
let sandbox: sinon.SinonSandbox;
7776

@@ -280,13 +279,13 @@ describe('AdoptedProbes', () => {
280279

281280
await adoptedProbes.syncDashboardData();
282281

283-
expect(insertStub.callCount).to.equal(1);
282+
expect(rawStub.callCount).to.equal(1);
284283

285-
expect(insertStub.args[0]).to.deep.equal([{
284+
expect(rawStub.args[0]![1]).to.deep.equal({
286285
recipient: '3cff97ae-4a0a-4f34-9f1a-155e6def0a45',
287286
subject: 'Adopted probe country change',
288-
message: 'Globalping API detected that your adopted probe with ip: 1.1.1.1 is located at "GB". So its country value changed from "IE" to "GB", and previous custom city value "Dublin" is not applied right now.\n\nIf this change is not right please report in [that issue](https://github.com/jsdelivr/globalping/issues/268).',
289-
}]);
287+
message: 'Globalping API detected that your adopted probe with ip: 1.1.1.1 is located at "GB". So its country value changed from "IE" to "GB", and custom city value "Dublin" is not applied right now.\n\nIf this change is not right please report in [that issue](https://github.com/jsdelivr/globalping/issues/268).',
288+
});
290289

291290
expect(whereStub.callCount).to.equal(1);
292291
expect(whereStub.args[0]).to.deep.equal([{ ip: '1.1.1.1' }]);
@@ -390,7 +389,6 @@ describe('AdoptedProbes', () => {
390389
expect(updatedLocation).to.deep.equal({
391390
continent: 'EU',
392391
region: 'Northern Europe',
393-
normalizedRegion: 'northern europe',
394392
country: 'IE',
395393
city: 'Dundalk',
396394
normalizedCity: 'dundalk',

Diff for: test/tests/unit/probe/router.test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,6 @@ describe('probe router', () => {
380380
const location = {
381381
continent: 'NA',
382382
region: getRegionByCountry('US'),
383-
normalizedRegion: 'northern america',
384383
country: 'US',
385384
state: 'NY',
386385
city: 'The New York City',

Diff for: test/tests/unit/ws/fetch-sockets.test.ts

-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ describe('fetchSockets', () => {
3838
location: {
3939
continent: 'EU',
4040
region: 'Western Europe',
41-
normalizedRegion: 'western europe',
4241
country: 'FR',
4342
state: undefined,
4443
city: 'Paris',
@@ -94,7 +93,6 @@ describe('fetchSockets', () => {
9493
getUpdatedLocation.returns({
9594
continent: 'EU',
9695
region: 'Western Europe',
97-
normalizedRegion: 'western europe',
9896
country: 'FR',
9997
state: undefined,
10098
city: 'Marseille',
@@ -122,7 +120,6 @@ describe('fetchSockets', () => {
122120
location: {
123121
continent: 'EU',
124122
region: 'Western Europe',
125-
normalizedRegion: 'western europe',
126123
country: 'FR',
127124
state: undefined,
128125
city: 'Marseille',

0 commit comments

Comments
 (0)