Skip to content

Commit

Permalink
fix potential test case failure
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Sandee committed Jun 8, 2022
1 parent 5db568e commit 24238ee
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/test/assertions.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
/** custom assertions that do a nicer job of type narrowing */

import { Ok, Result, Error } from "../utils";
import { Error, Ok, Result } from "../utils";

export const assertOk = <T1, T2>(
// note that using our preferred func-style actually changes behavior here for some reason and causes test failures (ts(2775))
/* eslint-disable func-style */

export function assertOk<T1, T2>(
result: Result<T1, T2>
): asserts result is Ok<T1, T2> => {
): asserts result is Ok<T1, T2> {
expect(result.isOk()).toEqual(true);
};
}

export const assertError = <T1, T2>(
export function assertError<T1, T2>(
result: Result<T1, T2>
): asserts result is Error<T1, T2> => {
): asserts result is Error<T1, T2> {
expect(result.isError()).toEqual(true);
};
}

export const assertInstanceOf = <T1>(
export function assertInstanceOf<T1>(
value: unknown,
type: T1
): asserts value is T1 => {
): asserts value is T1 {
expect(value).toBeInstanceOf(type);
};
}

0 comments on commit 24238ee

Please sign in to comment.