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:
parent
64bbc821c8
commit
8698c7839f
3 changed files with 22 additions and 1 deletions
|
|
@ -306,7 +306,7 @@ class MainBenchmarkClient {
|
|||
}
|
||||
|
||||
_populateNonStandardParams() {
|
||||
if (params === defaultParams)
|
||||
if (params.isDefault())
|
||||
return;
|
||||
const paramsDiff = [];
|
||||
const usedSearchparams = params.toSearchParamsObject();
|
||||
|
|
|
|||
|
|
@ -211,6 +211,10 @@ export class Params {
|
|||
toSearchParams() {
|
||||
return this.toSearchParamsObject().toString();
|
||||
}
|
||||
|
||||
isDefault() {
|
||||
return this === defaultParams;
|
||||
}
|
||||
}
|
||||
|
||||
function isValidJsonUrl(url) {
|
||||
|
|
|
|||
|
|
@ -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", () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue