diff --git a/src/test/Journal.test.ts b/src/test/Journal.test.ts index ad04859..5b69131 100644 --- a/src/test/Journal.test.ts +++ b/src/test/Journal.test.ts @@ -19,7 +19,7 @@ import { JournalError } from "../main/JournalError"; import type { JournalEvent } from "../main/JournalEvent"; import { sleep } from "../main/util/async"; -const journalDir = join(__dirname, "../../src/test/data/journal"); +const journalDir = "src/test/data/journal"; async function withTmpHome(action: (home: string) => Promise): Promise { const origHome = process.env["HOME"]; @@ -243,7 +243,7 @@ describe("Journal", () => { }); it("throws error when reading broken journal", async () => { - const journal = await Journal.open({ directory: join(__dirname, "../../src/test/data/broken") }); + const journal = await Journal.open({ directory: "src/test/data/broken" }); try { const promise = (async () => { for await (const event of journal) { @@ -307,9 +307,9 @@ describe("Journal", () => { } }); it("opens journal in given directory", async () => { - const journal = await Journal.open({ directory: __dirname }); + const journal = await Journal.open({ directory: "src/test" }); try { - expect(journal.getDirectory()).toBe(__dirname); + expect(journal.getDirectory()).toBe("src/test"); } finally { await journal.close(); } @@ -322,7 +322,7 @@ describe("Journal", () => { { file: "Journal.2023-01-01T000000.01.log", offset: 222, line: 3 }); }); it("returns start position when no journal find found", async () => { - expect(await Journal.findEnd(__dirname)).toEqual({ file: "", offset: 0, line: 1 }); + expect(await Journal.findEnd("src/test")).toEqual({ file: "", offset: 0, line: 1 }); }); }); diff --git a/src/test/events/carrier/CarrierStats.test.ts b/src/test/events/carrier/CarrierStats.test.ts index b88219b..972ce1a 100644 --- a/src/test/events/carrier/CarrierStats.test.ts +++ b/src/test/events/carrier/CarrierStats.test.ts @@ -1,8 +1,6 @@ -import { join } from "path"; - import { Journal } from "../../../main/Journal"; -const directory = join(__dirname, "../../../../src/test/data/events/CarrierStats"); +const directory = "src/test/data/events/CarrierStats"; describe("CarrierStats", () => { it("updates old TaxRate to new TaxRate_rearm, TaxRate_refuel and TaxRate_repair", async () => { diff --git a/src/test/events/exploration/Scan.test.ts b/src/test/events/exploration/Scan.test.ts index 4ab684f..fec2104 100644 --- a/src/test/events/exploration/Scan.test.ts +++ b/src/test/events/exploration/Scan.test.ts @@ -1,8 +1,6 @@ -import { join } from "path"; - import { Journal } from "../../../main/Journal"; -const directory = join(__dirname, "../../../../src/test/data/events/Scan"); +const directory = "src/test/data/events/Scan"; describe("Scan", () => { it("updates Materials object to array", async () => { diff --git a/src/test/events/odyssey/Backpack.test.ts b/src/test/events/odyssey/Backpack.test.ts index 38910ff..028be1f 100644 --- a/src/test/events/odyssey/Backpack.test.ts +++ b/src/test/events/odyssey/Backpack.test.ts @@ -1,8 +1,6 @@ -import { join } from "path"; - import { Journal } from "../../../main/Journal"; -const directory = join(__dirname, "../../../../src/test/data/events/Backpack"); +const directory = "src/test/data/events/Backpack"; describe("Scan", () => { it("rename BackPack and BackPackMaterials event to Backpack", async () => { diff --git a/src/test/events/other/Synthesis.test.ts b/src/test/events/other/Synthesis.test.ts index da853ce..aa5abd6 100644 --- a/src/test/events/other/Synthesis.test.ts +++ b/src/test/events/other/Synthesis.test.ts @@ -1,8 +1,6 @@ -import { join } from "path"; - import { Journal } from "../../../main/Journal"; -const directory = join(__dirname, "../../../../src/test/data/events/Synthesis"); +const directory = "src/test/data/events/Synthesis"; describe("Synthesis", () => { it("updates Materials object to array", async () => { diff --git a/src/test/events/startup/Statistics.test.ts b/src/test/events/startup/Statistics.test.ts index 6e37764..8d06b21 100644 --- a/src/test/events/startup/Statistics.test.ts +++ b/src/test/events/startup/Statistics.test.ts @@ -1,8 +1,6 @@ -import { join } from "path"; - import { Journal } from "../../../main/Journal"; -const directory = join(__dirname, "../../../../src/test/data/events/Statistics"); +const directory = "src/test/data/events/Statistics"; describe("Statistics", () => { it("updates fleet carrier distance travelled from LY string to number", async () => { diff --git a/src/test/events/station/EngineerCraft.test.ts b/src/test/events/station/EngineerCraft.test.ts index eccb6ad..540fe67 100644 --- a/src/test/events/station/EngineerCraft.test.ts +++ b/src/test/events/station/EngineerCraft.test.ts @@ -1,8 +1,6 @@ -import { join } from "path"; - import { Journal } from "../../../main/Journal"; -const directory = join(__dirname, "../../../../src/test/data/events/EngineerCraft"); +const directory = "src/test/data/events/EngineerCraft"; describe("EngineerCraft", () => { it("updates Ingredients object to array", async () => { diff --git a/src/test/events/travel/Docked.test.ts b/src/test/events/travel/Docked.test.ts index 8ac6cbd..6c9d708 100644 --- a/src/test/events/travel/Docked.test.ts +++ b/src/test/events/travel/Docked.test.ts @@ -1,8 +1,6 @@ -import { join } from "path"; - import { Journal } from "../../../main/Journal"; -const directory = join(__dirname, "../../../../src/test/data/events/Docked"); +const directory = "src/test/data/events/Docked"; describe("Docked", () => { it("updates old properties to new properties", async () => { diff --git a/src/test/events/travel/FSDJump.test.ts b/src/test/events/travel/FSDJump.test.ts index 750293b..f5f2a37 100644 --- a/src/test/events/travel/FSDJump.test.ts +++ b/src/test/events/travel/FSDJump.test.ts @@ -1,8 +1,6 @@ -import { join } from "path"; - import { Journal } from "../../../main/Journal"; -const directory = join(__dirname, "../../../../src/test/data/events/FSDJump"); +const directory = "src/test/data/events/FSDJump"; describe("FSDJump", () => { it("updates old properties to new properties", async () => { diff --git a/src/test/events/travel/Location.test.ts b/src/test/events/travel/Location.test.ts index cfcc878..0d508bb 100644 --- a/src/test/events/travel/Location.test.ts +++ b/src/test/events/travel/Location.test.ts @@ -1,8 +1,6 @@ -import { join } from "path"; - import { Journal } from "../../../main/Journal"; -const directory = join(__dirname, "../../../../src/test/data/events/Location"); +const directory = "src/test/data/events/Location"; describe("Location", () => { it("updates old properties to new properties", async () => { diff --git a/src/test/index.test.ts b/src/test/index.test.ts index 9d2397e..f079737 100644 --- a/src/test/index.test.ts +++ b/src/test/index.test.ts @@ -1,8 +1,6 @@ -import { join } from "path"; - import * as edj from "../main/index"; -const journalDir = join(__dirname, "../../src/test/data/journal"); +const journalDir = "src/test/data/journal"; describe("ed-journal", () => { it("exports the Journal class", async () => { diff --git a/src/test/util/LineReader.test.ts b/src/test/util/LineReader.test.ts index abbd4c6..19aa895 100644 --- a/src/test/util/LineReader.test.ts +++ b/src/test/util/LineReader.test.ts @@ -3,7 +3,7 @@ import { join } from "path"; import { LineReader } from "../../main/util/LineReader"; -const textsDir = join(__dirname, "../../../src/test/data/texts"); +const textsDir = "src/test/data/texts"; const testTxt = join(textsDir, "test.txt"); const smallTxt = join(textsDir, "small.txt"); diff --git a/src/tools/validate-file.ts b/src/tools/validate-file.ts index ba7f5e6..a56aeba 100644 --- a/src/tools/validate-file.ts +++ b/src/tools/validate-file.ts @@ -43,7 +43,7 @@ class ValidationError extends Error { (async () => { const validator = new Validator(); - const schema = JSON.parse((await readFile(join(__dirname, "..", schemaFile))).toString()) as Schema; + const schema = JSON.parse((await readFile(join("src", schemaFile))).toString()) as Schema; const journal = await Journal.open(); process.on("SIGINT", () => { diff --git a/src/tools/validate-journal.ts b/src/tools/validate-journal.ts index 7d3dd3f..0a36596 100644 --- a/src/tools/validate-journal.ts +++ b/src/tools/validate-journal.ts @@ -32,8 +32,7 @@ class ValidationError extends Error { (async () => { const validator = new Validator(); - const schema = JSON.parse((await readFile(join(__dirname, "..", - "journal-event.schema.json"))).toString()) as Schema; + const schema = JSON.parse((await readFile(join("src", "journal-event.schema.json"))).toString()) as Schema; const narrowedSchemas = new Map(); const journal = await Journal.open({ position, watch: true });