Skip to content

Commit

Permalink
feat: add setting icon to commands UI (#1052)
Browse files Browse the repository at this point in the history
* feat: add setting icon to commands UI

* fix: test failed
  • Loading branch information
BlackHole1 authored Apr 26, 2022
1 parent 2c21076 commit 193e6dc
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/renderer/components/commands.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ export class Commands extends React.Component<CommandsProps> {
onDoubleClick={this.handleDoubleClick}
>
<div>
<ControlGroup fill={true} vertical={false}>
<Button
icon="cog"
title="Setting"
onClick={appState.toggleSettings}
/>
</ControlGroup>
<ControlGroup fill={true} vertical={false}>
<VersionChooser appState={appState} />
<Runner appState={appState} />
Expand Down
1 change: 1 addition & 0 deletions tests/mocks/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export class StateMock {
public signOutGitHub = jest.fn();
public toggleAddVersionDialog = jest.fn();
public toggleAuthDialog = jest.fn();
public toggleSettings = jest.fn();
public updateElectronVersions = jest.fn();

constructor() {
Expand Down
20 changes: 20 additions & 0 deletions tests/renderer/components/__snapshots__/commands-spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ exports[`Commands component renders when system is darwin 1`] = `
onDoubleClick={[Function]}
>
<div>
<Blueprint3.ControlGroup
fill={true}
vertical={false}
>
<Blueprint3.Button
icon="cog"
onClick={[MockFunction]}
title="Setting"
/>
</Blueprint3.ControlGroup>
<Blueprint3.ControlGroup
fill={true}
vertical={false}
Expand Down Expand Up @@ -50,6 +60,16 @@ exports[`Commands component renders when system not is darwin 1`] = `
onDoubleClick={[Function]}
>
<div>
<Blueprint3.ControlGroup
fill={true}
vertical={false}
>
<Blueprint3.Button
icon="cog"
onClick={[MockFunction]}
title="Setting"
/>
</Blueprint3.ControlGroup>
<Blueprint3.ControlGroup
fill={true}
vertical={false}
Expand Down
9 changes: 9 additions & 0 deletions tests/renderer/components/commands-spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { IpcEvents } from '../../../src/ipc-events';

import { StateMock } from '../../mocks/mocks';
import { overridePlatform, resetPlatform } from '../../utils';
import { Button, ControlGroup } from '@blueprintjs/core';

jest.mock('../../../src/renderer/components/commands-runner', () => ({
Runner: 'runner',
Expand Down Expand Up @@ -67,4 +68,12 @@ describe('Commands component', () => {
expect(spy).toHaveBeenCalledWith(IpcEvents.CLICK_TITLEBAR_MAC);
spy.mockRestore();
});

it('show setting', () => {
const wrapper = shallow(<Commands appState={store as any} />);

wrapper.find(ControlGroup).at(0).find(Button).simulate('click');

expect(store.toggleSettings).toHaveBeenCalled();
});
});

0 comments on commit 193e6dc

Please sign in to comment.