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

Commit

Permalink
chore: refactor tests to match superstruct examples (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
danroc authored Sep 8, 2023
1 parent ac354ec commit 7fb0d61
Showing 1 changed file with 7 additions and 5 deletions.
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);
});
});

0 comments on commit 7fb0d61

Please sign in to comment.