|
| 1 | +import { Params, defaultParams } from "../../resources/shared/params.mjs"; |
| 2 | + |
| 3 | +describe("Params", () => { |
| 4 | + describe("toSearchParams", () => { |
| 5 | + it("should be empty for defaultParams", () => { |
| 6 | + expect(defaultParams.toSearchParams()).to.equal(""); |
| 7 | + }); |
| 8 | + it("should be empty for empty Params", () => { |
| 9 | + const params = new Params(); |
| 10 | + expect(params.toSearchParams()).to.equal(""); |
| 11 | + }); |
| 12 | + it("should contain custom viewport", () => { |
| 13 | + const params = new Params( |
| 14 | + new URLSearchParams({ |
| 15 | + viewport: "100x200", |
| 16 | + }) |
| 17 | + ); |
| 18 | + expect(params.toSearchParams()).to.equal("viewport=100x200"); |
| 19 | + }); |
| 20 | + it("should not contain default viewport", () => { |
| 21 | + const params = new Params( |
| 22 | + new URLSearchParams({ |
| 23 | + viewport: "800x600", |
| 24 | + }) |
| 25 | + ); |
| 26 | + expect(params.toSearchParams()).to.equal(""); |
| 27 | + }); |
| 28 | + it("should contain custom iterationCount", () => { |
| 29 | + const params = new Params( |
| 30 | + new URLSearchParams({ |
| 31 | + iterationCount: "100", |
| 32 | + }) |
| 33 | + ); |
| 34 | + expect(params.toSearchParams()).to.equal("iterationCount=100"); |
| 35 | + }); |
| 36 | + it("should contain single suite", () => { |
| 37 | + const params = new Params( |
| 38 | + new URLSearchParams({ |
| 39 | + suites: "Suite1", |
| 40 | + }) |
| 41 | + ); |
| 42 | + expect(params.toSearchParams()).to.equal("suites=Suite1"); |
| 43 | + }); |
| 44 | + it("should contain multiple single suite", () => { |
| 45 | + const params = new Params( |
| 46 | + new URLSearchParams({ |
| 47 | + suites: "SuiteB,Suite1,SuiteA", |
| 48 | + }) |
| 49 | + ); |
| 50 | + expect(params.toSearchParams()).to.equal("suites=SuiteB%2CSuite1%2CSuiteA"); |
| 51 | + }); |
| 52 | + it("should contain multiple tags", () => { |
| 53 | + const params = new Params( |
| 54 | + new URLSearchParams({ |
| 55 | + tags: "tagB,tag1,tagA", |
| 56 | + }) |
| 57 | + ); |
| 58 | + expect(params.toSearchParams()).to.equal("tags=tagB%2Ctag1%2CtagA"); |
| 59 | + }); |
| 60 | + }); |
| 61 | + |
| 62 | + describe("parse input params", () => { |
| 63 | + it("should parse custom viewport", () => { |
| 64 | + const params = new Params( |
| 65 | + new URLSearchParams({ |
| 66 | + viewport: "100x300", |
| 67 | + }) |
| 68 | + ); |
| 69 | + expect(params.viewport).to.eql({ width: 100, height: 300 }); |
| 70 | + }); |
| 71 | + it("should parse custom iterationCount", () => { |
| 72 | + const params = new Params( |
| 73 | + new URLSearchParams({ |
| 74 | + iterationCount: "100", |
| 75 | + }) |
| 76 | + ); |
| 77 | + expect(params.iterationCount).to.equal(100); |
| 78 | + }); |
| 79 | + it("should parse custom tags", () => { |
| 80 | + const params = new Params( |
| 81 | + new URLSearchParams({ |
| 82 | + tags: "tagB,tag1,tagA", |
| 83 | + }) |
| 84 | + ); |
| 85 | + expect(params.tags).to.eql(["tagB", "tag1", "tagA"]); |
| 86 | + }); |
| 87 | + it("should parse custom suites", () => { |
| 88 | + const params = new Params( |
| 89 | + new URLSearchParams({ |
| 90 | + suites: "SuiteB,Suite1,SuiteA", |
| 91 | + }) |
| 92 | + ); |
| 93 | + expect(params.suites).to.eql(["SuiteB", "Suite1", "SuiteA"]); |
| 94 | + }); |
| 95 | + }); |
| 96 | +}); |
0 commit comments