-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7164878
commit a26f606
Showing
5 changed files
with
324 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { mount } from '@vue/test-utils'; | ||
import Dropdown from '../Dropdown.vue'; | ||
import Submenu from '../Submenu.vue'; | ||
|
||
const DEFAULT_STUBS = { | ||
'dropdown': Dropdown, | ||
'submenu': Submenu, | ||
}; | ||
|
||
const DROPDOWN = ` | ||
<li><a href="#" class="dropdown-item">Dropdown Item 1</a></li> | ||
<li><a href="#" class="dropdown-item">Dropdown Item 2</a></li> | ||
<li><a href="#" class="dropdown-item">Dropdown Item 3</a></li> | ||
`; | ||
|
||
const FIRST_LEVEL_NESTED_DROPDOWN = ` | ||
${DROPDOWN} | ||
<dropdown haeder="Submenu Level 1"> | ||
<li><a href="#" class="dropdown-item">Nested Dropdown Item 1</a></li> | ||
<li><a href="#" class="dropdown-item">Nested Dropdown Item 2</a></li> | ||
</dropdown> | ||
`; | ||
|
||
const SECOND_LEVEL_NESTED_DROPDOWN = ` | ||
<dropdown haeder="Submenu Level 1"> | ||
<li><a href="#" class="dropdown-item">Nested Dropdown Item 1</a></li> | ||
<li><a href="#" class="dropdown-item">Nested Dropdown Item 2</a></li> | ||
<dropdown haeder="Submenu Level 2"> | ||
<li><a href="#" class="dropdown-item">Nested Submenu Item</a></li> | ||
</dropdown> | ||
</dropdown> | ||
`; | ||
|
||
describe('Dropdown with submenu', () => { | ||
test('dropdown', async () => { | ||
const wrapper = mount(Dropdown, { | ||
slots: { | ||
header: 'Test Dropdown', | ||
default: DROPDOWN, | ||
}, | ||
stubs: DEFAULT_STUBS, | ||
}); | ||
|
||
expect(wrapper.element).toMatchSnapshot(); | ||
}); | ||
|
||
test('dropdown with one level of submenu', async () => { | ||
const wrapper = mount(Dropdown, { | ||
slots: { | ||
header: 'Test Dropdown', | ||
default: FIRST_LEVEL_NESTED_DROPDOWN, | ||
}, | ||
stubs: DEFAULT_STUBS, | ||
}); | ||
|
||
expect(wrapper.element).toMatchSnapshot(); | ||
}); | ||
|
||
test('dropdown with two levels of submenu', async () => { | ||
const wrapper = mount(Dropdown, { | ||
slots: { | ||
header: 'Test Dropdown', | ||
default: SECOND_LEVEL_NESTED_DROPDOWN, | ||
}, | ||
stubs: DEFAULT_STUBS, | ||
}); | ||
|
||
expect(wrapper.element).toMatchSnapshot(); | ||
}); | ||
}); |
199 changes: 199 additions & 0 deletions
199
packages/vue-components/src/__tests__/__snapshots__/Dropdown.spec.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Dropdown with submenu dropdown 1`] = ` | ||
<div | ||
class="btn-group" | ||
> | ||
<button | ||
class="btn dropdown-toggle btn-light" | ||
type="button" | ||
> | ||
Test Dropdown | ||
</button> | ||
<ul | ||
class="dropdown-menu" | ||
> | ||
<li> | ||
<a | ||
class="dropdown-item" | ||
href="#" | ||
> | ||
Dropdown Item 1 | ||
</a> | ||
</li> | ||
<li> | ||
<a | ||
class="dropdown-item" | ||
href="#" | ||
> | ||
Dropdown Item 2 | ||
</a> | ||
</li> | ||
<li> | ||
<a | ||
class="dropdown-item" | ||
href="#" | ||
> | ||
Dropdown Item 3 | ||
</a> | ||
</li> | ||
</ul> | ||
</div> | ||
`; | ||
|
||
exports[`Dropdown with submenu dropdown with one level of submenu 1`] = ` | ||
<div | ||
class="btn-group" | ||
> | ||
<button | ||
class="btn dropdown-toggle btn-light" | ||
type="button" | ||
> | ||
Test Dropdown | ||
</button> | ||
<ul | ||
class="dropdown-menu" | ||
> | ||
<li> | ||
<a | ||
class="dropdown-item" | ||
href="#" | ||
> | ||
Dropdown Item 1 | ||
</a> | ||
</li> | ||
<li> | ||
<a | ||
class="dropdown-item" | ||
href="#" | ||
> | ||
Dropdown Item 2 | ||
</a> | ||
</li> | ||
<li> | ||
<a | ||
class="dropdown-item" | ||
href="#" | ||
> | ||
Dropdown Item 3 | ||
</a> | ||
</li> | ||
<li | ||
class="dropdown-submenu dropright" | ||
haeder="Submenu Level 1" | ||
> | ||
<a | ||
class="submenu-toggle" | ||
role="button" | ||
/> | ||
<ul | ||
class="dropdown-menu" | ||
> | ||
<li> | ||
<a | ||
class="dropdown-item" | ||
href="#" | ||
> | ||
Nested Dropdown Item 1 | ||
</a> | ||
</li> | ||
<li> | ||
<a | ||
class="dropdown-item" | ||
href="#" | ||
> | ||
Nested Dropdown Item 2 | ||
</a> | ||
</li> | ||
</ul> | ||
</li> | ||
</ul> | ||
</div> | ||
`; | ||
|
||
exports[`Dropdown with submenu dropdown with two levels of submenu 1`] = ` | ||
<div | ||
class="btn-group" | ||
> | ||
<button | ||
class="btn dropdown-toggle btn-light" | ||
type="button" | ||
> | ||
Test Dropdown | ||
</button> | ||
<ul | ||
class="dropdown-menu" | ||
> | ||
<li | ||
class="dropdown-submenu dropright" | ||
haeder="Submenu Level 1" | ||
> | ||
<a | ||
class="submenu-toggle" | ||
role="button" | ||
/> | ||
<ul | ||
class="dropdown-menu" | ||
> | ||
<li> | ||
<a | ||
class="dropdown-item" | ||
href="#" | ||
> | ||
Nested Dropdown Item 1 | ||
</a> | ||
</li> | ||
<li> | ||
<a | ||
class="dropdown-item" | ||
href="#" | ||
> | ||
Nested Dropdown Item 2 | ||
</a> | ||
</li> | ||
<li | ||
class="dropdown-submenu dropright" | ||
haeder="Submenu Level 2" | ||
> | ||
<a | ||
class="submenu-toggle" | ||
role="button" | ||
/> | ||
<ul | ||
class="dropdown-menu" | ||
> | ||
<li> | ||
<a | ||
class="dropdown-item" | ||
href="#" | ||
> | ||
Nested Submenu Item | ||
</a> | ||
</li> | ||
</ul> | ||
</li> | ||
</ul> | ||
</li> | ||
</ul> | ||
</div> | ||
`; |
Oops, something went wrong.