Skip to content

Commit 815ad60

Browse files
committed
chore: CSidebar - update tests
1 parent 32363a4 commit 815ad60

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

src/components/sidebar/tests/CSidebar.spec.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,16 @@ const App = Vue.extend({
3737
}
3838
},
3939
['link']
40-
)
40+
),
41+
h(
42+
'a', {
43+
attrs: {
44+
href: '/some-path',
45+
class: 'c-sidebar-nav-dropdown'
46+
}
47+
},
48+
['link']
49+
),
4150
])
4251
const View = h('div', { attrs: { class: 'view' }}, ['content'])
4352
return h('div', [
@@ -60,15 +69,19 @@ describe(`${ComponentName} .vue`, () => {
6069
expect(sidebarWrapper.element).toMatchSnapshot()
6170
})
6271
it('close sidebar on CSidebarNavLink click when in mobile width', () => {
63-
//for isOnMobileFunction be be called
64-
sidebarWrapper.find('a').trigger('click')
65-
72+
//cover branch, css vars not included in tests yet
73+
sidebarComponent.isOnMobile()
74+
//for isOnMobileFunction be called
6675
sidebarComponent.isOnMobile = () => sidebarComponent.bodyWidth < 768
76+
const sidebarClick = (className) => {
77+
sidebarWrapper.find(`a.c-sidebar-nav-${className}`).trigger('click')
78+
}
6779
sidebarComponent.bodyWidth = 1300
68-
sidebarWrapper.find('a').trigger('click')
69-
expect(sidebarComponent.open).toBe(true)
80+
sidebarClick('link')
7081
sidebarComponent.bodyWidth = 200
71-
sidebarWrapper.find('a').trigger('click')
82+
sidebarClick('dropdown')
83+
expect(sidebarComponent.open).toBe(true)
84+
sidebarClick('link')
7285
expect(sidebarComponent.open).toBe('responsive')
7386
})
7487
it('watches for prop changes', () => {

src/components/sidebar/tests/__snapshots__/CSidebar.spec.js.snap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ exports[`CSidebar .vue renders correctly 2`] = `
1818
>
1919
link
2020
</a>
21+
<a
22+
class="c-sidebar-nav-dropdown"
23+
href="/some-path"
24+
>
25+
link
26+
</a>
2127
</div>
2228
<div
2329
class="view"

src/components/sidebar/tests/__snapshots__/CSidebarBrand.spec.js.snap

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`CSidebarBrand renders correctly 1`] = `
4-
<a
5-
class="c-sidebar-brand"
6-
href="https://coreui.io"
7-
target="_self"
8-
/>
9-
`;
10-
113
exports[`CSidebarBrand renders correctly as div 1`] = `
124
<div
135
class="c-sidebar-brand"

0 commit comments

Comments
 (0)