Skip to content

Commit

Permalink
Add tests | Fixes liferay#1172
Browse files Browse the repository at this point in the history
  • Loading branch information
matuzalemsteles committed Sep 6, 2018
1 parent f657e09 commit 0c54435
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/clay-dropdown/src/__tests__/ClayActionsDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,23 @@ describe('ClayActionsDropdown', function() {
expect(clayActionsDropdown).toMatchSnapshot();
});

it('should keep the expanded updated with that of the dropdown base', () => {
jest.useFakeTimers();
clayActionsDropdown = new ClayActionsDropdown({
items: items,
label: 'Trigger',
spritemap: 'icons.svg',
});

expect(clayActionsDropdown.expanded).toBeFalsy();

clayActionsDropdown.refs.dropdown.toggle();
jest.runAllTimers();

expect(clayActionsDropdown.expanded).toBeTruthy();
expect(clayActionsDropdown).toMatchSnapshot();
});

it('should render a dropdown and emit an event on button click', () => {
clayActionsDropdown = new ClayActionsDropdown({
button: {
Expand Down
16 changes: 16 additions & 0 deletions packages/clay-dropdown/src/__tests__/ClayCreationMenuDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,22 @@ describe('ClayCreationMenuDropdown', function() {
expect(clayCreationMenuDropdown).toMatchSnapshot();
});

it('should keep the expanded updated with that of the dropdown base', () => {
jest.useFakeTimers();
clayCreationMenuDropdown = new ClayCreationMenuDropdown({
primaryItems: getItems(2, 'main'),
spritemap: 'icons.svg',
});

expect(clayCreationMenuDropdown.expanded).toBeFalsy();

clayCreationMenuDropdown.refs.dropdown.toggle();
jest.runAllTimers();

expect(clayCreationMenuDropdown.expanded).toBeTruthy();
expect(clayCreationMenuDropdown).toMatchSnapshot();
});

describe('with only primary items', () => {
describe('which are less than', () => {
it('the default primary and total maximums', () => {
Expand Down
17 changes: 17 additions & 0 deletions packages/clay-dropdown/src/__tests__/ClayDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,23 @@ describe('ClayDropdown', function() {
expect(clayDropdown).toMatchSnapshot();
});

it('should keep the expanded updated with that of the dropdown base', () => {
jest.useFakeTimers();
clayDropdown = new ClayDropdown({
items: items,
label: 'Trigger',
spritemap: 'icons.svg',
});

expect(clayDropdown.expanded).toBeFalsy();

clayDropdown.refs.dropdown.toggle();
jest.runAllTimers();

expect(clayDropdown.expanded).toBeTruthy();
expect(clayDropdown).toMatchSnapshot();
});

it('should render a dropdown with an icon trigger', () => {
clayDropdown = new ClayDropdown({
icon: 'list',
Expand Down

0 comments on commit 0c54435

Please sign in to comment.