Skip to content

Commit

Permalink
feat(dropdown) tests (#849)
Browse files Browse the repository at this point in the history
* feat(dropdown) tests
  • Loading branch information
mosinve committed Aug 15, 2017
1 parent 2bd562b commit eed57df
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/components/dropdown.spec.js
Expand Up @@ -37,4 +37,39 @@ describe("dropdown", async () => {
expect(openDds.length).toBe(1);
}
});

it('dd-item should render as link by default', async () => {
const {app: {$refs}} = window;
const {dd_6} = $refs;

expect(Array.from(dd_6.$refs.menu.children).find(node => node.innerHTML === 'link')).toBeElement('a');
});

it('dd-item-button should render as button', async () => {
const {app: {$refs}} = window;
const {dd_6} = $refs;

expect(Array.from(dd_6.$refs.menu.children).find(node => node.innerHTML === 'button')).toBeElement('button');
});

it('dd-item-button should emit click event', async () => {
const {app: {$refs}} = window;
const {dd_6} = $refs;

const spy = jest.fn();

dd_6.$parent.$root.$on('clicked::link', spy);

const buttonItem = Array.from(dd_6.$refs.menu.children).find(node => node.innerHTML === 'button');
buttonItem.click();

expect(spy).toHaveBeenCalled();
});

it('dd-divider should render', async () => {
const {app: {$refs}} = window;
const {dd_6} = $refs;

expect(Array.from(dd_6.$refs.menu.children).filter(node => node.classList.contains('dropdown-divider')).length).toBe(1);
});
});
6 changes: 6 additions & 0 deletions tests/fixtures/dropdown/demo.html
Expand Up @@ -61,4 +61,10 @@
<b-dd-item href="#">Something else here</b-dd-item>
</b-dd>

<b-dropdown ref="dd_6" text="Dropdown" variant="primary" class="m-md-2">
<b-dropdown-item>link</b-dropdown-item>
<b-dropdown-header>header</b-dropdown-header>
<b-dropdown-item-button>button</b-dropdown-item-button>
<b-dropdown-divider></b-dropdown-divider>
</b-dropdown>
</div>

0 comments on commit eed57df

Please sign in to comment.