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>
24 lines
658 B
JavaScript
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();
|
|
});
|
|
});
|