|
|
|
|
@ -1,6 +1,42 @@
|
|
|
|
|
import { messageProcessor } from "./main.js";
|
|
|
|
|
import { jest } from '@jest/globals'
|
|
|
|
|
|
|
|
|
|
test('should fire error message with empty message', () => {
|
|
|
|
|
console.error = jest.fn();
|
|
|
|
|
var errorMessage = "Got mallformed message:";
|
|
|
|
|
var errorParams = { action: undefined, data: undefined };
|
|
|
|
|
|
|
|
|
|
messageProcessor.processMessage();
|
|
|
|
|
expect(console.error).toHaveBeenCalledWith(errorMessage, errorParams);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('should fire error message with empty string', () => {
|
|
|
|
|
console.error = jest.fn();
|
|
|
|
|
var errorMessage = "Got mallformed message:";
|
|
|
|
|
var errorParams = { action: undefined, data: undefined };
|
|
|
|
|
|
|
|
|
|
messageProcessor.processMessage("");
|
|
|
|
|
expect(console.error).toHaveBeenCalledWith(errorMessage, errorParams);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('should fire error message with null', () => {
|
|
|
|
|
console.error = jest.fn();
|
|
|
|
|
var errorMessage = "Got mallformed message:";
|
|
|
|
|
var errorParams = { action: undefined, data: undefined };
|
|
|
|
|
|
|
|
|
|
messageProcessor.processMessage(null);
|
|
|
|
|
expect(console.error).toHaveBeenCalledWith(errorMessage, errorParams);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('should fire error message with undefined', () => {
|
|
|
|
|
console.error = jest.fn();
|
|
|
|
|
var errorMessage = "Got mallformed message:";
|
|
|
|
|
var errorParams = { action: undefined, data: undefined };
|
|
|
|
|
|
|
|
|
|
messageProcessor.processMessage(undefined);
|
|
|
|
|
expect(console.error).toHaveBeenCalledWith(errorMessage, errorParams);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('should fire error message about mallformed message', () => {
|
|
|
|
|
console.error = jest.fn();
|
|
|
|
|
var message = {};
|
|
|
|
|
|