aboutsummaryrefslogtreecommitdiff
path: root/test/unit/tag.unit.test.ts
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2021-07-27 16:51:54 +0200
committerHampusM <hampus@hampusmat.com>2021-07-27 16:51:54 +0200
commit055a58e79fb225978d64a3c8e3e25377cc2a5ece (patch)
tree8c37c249b93dfeb507afbf6b156955c96ad3bd49 /test/unit/tag.unit.test.ts
parentfa44d81b658024685e0496150d66a51f2f5fda8c (diff)
Added new unit tests & the test setup script uses Nodegit instead of exec
Diffstat (limited to 'test/unit/tag.unit.test.ts')
-rw-r--r--test/unit/tag.unit.test.ts52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/unit/tag.unit.test.ts b/test/unit/tag.unit.test.ts
new file mode 100644
index 0000000..8321092
--- /dev/null
+++ b/test/unit/tag.unit.test.ts
@@ -0,0 +1,52 @@
+import { Repository } from "../../packages/server/src/git/repository";
+import { Tag } from "../../packages/server/src/git/tag";
+import { EnvironmentVariables } from "../util";
+
+const env = process.env as EnvironmentVariables;
+
+describe("Tag", () => {
+ describe("Class methods", () => {
+ it("Should lookup a tag", async() => {
+ expect.assertions(2);
+
+ const repository = await Repository.open(env.BASE_DIR, env.AVAIL_REPO);
+
+ const tag = await Tag.lookup(repository, "1.2");
+
+ expect(tag).toBeDefined();
+ expect(tag).toBeInstanceOf(Tag);
+ });
+ });
+
+ describe("Instance methods", () => {
+ let tag: Tag;
+
+ beforeAll(async() => {
+ const repository = await Repository.open(env.BASE_DIR, env.AVAIL_REPO);
+ tag = await Tag.lookup(repository, "1.2");
+ });
+
+ it("Should get the author", async() => {
+ expect.assertions(5);
+
+ const author = await tag.author();
+
+ expect(author).toBeDefined();
+
+ expect(author).toHaveProperty("name");
+ expect(author.name).toEqual("BobDylan");
+
+ expect(author).toHaveProperty("email");
+ expect(author.email).toEqual("bob@example.com");
+ });
+
+ it("Should get the date", async() => {
+ expect.assertions(2);
+
+ const date = await tag.date();
+
+ expect(date).toBeDefined();
+ expect(typeof date).toEqual("number");
+ });
+ });
+}); \ No newline at end of file