aboutsummaryrefslogtreecommitdiff
path: root/test/unit
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/blob.unit.test.ts16
-rw-r--r--test/unit/commit.unit.test.ts40
-rw-r--r--test/unit/diff.unit.test.ts2
-rw-r--r--test/unit/repository.unit.test.ts52
-rw-r--r--test/unit/tree.unit.test.ts14
5 files changed, 66 insertions, 58 deletions
diff --git a/test/unit/blob.unit.test.ts b/test/unit/blob.unit.test.ts
index efb7071..1771255 100644
--- a/test/unit/blob.unit.test.ts
+++ b/test/unit/blob.unit.test.ts
@@ -6,17 +6,19 @@ import { Blob } from "../../packages/server/src/git/blob";
const env = process.env as EnvironmentVariables;
describe("Blob", () => {
- it("Should the get a blob from a path in a tree", async() => {
- expect.assertions(2);
+ describe("Class methods", () => {
+ it("Should the get a blob from a path in a tree", async() => {
+ expect.assertions(2);
- const tree = await Tree.ofRepository(await Repository.open(env.BASE_DIR, env.AVAIL_REPO));
- const blob = await Blob.fromPath(tree, "packages/client/src/main.ts");
+ const tree = await Tree.ofRepository(await Repository.open(env.BASE_DIR, env.AVAIL_REPO));
+ const blob = await Blob.fromPath(tree, "packages/client/src/main.ts");
- expect(blob).toBeDefined();
- expect(blob).toBeInstanceOf(Blob);
+ expect(blob).toBeDefined();
+ expect(blob).toBeInstanceOf(Blob);
+ });
});
- describe("Methods", () => {
+ describe("Instance methods", () => {
let blob: Blob;
beforeAll(async() => {
diff --git a/test/unit/commit.unit.test.ts b/test/unit/commit.unit.test.ts
index 2a43855..abbdb9a 100644
--- a/test/unit/commit.unit.test.ts
+++ b/test/unit/commit.unit.test.ts
@@ -13,36 +13,38 @@ describe("Commit", () => {
repository = await Repository.open(env.BASE_DIR, env.AVAIL_REPO);
});
- it("Should look up a commit", async() => {
- expect.assertions(8);
+ describe("Class methods", () => {
+ it("Should look up a commit", async() => {
+ expect.assertions(8);
- const commit = await Commit.lookup(repository, env.AVAIL_COMMIT);
+ const commit = await Commit.lookup(repository, env.AVAIL_COMMIT);
- expect(commit).toBeDefined();
- expect(commit).toBeInstanceOf(Commit);
+ expect(commit).toBeDefined();
+ expect(commit).toBeInstanceOf(Commit);
- expectCommitProperties(commit);
- });
+ expectCommitProperties(commit);
+ });
- it("Should look up a nonexistant commit and throw", async() => {
- expect.assertions(1);
+ it("Should look up a nonexistant commit and throw", async() => {
+ expect.assertions(1);
- await expect(Commit.lookup(repository, env.UNAVAIL_COMMIT)).rejects.toThrow();
- });
+ await expect(Commit.lookup(repository, env.UNAVAIL_COMMIT)).rejects.toThrow();
+ });
- it("Should look up if an existent commit exists and respond true", async() => {
- expect.assertions(1);
+ it("Should look up if an existent commit exists and respond true", async() => {
+ expect.assertions(1);
- await expect(Commit.lookupExists(repository, env.AVAIL_COMMIT)).resolves.toBeTruthy();
- });
+ await expect(Commit.lookupExists(repository, env.AVAIL_COMMIT)).resolves.toBeTruthy();
+ });
- it("Should look up if an nonexistant commit exists and respond false", async() => {
- expect.assertions(1);
+ it("Should look up if an nonexistant commit exists and respond false", async() => {
+ expect.assertions(1);
- await expect(Commit.lookupExists(repository, env.UNAVAIL_COMMIT)).resolves.toBeFalsy();
+ await expect(Commit.lookupExists(repository, env.UNAVAIL_COMMIT)).resolves.toBeFalsy();
+ });
});
- describe("Methods", () => {
+ describe("Instance methods", () => {
let commit: Commit;
beforeAll(async() => {
diff --git a/test/unit/diff.unit.test.ts b/test/unit/diff.unit.test.ts
index 1fb164f..5d30ec5 100644
--- a/test/unit/diff.unit.test.ts
+++ b/test/unit/diff.unit.test.ts
@@ -14,7 +14,7 @@ describe("Diff", () => {
diff = await (await repository.masterCommit()).diff();
});
- describe("Methods", () => {
+ describe("Instance methods", () => {
it("Should get the raw patches", async() => {
expect.assertions(2);
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() => {
diff --git a/test/unit/tree.unit.test.ts b/test/unit/tree.unit.test.ts
index f3ed635..47a716d 100644
--- a/test/unit/tree.unit.test.ts
+++ b/test/unit/tree.unit.test.ts
@@ -7,16 +7,18 @@ import { EnvironmentVariables } from "../util";
const env = process.env as EnvironmentVariables;
describe("Tree", () => {
- it("Should get the tree of a repository", async() => {
- expect.assertions(2);
+ describe("Class methods", () => {
+ it("Should get the tree of a repository", async() => {
+ expect.assertions(2);
- const tree = await Tree.ofRepository(await Repository.open(env.BASE_DIR, env.AVAIL_REPO));
+ const tree = await Tree.ofRepository(await Repository.open(env.BASE_DIR, env.AVAIL_REPO));
- expect(tree).toBeDefined();
- expect(tree).toBeInstanceOf(Tree);
+ expect(tree).toBeDefined();
+ expect(tree).toBeInstanceOf(Tree);
+ });
});
- describe("Methods", () => {
+ describe("Instance methods", () => {
let tree: Tree;
beforeAll(async() => {