-
Notifications
You must be signed in to change notification settings - Fork 538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding unit tests for FoxgloveWebSocketPlayer module #335
base: main
Are you sure you want to change the base?
Conversation
Quality Gate passedIssues Measures |
|
||
const result = dataTypeToFullName(message); | ||
|
||
expect(result).toContain("/msg/"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect(result).toBe("unit/msg/test") to be more precise
export type ToWorkerMessage = | ||
| { type: "open"; data: { wsUrl: string; protocols?: string[] | string } } | ||
| { type: "close"; data: undefined } | ||
| { type: "data"; data: string | ArrayBuffer | ArrayBufferView }; // SPDX-FileCopyrightText: Copyright (C) 2023-2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)<[email protected]> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove ours from here and put the old one in the top of the file
it("should not call onerror if it is undefined", () => { | ||
mockWorker.onmessage?.({ data: { type: "error" } } as MessageEvent); | ||
|
||
expect(adapter.onerror).toBeUndefined(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should expect the onerror
not to have been called as well.
expect(adapter.onerror).toBeUndefined(); | |
expect(adapter.onerror).toBeUndefined(); | |
expect(onErrorMock).not.toHaveBeenCalled(); |
it("should not call onmessage if it is undefined", () => { | ||
mockWorker.onmessage?.({ data: { type: "message" } } as MessageEvent); | ||
|
||
expect(adapter.onmessage).toBeUndefined(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should expect the onmessage
not to have been called as well.
expect(adapter.onmessage).toBeUndefined(); | |
expect(adapter.onmessage).toBeUndefined(); | |
expect(onMessageMock).not.toHaveBeenCalled(); |
const errorEvent = { message: "error" } as ErrorEvent; | ||
mockWorker.onerror?.(errorEvent); | ||
|
||
expect(adapter.onerror).toBeUndefined(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be undefined since it is being set as undefined in L169. You can delete this test.
User-Facing Changes
N/A
Description
Added some unit tests to files that provide support for the WebSocket player, also did some refactoring on the module.
Couldn't finish testing the whole module because I was having trouble accessing private fields and methods of the websocket class.
Checklist