Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

chore: refactor tests to match superstruct examples #104

Merged
merged 1 commit into from
Sep 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/JsonRpcRequest.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { is } from 'superstruct';

import { JsonRpcRequestStruct } from './JsonRpcRequest';

describe('JsonRpcRequestStruct', () => {
Expand All @@ -9,7 +11,7 @@ describe('JsonRpcRequestStruct', () => {
params: [1, 2, 3],
};

expect(JsonRpcRequestStruct.is(request)).toBe(true);
expect(is(request, JsonRpcRequestStruct)).toBe(true);
});

it('should be a valid JsonRpcRequest with a string ID', () => {
Expand All @@ -20,7 +22,7 @@ describe('JsonRpcRequestStruct', () => {
params: [1, 2, 3],
};

expect(JsonRpcRequestStruct.is(request)).toBe(true);
expect(is(request, JsonRpcRequestStruct)).toBe(true);
});

it('should be a valid JsonRpcRequest with a null ID', () => {
Expand All @@ -31,7 +33,7 @@ describe('JsonRpcRequestStruct', () => {
params: [1, 2, 3],
};

expect(JsonRpcRequestStruct.is(request)).toBe(true);
expect(is(request, JsonRpcRequestStruct)).toBe(true);
});

it('should be a valid JsonRpcRequest without params', () => {
Expand All @@ -41,7 +43,7 @@ describe('JsonRpcRequestStruct', () => {
method: 'my_method',
};

expect(JsonRpcRequestStruct.is(request)).toBe(true);
expect(is(request, JsonRpcRequestStruct)).toBe(true);
});

it('should not be a valid JsonRpcRequest if params is undefined', () => {
Expand All @@ -52,6 +54,6 @@ describe('JsonRpcRequestStruct', () => {
params: undefined,
};

expect(JsonRpcRequestStruct.is(request)).toBe(false);
expect(is(request, JsonRpcRequestStruct)).toBe(false);
});
});