Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 815ad60

Browse filesBrowse files
committed
chore: CSidebar - update tests
1 parent 32363a4 commit 815ad60
Copy full SHA for 815ad60

File tree

Expand file treeCollapse file tree

3 files changed

+26
-15
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+26
-15
lines changed

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

Copy file name to clipboardExpand all lines: src/components/sidebar/tests/CSidebar.spec.js
+20-7Lines 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

Copy file name to clipboardExpand all lines: src/components/sidebar/tests/__snapshots__/CSidebar.spec.js.snap
+6Lines 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

Copy file name to clipboardExpand all lines: src/components/sidebar/tests/__snapshots__/CSidebarBrand.spec.js.snap
-8Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.