Skip to content

Commit

Permalink
test: fix some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-yarmosh committed Apr 10, 2024
1 parent 75c8bbf commit 8ddd34a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
12 changes: 12 additions & 0 deletions migrations/create-tables.js.sql
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,15 @@ CREATE TABLE IF NOT EXISTS gp_credits (
CONSTRAINT gp_credits_user_id_unique UNIQUE (user_id),
CONSTRAINT gp_credits_amount_positive CHECK (`amount` >= 0)
);

CREATE TABLE IF NOT EXISTS gp_location_overrides (
id INT(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
user_created CHAR(36),
date_created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
user_updated CHAR(36),
date_updated TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
ip_range VARCHAR(255) NOT NULL,
city VARCHAR(255) NOT NULL,
state VARCHAR(255) NULL,
country VARCHAR(255) NULL
);
2 changes: 1 addition & 1 deletion src/lib/adopted-probes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class AdoptedProbes {

return {
...probe,
location: newLocation,
location: newLocation || probe.location,
tags: newTags,
index: getIndex(newLocation || probe.location, newTags),
};
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ws/synced-probe-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ export class SyncedProbeList extends EventEmitter {
}
}

const newNodeData = {
const newNodeData: NodeData = {
...nodeData,
...changes.revalidateTimestamp ? { revalidateTimestamp: changes.revalidateTimestamp } : {},
probesById,
Expand Down
8 changes: 4 additions & 4 deletions test/tests/unit/adopted-probes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ describe('AdoptedProbes', () => {
});
});

it('getUpdatedLocation method should return same location object if connected.country !== adopted.countryOfCustomCity', async () => {
it('getUpdatedLocation method should return null if connected.country !== adopted.countryOfCustomCity', async () => {
const adoptedProbes = new AdoptedProbes(sqlStub as unknown as Knex, fetchSocketsStub);
selectStub.resolves([{
...defaultAdoptedProbe,
Expand All @@ -407,10 +407,10 @@ describe('AdoptedProbes', () => {

await adoptedProbes.syncDashboardData();
const updatedLocation = adoptedProbes.getUpdatedLocation(defaultConnectedProbe);
expect(updatedLocation).to.equal(defaultConnectedProbe.location);
expect(updatedLocation).to.equal(null);
});

it('getUpdatedLocation method should return same location object if "isCustomCity: false"', async () => {
it('getUpdatedLocation method should return null if "isCustomCity: false"', async () => {
const adoptedProbes = new AdoptedProbes(sqlStub as unknown as Knex, fetchSocketsStub);
selectStub.resolves([{
...defaultAdoptedProbe,
Expand All @@ -422,7 +422,7 @@ describe('AdoptedProbes', () => {

await adoptedProbes.syncDashboardData();
const updatedLocation = adoptedProbes.getUpdatedLocation(defaultConnectedProbe);
expect(updatedLocation).to.equal(defaultConnectedProbe.location);
expect(updatedLocation).to.equal(null);
});

it('getUpdatedTags method should return updated tags', async () => {
Expand Down

0 comments on commit 8ddd34a

Please sign in to comment.