diff --git a/src/electron/views/device-connect-view/components/android-setup/prompt-install-service-step.tsx b/src/electron/views/device-connect-view/components/android-setup/prompt-install-service-step.tsx index 5f1e2132041..c4fc81836a8 100644 --- a/src/electron/views/device-connect-view/components/android-setup/prompt-install-service-step.tsx +++ b/src/electron/views/device-connect-view/components/android-setup/prompt-install-service-step.tsx @@ -11,24 +11,15 @@ import { AndroidSetupStepLayout, AndroidSetupStepLayoutProps } from './android-s import { CommonAndroidSetupStepProps } from './android-setup-types'; import * as styles from './prompt-install-service-step.scss'; +export const installAutomationId = 'install'; export const PromptInstallServiceStep = NamedFC( 'PromptInstallServiceStep', (props: CommonAndroidSetupStepProps) => { - const onCancelButton = () => { - // To be implemented in future feature work - console.log(`androidSetupActionCreator.cancel()`); - }; - - const onInstallButton = () => { - // To be implemented in future feature work - console.log(`androidSetupActionCreator.installService()`); - }; - const layoutProps: AndroidSetupStepLayoutProps = { headerText: 'Let us install the latest version on your device', leftFooterButtonProps: { text: 'Cancel', - onClick: onCancelButton, + onClick: _ => props.deps.androidSetupActionCreator.cancel(), }, rightFooterButtonProps: { text: 'Next', @@ -49,7 +40,11 @@ export const PromptInstallServiceStep = NamedFC( either missing or out of date. We'll need to install the latest version. - + ); }, diff --git a/src/tests/unit/tests/electron/views/device-connect-view/components/android-setup/__snapshots__/prompt-install-service-step.test.tsx.snap b/src/tests/unit/tests/electron/views/device-connect-view/components/android-setup/__snapshots__/prompt-install-service-step.test.tsx.snap index e9af1364dff..c9d1497bc4c 100644 --- a/src/tests/unit/tests/electron/views/device-connect-view/components/android-setup/__snapshots__/prompt-install-service-step.test.tsx.snap +++ b/src/tests/unit/tests/electron/views/device-connect-view/components/android-setup/__snapshots__/prompt-install-service-step.test.tsx.snap @@ -27,6 +27,7 @@ exports[`PromptInstallServiceStep renders with device 1`] = ` isEmulator={false} /> @@ -60,6 +61,7 @@ exports[`PromptInstallServiceStep renders with emulator 1`] = ` isEmulator={true} /> diff --git a/src/tests/unit/tests/electron/views/device-connect-view/components/android-setup/prompt-install-service-step.test.tsx b/src/tests/unit/tests/electron/views/device-connect-view/components/android-setup/prompt-install-service-step.test.tsx index 311404f42d3..fc381b1f956 100644 --- a/src/tests/unit/tests/electron/views/device-connect-view/components/android-setup/prompt-install-service-step.test.tsx +++ b/src/tests/unit/tests/electron/views/device-connect-view/components/android-setup/prompt-install-service-step.test.tsx @@ -1,17 +1,27 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +import { AndroidSetupActionCreator } from 'electron/flux/action-creator/android-setup-action-creator'; import { DeviceInfo } from 'electron/platform/android/android-service-configurator'; +import { AndroidSetupStepLayout } from 'electron/views/device-connect-view/components/android-setup/android-setup-step-layout'; import { CommonAndroidSetupStepProps } from 'electron/views/device-connect-view/components/android-setup/android-setup-types'; -import { PromptInstallServiceStep } from 'electron/views/device-connect-view/components/android-setup/prompt-install-service-step'; +import { + installAutomationId, + PromptInstallServiceStep, +} from 'electron/views/device-connect-view/components/android-setup/prompt-install-service-step'; import { shallow } from 'enzyme'; import * as React from 'react'; import { AndroidSetupStepPropsBuilder } from 'tests/unit/common/android-setup-step-props-builder'; +import { IMock, Mock, Times } from 'typemoq'; describe('PromptInstallServiceStep', () => { let props: CommonAndroidSetupStepProps; + let androidSetupActionCreatorMock: IMock; beforeEach(() => { - props = new AndroidSetupStepPropsBuilder('prompt-install-service').build(); + androidSetupActionCreatorMock = Mock.ofType(AndroidSetupActionCreator); + props = new AndroidSetupStepPropsBuilder('prompt-install-service') + .withDep('androidSetupActionCreator', androidSetupActionCreatorMock.object) + .build(); }); it('renders with device', () => { @@ -39,4 +49,17 @@ describe('PromptInstallServiceStep', () => { const rendered = shallow(); expect(rendered.getElement()).toMatchSnapshot(); }); + + it('calls cancel action when cancel button selected', () => { + const rendered = shallow(); + const stubEvent = {} as React.MouseEvent; + rendered.find(AndroidSetupStepLayout).prop('leftFooterButtonProps').onClick(stubEvent); + androidSetupActionCreatorMock.verify(m => m.cancel(), Times.once()); + }); + + it('handles the install button with the next action', () => { + const rendered = shallow(); + rendered.find({ 'data-automation-id': installAutomationId }).simulate('click'); + androidSetupActionCreatorMock.verify(m => m.next(), Times.once()); + }); });