5
5
6
6
/*eslint max-nested-callbacks: 0*/
7
7
/*jscs:disable requireCamelCaseOrUpperCaseIdentifiers*/
8
+ /*eslint newline-after-var: ["error", "always"]*/
9
+ /*eslint-env es6*/
8
10
define ( [
9
11
'jquery' ,
10
12
'Magento_Ui/js/grid/data-storage'
@@ -52,6 +54,7 @@ define([
52
54
53
55
it ( 'initializes _requests property as an empty array' , function ( ) {
54
56
var model = new DataStorage ( ) ;
57
+
55
58
model . _requests = null ;
56
59
model . initConfig ( ) ;
57
60
expect ( model . _requests ) . toEqual ( [ ] ) ;
@@ -110,7 +113,7 @@ define([
110
113
2 : {
111
114
id_field_name : 'entity_id' ,
112
115
entity_id : '42'
113
- } ,
116
+ }
114
117
}
115
118
} ) ;
116
119
@@ -129,8 +132,10 @@ define([
129
132
spyOn ( model , 'clearRequests' ) ;
130
133
spyOn ( model , 'hasScopeChanged' ) . and . returnValue ( true ) ;
131
134
spyOn ( model , 'requestData' ) . and . returnValue ( requestDataResult ) ;
135
+ spyOn ( model , 'getRequest' ) ;
132
136
expect ( model . getData ( ) ) . toEqual ( requestDataResult ) ;
133
137
expect ( model . clearRequests ) . toHaveBeenCalled ( ) ;
138
+ expect ( model . getRequest ) . not . toHaveBeenCalled ( ) ;
134
139
} ) ;
135
140
136
141
it ( 'returns the cached result if scope have not been changed' , function ( ) {
@@ -210,7 +215,7 @@ define([
210
215
id_field_name : 'entity_id' ,
211
216
entity_id : '1' ,
212
217
field : 'value'
213
- } ,
218
+ }
214
219
}
215
220
} ) ;
216
221
@@ -237,7 +242,7 @@ define([
237
242
/**
238
243
* Success result for ajax request
239
244
*
240
- * @param handler
245
+ * @param { Function } handler
241
246
* @returns {* }
242
247
*/
243
248
done : function ( handler ) {
@@ -297,10 +302,11 @@ define([
297
302
model = new DataStorage ( {
298
303
cachedRequestDelay : 0
299
304
} ) ;
305
+
300
306
spyOn ( model , 'getByIds' ) . and . returnValue ( items ) ;
301
307
model . getRequestData ( request ) . then ( function ( promiseResult ) {
302
- expect ( promiseResult ) . toEqual ( result )
303
- } )
308
+ expect ( promiseResult ) . toEqual ( result ) ;
309
+ } ) ;
304
310
} ) ;
305
311
} ) ;
306
312
0 commit comments