|
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | +import { test, build } from "../../src/optionsImageInfo/calcHashsums"; |
| 3 | + |
| 4 | +describe("calcHashsums", () => { |
| 5 | + describe("test", () => { |
| 6 | + it("should return true if calcHashsums option is defined", () => { |
| 7 | + expect(test({ calcHashsums: ["md5", "sha256"] })).toEqual(true); |
| 8 | + }); |
| 9 | + |
| 10 | + it("should return true if chs option is defined", () => { |
| 11 | + expect(test({ chs: ["sha1"] })).toEqual(true); |
| 12 | + }); |
| 13 | + |
| 14 | + it("should return true if calcHashsums is an empty array", () => { |
| 15 | + expect(test({ calcHashsums: [] })).toEqual(true); |
| 16 | + }); |
| 17 | + |
| 18 | + it("should return false if calcHashsums option is undefined", () => { |
| 19 | + expect(test({})).toEqual(false); |
| 20 | + }); |
| 21 | + }); |
| 22 | + |
| 23 | + describe("build", () => { |
| 24 | + it("should throw an error if calcHashsums option is undefined", () => { |
| 25 | + expect(() => build({})).toThrow("calcHashsums option is undefined"); |
| 26 | + }); |
| 27 | + |
| 28 | + it("should return 'chs:' if calcHashsums is an empty array", () => { |
| 29 | + expect(build({ calcHashsums: [] })).toEqual("chs:"); |
| 30 | + }); |
| 31 | + |
| 32 | + it("should return 'chs:md5' for a single hashsum type", () => { |
| 33 | + expect(build({ calcHashsums: ["md5"] })).toEqual("chs:md5"); |
| 34 | + }); |
| 35 | + |
| 36 | + it("should return 'chs:md5:sha256' for multiple hashsum types", () => { |
| 37 | + expect(build({ calcHashsums: ["md5", "sha256"] })).toEqual( |
| 38 | + "chs:md5:sha256" |
| 39 | + ); |
| 40 | + }); |
| 41 | + |
| 42 | + it("should work with the chs alias", () => { |
| 43 | + expect(build({ chs: ["sha1", "sha512"] })).toEqual("chs:sha1:sha512"); |
| 44 | + }); |
| 45 | + }); |
| 46 | +}); |
0 commit comments