refactor(testing): remove use of public keyword (#5051)

This commit is contained in:
Asher Gomez 2024-06-17 15:11:31 +12:00 committed by GitHub
parent f86c10ad8a
commit 935d665713
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 26 additions and 12 deletions

View File

@ -1,6 +1,12 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
export class Point { 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 // deno-lint-ignore no-explicit-any
action(...args: any[]): any { action(...args: any[]): any {
return args[0]; return args[0];

View File

@ -96,12 +96,14 @@
* *
* class User { * class User {
* static users: Map<string, User> = new Map(); * static users: Map<string, User> = new Map();
* name: string;
* age?: number; * age?: number;
* *
* constructor(public name: string) { * constructor(name: string) {
* if (User.users.has(name)) { * if (User.users.has(name)) {
* throw new Deno.errors.AlreadyExists(`User ${name} already exists`); * throw new Deno.errors.AlreadyExists(`User ${name} already exists`);
* } * }
* this.name = name;
* User.users.set(name, this); * User.users.set(name, this);
* } * }
* *
@ -168,12 +170,14 @@
* *
* class User { * class User {
* static users: Map<string, User> = new Map(); * static users: Map<string, User> = new Map();
* name: string;
* age?: number; * age?: number;
* *
* constructor(public name: string) { * constructor(name: string) {
* if (User.users.has(name)) { * if (User.users.has(name)) {
* throw new Deno.errors.AlreadyExists(`User ${name} already exists`); * throw new Deno.errors.AlreadyExists(`User ${name} already exists`);
* } * }
* this.name = name;
* User.users.set(name, this); * User.users.set(name, this);
* } * }
* *
@ -249,12 +253,14 @@
* *
* class User { * class User {
* static users: Map<string, User> = new Map(); * static users: Map<string, User> = new Map();
* name: string;
* age?: number; * age?: number;
* *
* constructor(public name: string) { * constructor(name: string) {
* if (User.users.has(name)) { * if (User.users.has(name)) {
* throw new Deno.errors.AlreadyExists(`User ${name} already exists`); * throw new Deno.errors.AlreadyExists(`User ${name} already exists`);
* } * }
* this.name = name;
* User.users.set(name, this); * User.users.set(name, this);
* } * }
* *
@ -330,12 +336,14 @@
* *
* class User { * class User {
* static users: Map<string, User> = new Map(); * static users: Map<string, User> = new Map();
* name: string;
* age?: number; * age?: number;
* *
* constructor(public name: string) { * constructor(name: string) {
* if (User.users.has(name)) { * if (User.users.has(name)) {
* throw new Deno.errors.AlreadyExists(`User ${name} already exists`); * throw new Deno.errors.AlreadyExists(`User ${name} already exists`);
* } * }
* this.name = name;
* User.users.set(name, this); * User.users.set(name, this);
* } * }
* *

View File

@ -447,7 +447,7 @@ class AssertSnapshotContext {
* This method can safely be called more than once and will only register the teardown * This method can safely be called more than once and will only register the teardown
* function once in a context. * function once in a context.
*/ */
public registerTeardown() { registerTeardown() {
if (!this.#teardownRegistered) { if (!this.#teardownRegistered) {
globalThis.addEventListener("unload", this.#teardown); globalThis.addEventListener("unload", this.#teardown);
this.#teardownRegistered = true; this.#teardownRegistered = true;
@ -458,7 +458,7 @@ class AssertSnapshotContext {
* Gets the number of snapshots which have been created with the same name and increments * Gets the number of snapshots which have been created with the same name and increments
* the count by 1. * the count by 1.
*/ */
public getCount(snapshotName: string) { getCount(snapshotName: string) {
let count = this.#snapshotCounts.get(snapshotName) || 0; let count = this.#snapshotCounts.get(snapshotName) || 0;
this.#snapshotCounts.set(snapshotName, ++count); this.#snapshotCounts.set(snapshotName, ++count);
return count; return count;
@ -467,7 +467,7 @@ class AssertSnapshotContext {
/** /**
* Get an existing snapshot by name or returns `undefined` if the snapshot does not exist. * 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); const snapshots = await this.#readSnapshotFile(options);
return snapshots.get(snapshotName); return snapshots.get(snapshotName);
} }
@ -478,7 +478,7 @@ class AssertSnapshotContext {
* *
* Should only be called when mode is `update`. * Should only be called when mode is `update`.
*/ */
public updateSnapshot(snapshotName: string, snapshot: string) { updateSnapshot(snapshotName: string, snapshot: string) {
if (!this.#snapshotsUpdated.includes(snapshotName)) { if (!this.#snapshotsUpdated.includes(snapshotName)) {
this.#snapshotsUpdated.push(snapshotName); this.#snapshotsUpdated.push(snapshotName);
} }
@ -492,7 +492,7 @@ class AssertSnapshotContext {
/** /**
* Get the number of updated snapshots. * Get the number of updated snapshots.
*/ */
public getUpdatedCount() { getUpdatedCount() {
return this.#snapshotsUpdated.length; return this.#snapshotsUpdated.length;
} }
@ -506,14 +506,14 @@ class AssertSnapshotContext {
* `assertSnapshot` could cause updates to be written to the snapshot file if the * `assertSnapshot` could cause updates to be written to the snapshot file if the
* `update` mode is passed in the options. * `update` mode is passed in the options.
*/ */
public pushSnapshotToUpdateQueue(snapshotName: string) { pushSnapshotToUpdateQueue(snapshotName: string) {
this.snapshotUpdateQueue.push(snapshotName); this.snapshotUpdateQueue.push(snapshotName);
} }
/** /**
* Check if exist snapshot * Check if exist snapshot
*/ */
public hasSnapshot(snapshotName: string): boolean { hasSnapshot(snapshotName: string): boolean {
return this.#currentSnapshots return this.#currentSnapshots
? this.#currentSnapshots.has(snapshotName) ? this.#currentSnapshots.has(snapshotName)
: false; : false;