import { chrome } from 'jest-chrome'; import { RemoteExecuteEventModel } from '@lenovo-software/lsa-clients-common/dist/models/eventModels'; import { WebViewWindowController } from '../webViewWindowController'; let wvc; beforeAll(async () => { wvc = new WebViewWindowController(); }); const executeMock = jest.fn(); beforeEach(() => { executeMock.mockClear(); }); jest.mock('../executor', () => { return { Executor: class Executor { execute(data: RemoteExecuteEventModel) { executeMock(data); } } }; }); describe('WebViewWindowController', () => { it('should open learn more url in the new tab', () => { const request = { message: 'LearnMoreAboutStatus', launchURL: 'https://example.com/lsa-learn-more' }; chrome.runtime.onMessage.callListeners(request, {}, jest.fn()); expect(executeMock).toHaveBeenCalledWith({ path: request.launchURL, teacherInfo: null }); }); it('should not open url in the new tab', () => { const request = { message: 'LearnMoreAboutStatus', launchURL: undefined }; chrome.runtime.onMessage.callListeners(request, {}, jest.fn()); expect(executeMock).not.toHaveBeenCalled(); }); });