From 055a58e79fb225978d64a3c8e3e25377cc2a5ece Mon Sep 17 00:00:00 2001 From: HampusM Date: Tue, 27 Jul 2021 16:51:54 +0200 Subject: Added new unit tests & the test setup script uses Nodegit instead of exec --- test/unit/repository.unit.test.ts | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'test/unit/repository.unit.test.ts') diff --git a/test/unit/repository.unit.test.ts b/test/unit/repository.unit.test.ts index 7d3f954..dfb158d 100644 --- a/test/unit/repository.unit.test.ts +++ b/test/unit/repository.unit.test.ts @@ -35,6 +35,12 @@ describe("Repository", () => { await expect(Repository.open(env.BASE_DIR, env.UNAVAIL_REPO)).rejects.toBeInstanceOf(BaseError); }); + it("Should fail to open a repository with a nonexistant branch", async() => { + expect.assertions(1); + + await expect(Repository.open(env.BASE_DIR, env.AVAIL_REPO, "wubbalubbadubdub")).rejects.toBeInstanceOf(BaseError); + }); + it("Should open all repositories", async() => { expect.hasAssertions(); @@ -57,6 +63,33 @@ describe("Repository", () => { repository = await Repository.open(env.BASE_DIR, env.AVAIL_REPO); }); + it("Should get the description", async() => { + expect.assertions(2); + + const description = await repository.description(); + + expect(description).toBeDefined(); + expect(description.length).toBeGreaterThan(1); + }); + + it("Should get the owner", async() => { + expect.assertions(2); + + const owner = await repository.owner(); + + expect(owner).toBeDefined(); + expect(owner).toEqual("Bob"); + }); + + it("Should get the branch", async() => { + expect.assertions(2); + + const branch = await repository.branch(); + + expect(branch).toBeDefined(); + expect(branch).toBeInstanceOf(Branch); + }); + it("Should look up if an existent object exists and respond true", async() => { expect.assertions(1); -- cgit v1.2.3-18-g5258