File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { useCssModule , createApp } from '../../../src'
2
+ import { mockWarn } from '../../helpers'
3
+ import { proxy } from '../../../src/utils'
4
+
5
+ function injectStyles ( this : any , style : object ) {
6
+ proxy ( this , '$style' , {
7
+ get : function ( ) {
8
+ return style
9
+ } ,
10
+ } )
11
+ }
12
+
13
+ describe ( 'api: useCssModule' , ( ) => {
14
+ mockWarn ( true )
15
+
16
+ function mountWithModule ( modules : object ) {
17
+ let res
18
+ const Comp = {
19
+ beforeCreate ( ) {
20
+ injectStyles . call ( this , modules )
21
+ } ,
22
+ setup ( ) {
23
+ res = useCssModule ( )
24
+ } ,
25
+ }
26
+ const root = document . createElement ( 'div' )
27
+ createApp ( Comp ) . mount ( root )
28
+ return res
29
+ }
30
+
31
+ it ( 'basic usage' , ( ) => {
32
+ const modules = {
33
+ $style : {
34
+ red : 'red' ,
35
+ } ,
36
+ }
37
+ expect ( mountWithModule ( modules . $style ) ) . toMatchObject ( modules . $style )
38
+ } )
39
+
40
+ it ( 'warn out of setup usage' , ( ) => {
41
+ useCssModule ( )
42
+ expect (
43
+ '[Vue warn]: useCssModule must be called inside setup()'
44
+ ) . toHaveBeenWarned ( )
45
+ } )
46
+ } )
You can’t perform that action at this time.
0 commit comments