import { SimplySmartController } from "./SimplySmartController"; import { LayoutState } from "../common/state/LayoutState"; import { Mock, It, IMock, Times } from 'typemoq'; import { expect } from 'chai'; describe('Simply Smart Controller', () => { let $window: ng.IWindowService; let $state: IMock; let controller: SimplySmartController; let $location: IMock; let assets: IMock; let experimentService: IMock; let mixpanelService: IMock<{ track(event: string, params: any): any }>; let RUNNING_EXPERIMENTS: any; beforeEach(() => { assets = Mock.ofType(); experimentService = Mock.ofType(); mixpanelService = Mock.ofType(); $state = Mock.ofType(); $location = Mock.ofType(); RUNNING_EXPERIMENTS = { 'SIMPLY_SMART': 'QS - Simply smart' }; controller = new SimplySmartController($window, $state.object, { forcedToView: false }, $location.object, assets, {} as LayoutState, RUNNING_EXPERIMENTS, experimentService.object, mixpanelService.object); }); it('should redirect users to the tariffs saving the users options', () => { mixpanelService.setup(x => x.track("QS - Viewed Simply Smart Page", { forcedToView: false })).verifiable(); mixpanelService.verify(x => x.track("QS - Viewed Simply Smart Page", It.isValue({ forcedToView: false })), Times.once()); $location.setup(x => x.path(It.isAnyString())).returns(() => $location.object); controller.gotoTariffs(true); experimentService.verify(x => x.saveProperty("QS - Simply smart", "isSimplySmart", true), Times.once()); mixpanelService.verify(x => x.track("QS - Simply Smart", It.isValue({ simplySmart: true })), Times.once()); }); });