diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/int/api.int.test.ts | 10 | ||||
-rw-r--r-- | test/teardown.ts | 5 | ||||
-rw-r--r-- | test/tsconfig.json | 6 | ||||
-rw-r--r-- | test/unit/patch.unit.test.ts | 4 | ||||
-rw-r--r-- | test/unit/tree.unit.test.ts | 2 |
5 files changed, 22 insertions, 5 deletions
diff --git a/test/int/api.int.test.ts b/test/int/api.int.test.ts index b93a947..11478ad 100644 --- a/test/int/api.int.test.ts +++ b/test/int/api.int.test.ts @@ -265,7 +265,15 @@ describe("API", () => { beforeAll(async() => { const body = new Readable({ read: () => null }); - const head = /^[a-f0-9]+/.exec((await readFile(`${env.BASE_DIR}/${env.AVAIL_REPO}/FETCH_HEAD`)).toString())[0]; + let head = (await readFile(`${env.BASE_DIR}/${env.AVAIL_REPO}/FETCH_HEAD`)).toString(); + + const find_head = /^[a-f0-9]+/.exec(head); + + if(!find_head) { + throw(new Error("Failed to get repository head!")); + } + + head = find_head[0]; body.push(`0098want ${head} multi_ack_detailed no-done side-band-64k thin-pack ofs-delta deepen-since deepen-not agent=git/2.32.0\n00000009done\n`); body.push(null); diff --git a/test/teardown.ts b/test/teardown.ts index 290c478..c5b49e3 100644 --- a/test/teardown.ts +++ b/test/teardown.ts @@ -1,5 +1,8 @@ import { remove } from "fs-extra"; +import { EnvironmentVariables } from "./util"; + +const env = process.env as EnvironmentVariables; export default async function(): Promise<void> { - await remove(process.env.BASE_DIR); + await remove(env.BASE_DIR); }
\ No newline at end of file diff --git a/test/tsconfig.json b/test/tsconfig.json new file mode 100644 index 0000000..a397e7d --- /dev/null +++ b/test/tsconfig.json @@ -0,0 +1,6 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "module": "CommonJS", + } +}
\ No newline at end of file diff --git a/test/unit/patch.unit.test.ts b/test/unit/patch.unit.test.ts index e4aa8d3..3197059 100644 --- a/test/unit/patch.unit.test.ts +++ b/test/unit/patch.unit.test.ts @@ -89,7 +89,7 @@ describe("Patch", () => { } }); - it("Should get the hunks of an empty patch and respond with null", async() => { + it("Should get the hunks of an empty patch and respond with an ampty array", async() => { expect.assertions(2); const other_commit = await Commit.lookup(repository, "ef256e9e40b5fd0cc741c509e611808cc66bafad"); @@ -98,7 +98,7 @@ describe("Patch", () => { const hunks = await other_patch.getHunks(); expect(hunks).toBeDefined(); - expect(hunks).toBeNull(); + expect(hunks).toHaveLength(0); }); }); });
\ No newline at end of file diff --git a/test/unit/tree.unit.test.ts b/test/unit/tree.unit.test.ts index d34c93e..3fe49f3 100644 --- a/test/unit/tree.unit.test.ts +++ b/test/unit/tree.unit.test.ts @@ -82,7 +82,7 @@ describe("Tree", () => { // Extract the archive entries to an array of entries const entries = await new Promise((resolve: (value: Entry[]) => void) => { - const entries = []; + const entries: Entry[] = []; extract_archive.on("finish", () => { resolve(entries); |