Skip to content

Commit

Permalink
Correct toolbar unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
fcollonval committed Aug 1, 2020
1 parent 4ff34ca commit 4a78619
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
12 changes: 6 additions & 6 deletions src/components/Toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,18 +183,18 @@ export class Toolbar extends React.Component<IToolbarProps, IToolbarState> {
onClick={this._onPushClick}
title={'Push committed changes'}
/>
<ActionButton
className={toolbarButtonClass}
icon={refreshIcon}
onClick={this._onRefreshClick}
title={'Refresh the repository to detect local and remote changes'}
/>
<ActionButton
className={toolbarButtonClass}
icon={tagIcon}
onClick={this._onTagClick}
title={'Checkout a tag'}
/>
<ActionButton
className={toolbarButtonClass}
icon={refreshIcon}
onClick={this._onRefreshClick}
title={'Refresh the repository to detect local and remote changes'}
/>
</div>
);
}
Expand Down
25 changes: 17 additions & 8 deletions tests/test-components/Toolbar.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ import * as git from '../../src/git';
import { CommandIDs } from '../../src/commandsAndMenu';
import { GitExtension } from '../../src/model';
import { pullIcon, pushIcon } from '../../src/style/icons';
import {
toolbarButtonClass,
toolbarMenuButtonClass
} from '../../src/style/Toolbar';
import { toolbarMenuButtonClass } from '../../src/style/Toolbar';

jest.mock('@lumino/commands');
jest.mock('../../src/git');
Expand Down Expand Up @@ -213,7 +210,10 @@ describe('Toolbar', () => {
refresh: async () => {}
};
const node = shallow(<Toolbar {...props} />);
const button = node.find(ActionButton).last();
const button = node
.find(ActionButton)
.findWhere(n => n.prop('icon') === refreshIcon)
.first();

expect(button.prop('title')).toEqual(
'Refresh the repository to detect local and remote changes'
Expand Down Expand Up @@ -344,7 +344,10 @@ describe('Toolbar', () => {
refresh: async () => {}
};
const node = shallow(<Toolbar {...props} />);
const button = node.find(`.${toolbarButtonClass}`).first();
const button = node
.find(ActionButton)
.findWhere(n => n.prop('icon') === pullIcon)
.first();

button.simulate('click');
expect(mockedExecute).toHaveBeenCalledTimes(1);
Expand Down Expand Up @@ -380,7 +383,10 @@ describe('Toolbar', () => {
refresh: async () => {}
};
const node = shallow(<Toolbar {...props} />);
const button = node.find(`.${toolbarButtonClass}`).at(1);
const button = node
.find(ActionButton)
.findWhere(n => n.prop('icon') === pushIcon)
.first();

button.simulate('click');
expect(mockedExecute).toHaveBeenCalledTimes(1);
Expand Down Expand Up @@ -408,7 +414,10 @@ describe('Toolbar', () => {
refresh: spy
};
const node = shallow(<Toolbar {...props} />);
const button = node.find(`.${toolbarButtonClass}`).last();
const button = node
.find(ActionButton)
.findWhere(n => n.prop('icon') === refreshIcon)
.first();

button.simulate('click');
expect(spy).toHaveBeenCalledTimes(1);
Expand Down

0 comments on commit 4a78619

Please sign in to comment.