mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
update naming of classes and tests
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { NotificationService } from "./services/NotificationService";
|
||||
import { ETANotificationScheduler } from "./notifications/schedulers/ETANotificationScheduler";
|
||||
import { GetterSetterRepository } from "./repositories/GetterSetterRepository";
|
||||
|
||||
export interface ServerContext {
|
||||
repository: GetterSetterRepository;
|
||||
notificationService: NotificationService;
|
||||
notificationService: ETANotificationScheduler;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { MergedResolvers } from "./MergedResolvers";
|
||||
import { ServerContext } from "./ServerContext";
|
||||
import { UnoptimizedInMemoryRepository } from "./repositories/UnoptimizedInMemoryRepository";
|
||||
import { TimedApiBasedRepositoryLoader } from "./loaders/TimedApiBasedRepositoryLoader";
|
||||
import { NotificationService } from "./services/NotificationService";
|
||||
import { ETANotificationScheduler } from "./notifications/schedulers/ETANotificationScheduler";
|
||||
import { configDotenv } from "dotenv";
|
||||
import { loadTestData } from "./loaders/loadTestData";
|
||||
|
||||
@@ -21,16 +21,16 @@ async function main() {
|
||||
});
|
||||
|
||||
const repository = new UnoptimizedInMemoryRepository();
|
||||
let notificationService: NotificationService;
|
||||
let notificationService: ETANotificationScheduler;
|
||||
if (process.argv.length > 2 && process.argv[2] == "integration-testing") {
|
||||
await loadTestData(repository);
|
||||
notificationService = new NotificationService(repository, false);
|
||||
notificationService = new ETANotificationScheduler(repository, false);
|
||||
} else {
|
||||
const repositoryDataUpdater = new TimedApiBasedRepositoryLoader(
|
||||
repository
|
||||
);
|
||||
await repositoryDataUpdater.start();
|
||||
notificationService = new NotificationService(repository);
|
||||
notificationService = new ETANotificationScheduler(repository);
|
||||
}
|
||||
notificationService.reloadAPNsTokenIfTimePassed();
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { GetterRepository } from "../repositories/GetterRepository";
|
||||
import { GetterRepository } from "../../repositories/GetterRepository";
|
||||
import jwt from "jsonwebtoken";
|
||||
import fs from "fs";
|
||||
import { TupleKey } from "../types/TupleKey";
|
||||
import { IEta } from "../entities/entities";
|
||||
import { TupleKey } from "../../types/TupleKey";
|
||||
import { IEta } from "../../entities/entities";
|
||||
import http2 from "http2";
|
||||
|
||||
export interface ScheduledNotificationData {
|
||||
@@ -17,7 +17,7 @@ interface APNsUrl {
|
||||
host: string;
|
||||
}
|
||||
|
||||
export class NotificationService {
|
||||
export class ETANotificationScheduler {
|
||||
public readonly secondsThresholdForNotificationToFire = 180;
|
||||
|
||||
private apnsToken: string | undefined = undefined;
|
||||
@@ -113,7 +113,7 @@ export class NotificationService {
|
||||
throw new Error("APNS_BUNDLE_ID environment variable is not set correctly");
|
||||
}
|
||||
|
||||
const { path, host } = NotificationService.getAPNsFullUrlToUse(deviceId);
|
||||
const { path, host } = ETANotificationScheduler.getAPNsFullUrlToUse(deviceId);
|
||||
|
||||
const headers = {
|
||||
':method': 'POST',
|
||||
@@ -2094,9 +2094,9 @@ export const fetchSystemDataSuccessfulResponse = {
|
||||
"logo": 1,
|
||||
"goRoutePlannerEnabled": "0",
|
||||
"goColor": null,
|
||||
"goSupportEmail": "transit.services@pepperdine.edu",
|
||||
"goSupportEmail": "transit.schedulers@pepperdine.edu",
|
||||
"goAuthenticationType": "0",
|
||||
"email": "transit.services@pepperdine.edu"
|
||||
"email": "transit.schedulers@pepperdine.edu"
|
||||
},
|
||||
{
|
||||
"fullname": "Perimeter Summit Shuttle",
|
||||
@@ -3347,4 +3347,4 @@ export const fetchSystemDataSuccessfulResponse = {
|
||||
"fromCache": 1,
|
||||
"myip": "206.211.154.147"
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { beforeEach, describe, expect, it, jest } from "@jest/globals";
|
||||
import { NotificationService } from "../../src/services/NotificationService";
|
||||
import { UnoptimizedInMemoryRepository } from "../../src/repositories/UnoptimizedInMemoryRepository";
|
||||
import { ETANotificationScheduler } from "../../../src/notifications/schedulers/ETANotificationScheduler";
|
||||
import { UnoptimizedInMemoryRepository } from "../../../src/repositories/UnoptimizedInMemoryRepository";
|
||||
import http2 from "http2";
|
||||
import { IEta, IShuttle, IStop } from "../../src/entities/entities";
|
||||
import { addMockShuttleToRepository, addMockStopToRepository } from "../testHelpers/repositorySetupHelpers";
|
||||
import { IEta, IShuttle, IStop } from "../../../src/entities/entities";
|
||||
import { addMockShuttleToRepository, addMockStopToRepository } from "../../testHelpers/repositorySetupHelpers";
|
||||
import EventEmitter = require("node:events");
|
||||
|
||||
jest.mock("http2");
|
||||
@@ -55,13 +55,13 @@ function mockHttp2Connect(status: number) {
|
||||
(http2.connect as jest.Mock) = jest.fn(() => new MockClient());
|
||||
}
|
||||
|
||||
describe("NotificationService", () => {
|
||||
describe("ETANotificationScheduler", () => {
|
||||
let repository: UnoptimizedInMemoryRepository
|
||||
let notificationService: NotificationService;
|
||||
let notificationService: ETANotificationScheduler;
|
||||
|
||||
beforeEach(() => {
|
||||
repository = new UnoptimizedInMemoryRepository();
|
||||
notificationService = new NotificationService(repository);
|
||||
notificationService = new ETANotificationScheduler(repository);
|
||||
|
||||
// Ensure that tests don't hit the server
|
||||
process.env = {
|
||||
@@ -192,7 +192,7 @@ describe("NotificationService", () => {
|
||||
it('should return the production URL when APNS_IS_PRODUCTION is set to "1"', () => {
|
||||
process.env.APNS_IS_PRODUCTION = "1";
|
||||
const deviceId = 'testDeviceId';
|
||||
const result = NotificationService.getAPNsFullUrlToUse(deviceId);
|
||||
const result = ETANotificationScheduler.getAPNsFullUrlToUse(deviceId);
|
||||
|
||||
const { fullUrl, host, path } = result;
|
||||
expect(fullUrl).toBe(`https://api.push.apple.com/3/device/${deviceId}`);
|
||||
@@ -203,7 +203,7 @@ describe("NotificationService", () => {
|
||||
it('should return the sandbox URL when APNS_IS_PRODUCTION is set to something other than 1', () => {
|
||||
process.env.APNS_IS_PRODUCTION = "0";
|
||||
const deviceId = 'testDeviceId';
|
||||
const result = NotificationService.getAPNsFullUrlToUse(deviceId);
|
||||
const result = ETANotificationScheduler.getAPNsFullUrlToUse(deviceId);
|
||||
|
||||
const { fullUrl, host, path } = result;
|
||||
expect(fullUrl).toBe(`https://api.development.push.apple.com/3/device/${deviceId}`);
|
||||
@@ -2,7 +2,7 @@ import { describe, expect, it } from "@jest/globals";
|
||||
import { generateMockSystems } from "../testHelpers/mockDataGenerators";
|
||||
import { setupTestServerContext, setupTestServerHolder } from "../testHelpers/apolloTestServerHelpers";
|
||||
import assert = require("node:assert");
|
||||
import { ScheduledNotificationData } from "../../src/services/NotificationService";
|
||||
import { ScheduledNotificationData } from "../../src/notifications/schedulers/ETANotificationScheduler";
|
||||
import { addMockShuttleToRepository, addMockStopToRepository } from "../testHelpers/repositorySetupHelpers";
|
||||
|
||||
// See Apollo documentation for integration test guide
|
||||
|
||||
@@ -4,7 +4,7 @@ import { MergedResolvers } from "../../src/MergedResolvers";
|
||||
import { UnoptimizedInMemoryRepository } from "../../src/repositories/UnoptimizedInMemoryRepository";
|
||||
import { beforeEach } from "@jest/globals";
|
||||
import { ServerContext } from "../../src/ServerContext";
|
||||
import { NotificationService } from "../../src/services/NotificationService";
|
||||
import { ETANotificationScheduler } from "../../src/notifications/schedulers/ETANotificationScheduler";
|
||||
|
||||
|
||||
function setUpTestServer() {
|
||||
@@ -26,7 +26,7 @@ export function setupTestServerContext() {
|
||||
|
||||
beforeEach(() => {
|
||||
context.repository = new UnoptimizedInMemoryRepository();
|
||||
context.notificationService = new NotificationService(context.repository);
|
||||
context.notificationService = new ETANotificationScheduler(context.repository);
|
||||
});
|
||||
|
||||
return context as ServerContext;
|
||||
|
||||
Reference in New Issue
Block a user