Skip to content

Commit

Permalink
chore: remove unused helpers (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
OrKoN authored Feb 2, 2022
1 parent 6f3cf78 commit 9909e9d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 83 deletions.
34 changes: 0 additions & 34 deletions src/SchemaUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,40 +69,6 @@ export const typeableInputTypes = new Set([
"email",
]);

export function createViewportStep(viewport: {
clientWidth: number;
clientHeight: number;
}): SetViewportStep {
return {
type: "setViewport",
width: viewport.clientWidth,
height: viewport.clientHeight,
// TODO read real parameters here
deviceScaleFactor: 1,
isMobile: false,
hasTouch: false,
isLandscape: false,
};
}

export function createEmulateNetworkConditionsStep(conditions: {
download: number;
upload: number;
latency: number;
}): EmulateNetworkConditionsStep {
return {
type: "emulateNetworkConditions",
...conditions,
};
}

export function areSelectorsEqual(stepA: Step, stepB: Step): boolean {
if ("selectors" in stepA && "selectors" in stepB) {
return JSON.stringify(stepA.selectors) === JSON.stringify(stepB.selectors);
}
return !("selectors" in stepA) && !("selectors" in stepB);
}

function hasProperty<KeyType extends PropertyKey>(
data: object,
prop: KeyType
Expand Down
50 changes: 1 addition & 49 deletions test/SchemaUtils_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,58 +14,10 @@
limitations under the License.
*/

import { areSelectorsEqual, parse } from "../src/SchemaUtils.js";
import { parse } from "../src/SchemaUtils.js";
import { assert } from "chai";

describe("SchemaUtils", () => {
it("should compare step selectors", () => {
assert.isTrue(
areSelectorsEqual(
{
type: "scroll",
},
{
type: "scroll",
}
)
);
assert.isFalse(
areSelectorsEqual(
{
type: "scroll",
selectors: [["#id"]],
},
{
type: "scroll",
}
)
);
assert.isTrue(
areSelectorsEqual(
{
type: "scroll",
selectors: [["#id"]],
},
{
type: "scroll",
selectors: [["#id"]],
}
)
);
assert.isFalse(
areSelectorsEqual(
{
type: "scroll",
selectors: [["#id", "#id2"]],
},
{
type: "scroll",
selectors: [["#id"]],
}
)
);
});

describe("Schema parser", () => {
it("should parse a sample Schema JSON", () => {
const actual = parse({
Expand Down

0 comments on commit 9909e9d

Please sign in to comment.