@@ -9,7 +9,8 @@ describe('js-to-styles-vars-loader', () => {
9
9
context : path . resolve ( ) ,
10
10
_module : {
11
11
resource : 'fakeResource.scss'
12
- }
12
+ } ,
13
+ addDependency ( ) { }
13
14
} ;
14
15
15
16
it ( 'exports a function' , ( ) => {
@@ -83,7 +84,10 @@ describe('js-to-styles-vars-loader', () => {
83
84
} ) ;
84
85
85
86
describe ( 'getVarData' , ( ) => {
86
- const context = { context : path . resolve ( ) } ;
87
+ const context = {
88
+ context : path . resolve ( ) ,
89
+ addDependency ( ) { }
90
+ } ;
87
91
88
92
it ( 'gets variable data by modulePath with context' , ( ) => {
89
93
const varData = operator . getVarData ( [ { path : './mocks/colors.js' } ] , context ) ;
@@ -99,6 +103,13 @@ describe('js-to-styles-vars-loader', () => {
99
103
const varData = operator . getVarData ( [ { path :'./mocks/corners.js' , methodName : 'typeOne' } ] , context ) ;
100
104
expect ( varData ) . toEqual ( { tiny : '1%' , medium : '3%' } ) ;
101
105
} ) ;
106
+
107
+ it ( 'call context.addDependecy with modulePath' , ( ) => {
108
+ spyOn ( context , 'addDependency' ) ;
109
+ const relativePath = './mocks/corners.js' ;
110
+ operator . getVarData ( [ { path : relativePath , methodName : 'typeOne' } ] , context ) ;
111
+ expect ( context . addDependency ) . toHaveBeenCalledWith ( path . resolve ( relativePath ) ) ;
112
+ } ) ;
102
113
} ) ;
103
114
104
115
describe ( 'transformToSassVars' , ( ) => {
@@ -117,7 +128,8 @@ describe('js-to-styles-vars-loader', () => {
117
128
118
129
describe ( 'mergeVarsToContent' , ( ) => {
119
130
const context = {
120
- context : path . resolve ( )
131
+ context : path . resolve ( ) ,
132
+ addDependency ( ) { }
121
133
} ;
122
134
123
135
it ( 'inserts vars to styles content' , ( ) => {
@@ -141,7 +153,8 @@ describe('js-to-styles-vars-loader', () => {
141
153
it ( 'gets module.resource' , ( ) => {
142
154
const context = {
143
155
_module : {
144
- resource : 'fakeResource'
156
+ resource : 'fakeResource' ,
157
+ addDependency ( ) { }
145
158
}
146
159
} ;
147
160
0 commit comments