Skip to content

Commit

Permalink
Add tests | Fixes liferay#481
Browse files Browse the repository at this point in the history
  • Loading branch information
matuzalemsteles authored and Kien Do committed Feb 21, 2018
1 parent 7fbb0e4 commit a2efd67
Showing 1 changed file with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,46 @@ describe('ClayManagementToolbar', function() {
expect(managementToolbar).toMatchSnapshot();
});

it('should render a management toolbar with info button', () => {
managementToolbar = new ClayManagementToolbar({
spritemap: spritemap,
infoButton: true,
});

expect(managementToolbar).toMatchSnapshot();
});

it('should render a management toolbar with info button in active state', () => {
managementToolbar = new ClayManagementToolbar({
actionItems: [
{
label: 'Edit',
href: '#editurl',
icon: 'edit',
quickAction: true,
},
{
label: 'Info Button',
href: '#infobutton',
icon: 'info-circle-open',
quickAction: true,
},
{
label: 'Delete',
href: '#deleteurl',
icon: 'trash',
quickAction: true,
},
],
selectable: true,
selectedItems: 1,
spritemap: spritemap,
totalItems: 10,
});

expect(managementToolbar).toMatchSnapshot();
});

it('should render a selectable management toolbar and emit an event on checkbox click', () => {
managementToolbar = new ClayManagementToolbar({
selectable: true,
Expand Down Expand Up @@ -585,4 +625,18 @@ describe('ClayManagementToolbar', function() {
expect(spy).toHaveBeenCalled();
expect(spy).toHaveBeenCalledWith('actionClicked', expect.any(Object));
});

it('should render a management toolbar with info button and emit an event on infoButton click', () => {
managementToolbar = new ClayManagementToolbar({
spritemap: spritemap,
infoButton: true,
});

const spy = jest.spyOn(managementToolbar, 'emit');

managementToolbar.refs.infoButton.element.click();

expect(spy).toHaveBeenCalled();
expect(spy).toHaveBeenCalledWith('infoButtonClicked', expect.any(Object));
});
});

0 comments on commit a2efd67

Please sign in to comment.