Skip to content

Commit

Permalink
chore: deno fmt; deno lint
Browse files Browse the repository at this point in the history
  • Loading branch information
crookse committed Dec 23, 2022
1 parent 5eac43d commit 974ea37
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/fake/fake_mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ export function createFake<OriginalConstructor, OriginalObject>(
methodName,
);

if (!((methodName as string) in (this.#original as Record<string, unknown>))) {
if (
!((methodName as string) in (this.#original as Record<string, unknown>))
) {
const typeSafeMethodName = String(methodName as string);

throw new FakeError(
Expand Down
4 changes: 3 additions & 1 deletion src/mock/mock_mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ export function createMock<OriginalConstructor, OriginalObject>(
methodName,
);

if (!((methodName as string) in (this.#original as Record<string, unknown>))) {
if (
!((methodName as string) in (this.#original as Record<string, unknown>))
) {
const typeSafeMethodName = String(methodName);
throw new MockError(
`Method "${typeSafeMethodName}" does not exist.`,
Expand Down
8 changes: 7 additions & 1 deletion tests/deno/unit/mod/stub_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ Deno.test("Stub()", async (t) => {

await t.step("throws error on Stub(null) calls", () => {
try {
const stub = Stub(null, "prop");
// @ts-ignore This test ensures an error is thrown when `null` is being
// provided as the object containing the property or method to stub. It is
// the first check in the `Stub()` call. Even though `Stub(null)` cannot
// happen in TypeScript if type-checking is on, this can still happen in
// JS. This is ignored because it is being tested in TypeScript, but this
// SHOULD only happen in JavaScript.
Stub(null, "prop");
} catch (error) {
assertEquals(error.message, "Cannot create a stub using Stub(null)");
}
Expand Down

0 comments on commit 974ea37

Please sign in to comment.