|
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | +import { test, build } from "../../src/options/maxResultDimension"; |
| 3 | + |
| 4 | +describe("maxResultDimension", () => { |
| 5 | + describe("test", () => { |
| 6 | + it("should return true if max_result_dimension option is defined", () => { |
| 7 | + expect(test({ max_result_dimension: 1920 })).toEqual(true); |
| 8 | + }); |
| 9 | + |
| 10 | + it("should return true if mrd option is defined", () => { |
| 11 | + expect(test({ mrd: 2560 })).toEqual(true); |
| 12 | + }); |
| 13 | + |
| 14 | + it("should return false if max_result_dimension option is undefined", () => { |
| 15 | + expect(test({})).toEqual(false); |
| 16 | + }); |
| 17 | + }); |
| 18 | + |
| 19 | + describe("build", () => { |
| 20 | + it("should throw an error if max_result_dimension option is undefined", () => { |
| 21 | + expect(() => build({})).toThrow( |
| 22 | + "max_result_dimension option is undefined" |
| 23 | + ); |
| 24 | + }); |
| 25 | + |
| 26 | + it("should throw an error if max_result_dimension is not a number", () => { |
| 27 | + // @ts-expect-error: Let's ignore an error (check for users with vanilla js). |
| 28 | + expect(() => build({ max_result_dimension: "1920" })).toThrow( |
| 29 | + "max_result_dimension option is not a number" |
| 30 | + ); |
| 31 | + }); |
| 32 | + |
| 33 | + it("should throw an error if max_result_dimension is less than 0", () => { |
| 34 | + expect(() => build({ max_result_dimension: -1 })).toThrow( |
| 35 | + "max_result_dimension option value can't be less then 0" |
| 36 | + ); |
| 37 | + }); |
| 38 | + |
| 39 | + it("should return mrd:0 if max_result_dimension option is 0", () => { |
| 40 | + expect(build({ max_result_dimension: 0 })).toEqual("mrd:0"); |
| 41 | + }); |
| 42 | + |
| 43 | + it("should return mrd:1920 if mrd option is 1920", () => { |
| 44 | + expect(build({ mrd: 1920 })).toEqual("mrd:1920"); |
| 45 | + }); |
| 46 | + |
| 47 | + it("should return mrd:2560 if max_result_dimension option is 2560", () => { |
| 48 | + expect(build({ max_result_dimension: 2560 })).toEqual("mrd:2560"); |
| 49 | + }); |
| 50 | + |
| 51 | + it("should work with 0", () => { |
| 52 | + expect(build({ max_result_dimension: 0 })).toEqual("mrd:0"); |
| 53 | + expect(build({ mrd: 0 })).toEqual("mrd:0"); |
| 54 | + }); |
| 55 | + }); |
| 56 | +}); |
0 commit comments