Implement Params.prototype.isDefault() helper (#555)

The isDefault getter is a bit more explict than checking for equalirty against defaultParams.
This commit is contained in:
Camillo Bruni 2026-07-14 16:58:38 +02:00 committed by GitHub
parent 64bbc821c8
commit 8698c7839f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 22 additions and 1 deletions

View file

@ -306,7 +306,7 @@ class MainBenchmarkClient {
}
_populateNonStandardParams() {
if (params === defaultParams)
if (params.isDefault())
return;
const paramsDiff = [];
const usedSearchparams = params.toSearchParamsObject();

View file

@ -211,6 +211,10 @@ export class Params {
toSearchParams() {
return this.toSearchParamsObject().toString();
}
isDefault() {
return this === defaultParams;
}
}
function isValidJsonUrl(url) {

View file

@ -75,6 +75,23 @@ describe("Params", () => {
expect(params.toSearchParams()).to.equal("suites=");
});
});
describe("isDefault", () => {
it("should return true for defaultParams", () => {
expect(defaultParams.isDefault()).to.be(true);
});
it("should return false for newly instantiated empty Params", () => {
const params = new Params();
expect(params.isDefault()).to.be(false);
});
it("should return false for custom params", () => {
const params = new Params(
new URLSearchParams({
iterationCount: "100",
})
);
expect(params.isDefault()).to.be(false);
});
});
describe("parse input params", () => {
it("should parse custom viewport", () => {