This repository was archived by the owner on Sep 20, 2024. It is now read-only.
File tree 2 files changed +14
-5
lines changed
2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change 1
1
import { shallowMount } from '@vue/test-utils'
2
2
import Button from './index.vue'
3
+ import Theme from '../../../kiwi.config'
3
4
4
5
describe ( '===== Button Component =====' , ( ) => {
5
6
let button
6
7
describe ( 'Instance Tests' , ( ) => {
7
8
it ( 'should be a Vue instance' , ( ) => {
8
9
button = shallowMount ( Button , {
9
- provide : {
10
- KiwiTheme : { }
10
+ provide ( ) {
11
+ return {
12
+ $theme : ( ) => Theme ,
13
+ $colorMode : 'light'
14
+ }
11
15
}
12
16
} )
13
17
expect ( button . isVueInstance ( ) ) . toBeTruthy ( )
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import Theme from '../../../kiwi.config'
5
5
describe ( '===== ThemeProvider Component =====' , ( ) => {
6
6
let themeProvider
7
7
const ChildComponent = {
8
- inject : [ 'KiwiTheme ' ] ,
8
+ inject : [ '$theme' , '$colorMode '] ,
9
9
render : h => h ( 'div' , { } )
10
10
}
11
11
@@ -18,12 +18,17 @@ describe('===== ThemeProvider Component =====', () => {
18
18
expect ( themeProvider . isVueInstance ( ) ) . toBeTruthy ( )
19
19
} )
20
20
21
- it ( 'should provide theme to child components' , ( ) => {
21
+ it ( 'should provide theme & default color mode to child components' , ( ) => {
22
22
themeProvider = shallowMount ( ThemeProvider , {
23
23
slots : {
24
24
default : [ ChildComponent ]
25
+ } ,
26
+ propsData : {
27
+ theme : Theme ,
28
+ colorMode : 'light'
25
29
}
26
30
} )
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' )
28
33
} )
29
34
} )
You can’t perform that action at this time.
0 commit comments