|
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | +import { test, build } from "../../src/optionsImageInfo/pagesNumber"; |
| 3 | + |
| 4 | +describe("pages_number", () => { |
| 5 | + describe("test", () => { |
| 6 | + it("should return true if pages_number option is defined", () => { |
| 7 | + expect(test({ pages_number: 1 })).toEqual(true); |
| 8 | + }); |
| 9 | + |
| 10 | + it("should return true if pages_number option is false", () => { |
| 11 | + expect(test({ pn: false })).toEqual(true); |
| 12 | + }); |
| 13 | + |
| 14 | + it("should return false if pages_number option is undefined", () => { |
| 15 | + expect(test({})).toEqual(false); |
| 16 | + }); |
| 17 | + |
| 18 | + it("should return true if pn option is defined", () => { |
| 19 | + expect(test({ pn: "t" })).toEqual(true); |
| 20 | + }); |
| 21 | + }); |
| 22 | + |
| 23 | + describe("build", () => { |
| 24 | + it("should throw an error if pages_number option is undefined", () => { |
| 25 | + expect(() => build({})).toThrow("pages_number option is undefined"); |
| 26 | + }); |
| 27 | + |
| 28 | + it("should return 't' if pages_number option is 1", () => { |
| 29 | + expect(build({ pages_number: 1 })).toEqual("pn:t"); |
| 30 | + }); |
| 31 | + |
| 32 | + it("should return 't' if s option is 't'", () => { |
| 33 | + expect(build({ pn: "t" })).toEqual("pn:t"); |
| 34 | + }); |
| 35 | + |
| 36 | + it("should return 't' if pages_number option is true", () => { |
| 37 | + expect(build({ pages_number: true })).toEqual("pn:t"); |
| 38 | + }); |
| 39 | + |
| 40 | + it("should return 'f' if pages_number option is false", () => { |
| 41 | + expect(build({ pages_number: false })).toEqual("pn:f"); |
| 42 | + }); |
| 43 | + |
| 44 | + it("should return 'f' if pages_number option is 0", () => { |
| 45 | + // @ts-expect-error: Let's ignore an error. |
| 46 | + expect(build({ pages_number: 0 })).toEqual("pn:f"); |
| 47 | + }); |
| 48 | + |
| 49 | + it("should return 'f' if pages_number option is string (except 't')", () => { |
| 50 | + expect(build({ pages_number: "true" })).toEqual("pn:f"); |
| 51 | + }); |
| 52 | + }); |
| 53 | +}); |
0 commit comments