Skip to content

Commit

Permalink
chore: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
crutchcorn committed Apr 2, 2024
1 parent 23b9fde commit a0d2527
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions lib/reactotron-core-client/src/client-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ type BrowserWebSocket = WebSocket
/**
* Configuration options for the Reactotron Client.
*/
export interface ClientOptions<Client> extends LifeCycleMethods {
export interface ClientOptions<Client> extends Omit<LifeCycleMethods, "onCommand"> {
/**
* A function which returns a websocket.
*
* This is over-engineered because we need the ability to create different
* types of websockets for React Native, React, and NodeJS. :|
*/
createSocket?: ((path: string) => BrowserWebSocket) | ((path: string) => NodeWebSocket)
createSocket?: ((path: string) => BrowserWebSocket) | ((path: string) => NodeWebSocket) | null

/**
* The hostname or ip address of the server. Default: localhost.
*/
host?: string
host?: string | null

/**
* The port to connect to the server on. Default: 9090.
*/
port?: number
port?: number | null

/**
* The name of this client. Usually the app name.
Expand Down Expand Up @@ -55,7 +55,7 @@ export interface ClientOptions<Client> extends LifeCycleMethods {
/**
* Fires when the server sends a command.
*/
onCommand?: (command: any) => void
onCommand?: ((command: any) => void) | null

/**
* Fires when we connect to the server.
Expand Down
2 changes: 1 addition & 1 deletion lib/reactotron-core-client/test/configure.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createClient } from "../src/reactotron-core-client"
import WebSocket from "ws"
import { WebSocket } from "ws"

const createSocket = (path) => new WebSocket(path)

Expand Down
4 changes: 2 additions & 2 deletions lib/reactotron-core-client/test/plugin-clear.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { createClient, corePlugins } from "../src/reactotron-core-client"
import plugin from "../src/plugins/clear"
import WebSocket from "ws"
import { WebSocket } from "ws"

const createSocket = (path) => new WebSocket(path)

test("clears", () => {
const client: any = createClient({ createSocket })
const results = []
const results = [] as Array<{ type: string; payload: any }>
client.send = (type, payload) => results.push({ type, payload })
client.use(plugin())
expect(client.plugins.length).toBe(corePlugins.length + 1)
Expand Down
4 changes: 2 additions & 2 deletions lib/reactotron-core-client/test/plugin-logger.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { createClient, corePlugins } from "../src/reactotron-core-client"
import plugin from "../src/plugins/logger"
import WebSocket from "ws"
import { WebSocket } from "ws"

const createSocket = (path) => new WebSocket(path)

test("the 4 functions send the right data", () => {
const client: any = createClient({ createSocket })
const results = []
const results = [] as Array<{ type: string; payload: any }>
client.send = (type, payload) => {
results.push({ type, payload })
}
Expand Down

0 comments on commit a0d2527

Please sign in to comment.