Skip to content

Commit e68a722

Browse files
committed
fix: restore providing minimize state in CSidebar, update tests
1 parent 4eab33b commit e68a722

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

src/components/Sidebar/CSidebar.vue

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,14 @@ export default {
4040
}
4141
},
4242
provide () {
43-
return { dropdownMode: this.dropdownMode }
43+
const state = {}
44+
Object.defineProperty(state, 'minimize', {
45+
get: () => this.minimize
46+
})
47+
return {
48+
state,
49+
dropdownMode: this.dropdownMode
50+
}
4451
},
4552
data () {
4653
return {
@@ -85,13 +92,13 @@ export default {
8592
if (
8693
hiddingElementClicked &&
8794
this.hideOnMobileClick &&
88-
this.isOnMobile(event)
95+
this.isOnMobile()
8996
) {
9097
this.open = false
9198
this.$emit('update:show', false)
9299
}
93100
},
94-
isOnMobile (event) {
101+
isOnMobile () {
95102
return Boolean(getComputedStyle(this.$el).getPropertyValue('--on-mobile'))
96103
}
97104
}

src/components/Sidebar/CSidebarNav.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<VuePerfectScrollbar
44
class="c-scroll-area"
55
:settings="psSettings"
6-
:switcher="!state.minimized"
6+
:switcher="!state.minimize"
77
>
88
<ul class="c-nav">
99
<slot></slot>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const App = Vue.extend({
4545
})
4646

4747
const sidebarWrapper = mount(App, { attachToDocument: true })
48-
const sidebarComponent = sidebarWrapper.vm.$children[0]
48+
// const sidebarComponent = sidebarWrapper.vm.$children[0]
4949

5050
describe(`${ComponentName} .vue`, () => {
5151
it('has a name', () => {

src/components/Sidebar/tests/CSidebarNav.spec.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ const Sidebar = Vue.extend({
1111
components: { CSidebar, CSidebarNav },
1212
data () {
1313
return {
14-
minimized: false
14+
minimize: false
1515
}
1616
},
1717
render (h) {
1818
return h(
1919
'CSidebar',
20-
{ props: { minimize: this.minimized } },
20+
{ props: { minimize: this.minimize } },
2121
[h('CSidebarNav')]
2222
)
2323
}
@@ -37,15 +37,12 @@ describe(`${ComponentName} .vue`, () => {
3737
})
3838
it('properly inherits state from sidebar', () => {
3939
const nav = sidebarWrapper.vm.$children[0].$children[0]
40-
expect(nav.state.open).toBe(true)
41-
expect(nav.state.mobileOpen).toBe(false)
40+
expect(nav.state.minimize).toBe(false)
4241

43-
expect(nav.state.minimized).toBe(false)
42+
sidebarWrapper.setData({minimize: true})
43+
expect(nav.state.minimize).toBe(true)
4444

45-
sidebarWrapper.setData({minimized: true})
46-
expect(nav.state.minimized).toBe(true)
47-
48-
sidebarWrapper.setData({minimized: false})
49-
expect(nav.state.minimized).toBe(false)
45+
sidebarWrapper.setData({minimize: false})
46+
expect(nav.state.minimize).toBe(false)
5047
})
5148
})

0 commit comments

Comments
 (0)