aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2021-08-15 15:03:44 +0200
committerHampusM <hampus@hampusmat.com>2021-08-15 15:03:44 +0200
commit9736749a779661a95211a91200617a03a1b9a702 (patch)
tree6bea5e5ec5773aa940e79e7e80c9ebac086eaa10 /test
parentc32094d0b1fc3aa5160087d71bff36ed1779bc3a (diff)
Added a count query parameter to the log API endpoint
Diffstat (limited to 'test')
-rw-r--r--test/unit/commit.unit.test.ts20
-rw-r--r--test/unit/repository.unit.test.ts8
-rw-r--r--test/util.ts14
3 files changed, 18 insertions, 24 deletions
diff --git a/test/unit/commit.unit.test.ts b/test/unit/commit.unit.test.ts
index d302ea8..0d8c918 100644
--- a/test/unit/commit.unit.test.ts
+++ b/test/unit/commit.unit.test.ts
@@ -1,6 +1,6 @@
import { Repository } from "server/src/git/repository";
import { Commit } from "server/src/git/commit";
-import { EnvironmentVariables, expectCommitProperties } from "../util";
+import { EnvironmentVariables } from "../util";
import { Diff } from "server/src/git/diff";
import { Tree } from "server/src/git/tree";
@@ -15,14 +15,12 @@ describe("Commit", () => {
describe("Class methods", () => {
it("Should look up a commit", async() => {
- expect.assertions(8);
+ expect.assertions(2);
const commit = await Commit.lookup(repository, env.AVAIL_COMMIT);
expect(commit).toBeDefined();
expect(commit).toBeInstanceOf(Commit);
-
- expectCommitProperties(commit);
});
it("Should look up a nonexistant commit and throw", async() => {
@@ -42,6 +40,20 @@ describe("Commit", () => {
await expect(Commit.lookupExists(repository, env.UNAVAIL_COMMIT)).resolves.toBeFalsy();
});
+
+ it("Should get multiple commits", async() => {
+ expect.hasAssertions();
+
+ const commits = await Commit.getMultiple(repository);
+
+ expect(commits).toBeDefined();
+ expect(commits).toHaveLength(20);
+
+ for(const commit of commits) {
+ expect(commit).toBeDefined();
+ expect(commit).toBeInstanceOf(Commit);
+ }
+ });
});
describe("Instance methods", () => {
diff --git a/test/unit/repository.unit.test.ts b/test/unit/repository.unit.test.ts
index 752cd59..9aaa748 100644
--- a/test/unit/repository.unit.test.ts
+++ b/test/unit/repository.unit.test.ts
@@ -3,7 +3,7 @@ import { Commit } from "server/src/git/commit";
import { Tree } from "server/src/git/tree";
import { Branch } from "server/src/git/branch";
import { Tag } from "server/src/git/tag";
-import { EnvironmentVariables, expectCommitProperties } from "../util";
+import { EnvironmentVariables } from "../util";
import { ServerError } from "server/src/git/error";
const env = process.env as EnvironmentVariables;
@@ -105,14 +105,12 @@ describe("Repository", () => {
});
it("Should get the head commit", async() => {
- expect.assertions(8);
+ expect.assertions(2);
const master_commit = await repository.head();
expect(master_commit).toBeDefined();
expect(master_commit).toBeInstanceOf(Commit);
-
- expectCommitProperties(master_commit);
});
it("Should get the commits", async() => {
@@ -125,8 +123,6 @@ describe("Repository", () => {
for(const commit of commits) {
expect(commit).toBeDefined();
expect(commit).toBeInstanceOf(Commit);
-
- expectCommitProperties(commit);
}
});
diff --git a/test/util.ts b/test/util.ts
index 30a5c60..9e62ec9 100644
--- a/test/util.ts
+++ b/test/util.ts
@@ -1,5 +1,3 @@
-import { Commit, CommitAuthor } from "server/src/git/commit";
-
export type EnvironmentVariables = {
GIT_DIR: string,
AVAIL_REPO: string,
@@ -9,16 +7,4 @@ export type EnvironmentVariables = {
UNAVAIL_OBJECT: string,
AVAIL_COMMIT: string,
UNAVAIL_COMMIT: string
-}
-
-export function expectCommitProperties(commit: Commit): void {
- expect(commit).toHaveProperty("id");
- expect(commit).toHaveProperty("author");
-
- const author = commit.author();
- expect(author).toBeInstanceOf(CommitAuthor);
-
- expect(commit).toHaveProperty("date");
- expect(commit).toHaveProperty("message");
- expect(commit).toHaveProperty("isSigned");
} \ No newline at end of file