From 935d665713bd32d37ba9943122286b39f790db81 Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Mon, 17 Jun 2024 15:11:31 +1200 Subject: [PATCH] refactor(testing): remove use of `public` keyword (#5051) --- testing/_test_utils.ts | 8 +++++++- testing/bdd.ts | 16 ++++++++++++---- testing/snapshot.ts | 14 +++++++------- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/testing/_test_utils.ts b/testing/_test_utils.ts index 825ee26f8..d41a3500c 100755 --- a/testing/_test_utils.ts +++ b/testing/_test_utils.ts @@ -1,6 +1,12 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. export class Point { - constructor(public x: number, public y: number) {} + x: number; + y: number; + + constructor(x: number, y: number) { + this.x = x; + this.y = y; + } // deno-lint-ignore no-explicit-any action(...args: any[]): any { return args[0]; diff --git a/testing/bdd.ts b/testing/bdd.ts index 8f4bb9a28..8f7266b4d 100644 --- a/testing/bdd.ts +++ b/testing/bdd.ts @@ -96,12 +96,14 @@ * * class User { * static users: Map = new Map(); + * name: string; * age?: number; * - * constructor(public name: string) { + * constructor(name: string) { * if (User.users.has(name)) { * throw new Deno.errors.AlreadyExists(`User ${name} already exists`); * } + * this.name = name; * User.users.set(name, this); * } * @@ -168,12 +170,14 @@ * * class User { * static users: Map = new Map(); + * name: string; * age?: number; * - * constructor(public name: string) { + * constructor(name: string) { * if (User.users.has(name)) { * throw new Deno.errors.AlreadyExists(`User ${name} already exists`); * } + * this.name = name; * User.users.set(name, this); * } * @@ -249,12 +253,14 @@ * * class User { * static users: Map = new Map(); + * name: string; * age?: number; * - * constructor(public name: string) { + * constructor(name: string) { * if (User.users.has(name)) { * throw new Deno.errors.AlreadyExists(`User ${name} already exists`); * } + * this.name = name; * User.users.set(name, this); * } * @@ -330,12 +336,14 @@ * * class User { * static users: Map = new Map(); + * name: string; * age?: number; * - * constructor(public name: string) { + * constructor(name: string) { * if (User.users.has(name)) { * throw new Deno.errors.AlreadyExists(`User ${name} already exists`); * } + * this.name = name; * User.users.set(name, this); * } * diff --git a/testing/snapshot.ts b/testing/snapshot.ts index 71858efd0..3c4592297 100644 --- a/testing/snapshot.ts +++ b/testing/snapshot.ts @@ -447,7 +447,7 @@ class AssertSnapshotContext { * This method can safely be called more than once and will only register the teardown * function once in a context. */ - public registerTeardown() { + registerTeardown() { if (!this.#teardownRegistered) { globalThis.addEventListener("unload", this.#teardown); this.#teardownRegistered = true; @@ -458,7 +458,7 @@ class AssertSnapshotContext { * Gets the number of snapshots which have been created with the same name and increments * the count by 1. */ - public getCount(snapshotName: string) { + getCount(snapshotName: string) { let count = this.#snapshotCounts.get(snapshotName) || 0; this.#snapshotCounts.set(snapshotName, ++count); return count; @@ -467,7 +467,7 @@ class AssertSnapshotContext { /** * Get an existing snapshot by name or returns `undefined` if the snapshot does not exist. */ - public async getSnapshot(snapshotName: string, options: SnapshotOptions) { + async getSnapshot(snapshotName: string, options: SnapshotOptions) { const snapshots = await this.#readSnapshotFile(options); return snapshots.get(snapshotName); } @@ -478,7 +478,7 @@ class AssertSnapshotContext { * * Should only be called when mode is `update`. */ - public updateSnapshot(snapshotName: string, snapshot: string) { + updateSnapshot(snapshotName: string, snapshot: string) { if (!this.#snapshotsUpdated.includes(snapshotName)) { this.#snapshotsUpdated.push(snapshotName); } @@ -492,7 +492,7 @@ class AssertSnapshotContext { /** * Get the number of updated snapshots. */ - public getUpdatedCount() { + getUpdatedCount() { return this.#snapshotsUpdated.length; } @@ -506,14 +506,14 @@ class AssertSnapshotContext { * `assertSnapshot` could cause updates to be written to the snapshot file if the * `update` mode is passed in the options. */ - public pushSnapshotToUpdateQueue(snapshotName: string) { + pushSnapshotToUpdateQueue(snapshotName: string) { this.snapshotUpdateQueue.push(snapshotName); } /** * Check if exist snapshot */ - public hasSnapshot(snapshotName: string): boolean { + hasSnapshot(snapshotName: string): boolean { return this.#currentSnapshots ? this.#currentSnapshots.has(snapshotName) : false;