Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit d9f2fa0

Browse files
committedOct 18, 2019
fix(test): provide theme in button component
1 parent ae854f4 commit d9f2fa0

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed
 

‎src/components/Button/button.test.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import { shallowMount } from '@vue/test-utils'
22
import Button from './index.vue'
3+
import Theme from '../../../kiwi.config'
34

45
describe('===== Button Component =====', () => {
56
let button
67
describe('Instance Tests', () => {
78
it('should be a Vue instance', () => {
89
button = shallowMount(Button, {
9-
provide: {
10-
KiwiTheme: {}
10+
provide () {
11+
return {
12+
$theme: () => Theme,
13+
$colorMode: 'light'
14+
}
1115
}
1216
})
1317
expect(button.isVueInstance()).toBeTruthy()

‎src/components/ThemeProvider/index.test.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Theme from '../../../kiwi.config'
55
describe('===== ThemeProvider Component =====', () => {
66
let themeProvider
77
const ChildComponent = {
8-
inject: ['KiwiTheme'],
8+
inject: ['$theme', '$colorMode'],
99
render: h => h('div', {})
1010
}
1111

@@ -18,12 +18,17 @@ describe('===== ThemeProvider Component =====', () => {
1818
expect(themeProvider.isVueInstance()).toBeTruthy()
1919
})
2020

21-
it('should provide theme to child components', () => {
21+
it('should provide theme & default color mode to child components', () => {
2222
themeProvider = shallowMount(ThemeProvider, {
2323
slots: {
2424
default: [ChildComponent]
25+
},
26+
propsData: {
27+
theme: Theme,
28+
colorMode: 'light'
2529
}
2630
})
27-
expect(themeProvider.find(ChildComponent).vm.KiwiTheme).toBe(Theme)
31+
expect(themeProvider.find(ChildComponent).vm.$theme()).toBe(Theme)
32+
expect(themeProvider.find(ChildComponent).vm.$colorMode).toBe('light')
2833
})
2934
})

0 commit comments

Comments
 (0)
This repository has been archived.