docbrown/app/javascript/utilities/__tests__/sendHapticMessage.test.js
Lawrence 56e10f1306
Notifications Initializer Migration to Pack tag (#19124)
Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
Co-authored-by: Lawrence S <lboogie@Lawrences-Air.attlocal.net>
Co-authored-by: Rajat Talesra <rajat@forem.com>
2023-04-14 17:50:07 -04:00

24 lines
658 B
JavaScript

import { sendHapticMessage } from '../sendHapticMessage';
describe('SendHapticMessage Utility', () => {
it('should call postMessage', async () => {
const mockPostMessage = jest.fn();
global.window.webkit = {
messageHandlers: {
haptic: {
postMessage: mockPostMessage,
},
},
};
await sendHapticMessage('sample message');
expect(mockPostMessage).toHaveBeenCalled();
});
it('should log to console otherwise', async () => {
global.window = {};
global.console.log = jest.fn();
await sendHapticMessage('sample message');
expect(global.console.log).not.toHaveBeenCalled();
});
});