From 81b2d3df856a284841ef96a09742396d0c4a00ea Mon Sep 17 00:00:00 2001 From: Kir_Antipov Date: Tue, 7 Dec 2021 21:57:46 +0300 Subject: [PATCH] Covered DependencyKind with tests --- test/dependency-kind.test.ts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 test/dependency-kind.test.ts diff --git a/test/dependency-kind.test.ts b/test/dependency-kind.test.ts new file mode 100644 index 0000000..30980e2 --- /dev/null +++ b/test/dependency-kind.test.ts @@ -0,0 +1,34 @@ +import { describe, test, expect } from "@jest/globals"; +import DependencyKind from "../src/metadata/dependency-kind"; + +describe("DependencyKind.getValues", () => { + test("all DependencyKind values are returned", () => { + const kinds = DependencyKind.getValues(); + expect(kinds).toHaveLength(6); + expect(kinds).toContain(DependencyKind.Depends); + expect(kinds).toContain(DependencyKind.Recommends); + expect(kinds).toContain(DependencyKind.Includes); + expect(kinds).toContain(DependencyKind.Suggests); + expect(kinds).toContain(DependencyKind.Conflicts); + expect(kinds).toContain(DependencyKind.Breaks); + }); +}); + +describe("DependencyKind.parse", () => { + test("every DependencyKind can be parsed", () => { + for (const kind of DependencyKind.getValues()) { + expect(DependencyKind.parse(DependencyKind.toString(kind))).toStrictEqual(kind); + } + }); + + test("DependencyKind's name is case-insensitive", () => { + for (const kind of DependencyKind.getValues()) { + expect(DependencyKind.parse(DependencyKind.toString(kind).toLowerCase())).toStrictEqual(kind); + expect(DependencyKind.parse(DependencyKind.toString(kind).toUpperCase())).toStrictEqual(kind); + } + }); + + test("undefined is returned when the value cannot be parsed", () => { + expect(DependencyKind.parse("There's no such dependency kind")).toBeUndefined(); + }); +}); \ No newline at end of file