From 19f7523a4590fd41792d22d662bd6f5cf2bfead0 Mon Sep 17 00:00:00 2001 From: HampusM Date: Tue, 27 Jul 2021 17:44:40 +0200 Subject: Made the unit test structure more consistent --- test/unit/repository.unit.test.ts | 52 ++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 25 deletions(-) (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 dfb158d..dd0d09b 100644 --- a/test/unit/repository.unit.test.ts +++ b/test/unit/repository.unit.test.ts @@ -18,45 +18,47 @@ function expectRepositoryProperties(repository: Repository) { } describe("Repository", () => { - it("Should open a repository", async() => { - expect.assertions(8); + describe("Class methods", () => { + it("Should open a repository", async() => { + expect.assertions(8); - const repository = await Repository.open(env.BASE_DIR, env.AVAIL_REPO); + const repository = await Repository.open(env.BASE_DIR, env.AVAIL_REPO); - expect(repository).toBeDefined(); - expect(repository).toBeInstanceOf(Repository); + expect(repository).toBeDefined(); + expect(repository).toBeInstanceOf(Repository); - expectRepositoryProperties(repository); - }); + expectRepositoryProperties(repository); + }); - it("Should fail to open a nonexistant repository", async() => { - expect.assertions(1); + it("Should fail to open a nonexistant repository", async() => { + expect.assertions(1); - await expect(Repository.open(env.BASE_DIR, env.UNAVAIL_REPO)).rejects.toBeInstanceOf(BaseError); - }); + 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); + 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); - }); + await expect(Repository.open(env.BASE_DIR, env.AVAIL_REPO, "wubbalubbadubdub")).rejects.toBeInstanceOf(BaseError); + }); - it("Should open all repositories", async() => { - expect.hasAssertions(); + it("Should open all repositories", async() => { + expect.hasAssertions(); - const all_repositories = await Repository.openAll(env.BASE_DIR); + const all_repositories = await Repository.openAll(env.BASE_DIR); - expect(all_repositories).toBeDefined(); + expect(all_repositories).toBeDefined(); - for(const repository of all_repositories) { - expect(repository).toBeDefined(); - expect(repository).toBeInstanceOf(Repository); + for(const repository of all_repositories) { + expect(repository).toBeDefined(); + expect(repository).toBeInstanceOf(Repository); - expectRepositoryProperties(repository); - } + expectRepositoryProperties(repository); + } + }); }); - describe("Methods", () => { + describe("Instance methods", () => { let repository: Repository; beforeAll(async() => { -- cgit v1.2.3-18-g5258