Skip to content

Commit 8357cf8

Browse files
Jasmine test added for initConfig, getByIds, getRequestData, cacheRequest
1 parent c9d5e8e commit 8357cf8

File tree

1 file changed

+124
-1
lines changed

1 file changed

+124
-1
lines changed

dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/data-storage.test.js

Lines changed: 124 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ define([
1212
'use strict';
1313

1414
describe('Magento_Ui/js/grid/data-storage', function () {
15-
describe('costructor', function () {
15+
16+
describe('constructor', function () {
1617
it('converts dataScope property to array', function () {
1718
var model = new DataStorage({
1819
dataScope: 'magento'
@@ -22,6 +23,77 @@ define([
2223
});
2324
});
2425

26+
describe('"initConfig" method', function () {
27+
28+
var model = new DataStorage({
29+
dataScope: 'magento'
30+
});
31+
32+
it('Check for defined ', function () {
33+
expect(model.hasOwnProperty('initConfig')).toBeDefined();
34+
});
35+
36+
it('Check method type', function () {
37+
var type = typeof model.initConfig;
38+
39+
expect(type).toEqual('function');
40+
});
41+
42+
it('Check returned value if method called without arguments', function () {
43+
expect(model.initConfig()).toBeDefined();
44+
});
45+
46+
it('Check returned value type if method called without arguments', function () {
47+
var type = typeof model.initConfig();
48+
49+
expect(type).toEqual('object');
50+
});
51+
52+
it('Check this.dataScope property (is modify in initConfig method)', function () {
53+
model.dataScope = null;
54+
model.initConfig();
55+
expect(typeof model.dataScope).toEqual('object');
56+
});
57+
58+
it('Check this._requests property (is modify in initConfig method)', function () {
59+
model._requests = null;
60+
model.initConfig();
61+
expect(typeof model._requests).toEqual('object');
62+
});
63+
});
64+
65+
describe('"getByIds"', function() {
66+
67+
var model = new DataStorage({
68+
dataScope: 'magento'
69+
});
70+
71+
it('check for defined', function() {
72+
expect(model.hasOwnProperty('getByIds')).toBeDefined();
73+
});
74+
75+
it('check method type', function () {
76+
expect(typeof model.getByIds).toEqual('function');
77+
});
78+
79+
it('Check returned value if method called with argument', function () {
80+
var ids = [1,2,3];
81+
expect(model.getByIds(ids)).toBeDefined();
82+
});
83+
84+
it('check returned false if method called with argument', function() {
85+
var ids = [1,2,3];
86+
var type = typeof model.getByIds(ids);
87+
expect(type).toEqual('boolean');
88+
});
89+
90+
it('Return false', function() {
91+
var ids = [1,2,3];
92+
expect(model.getByIds(ids)).toEqual('false');
93+
});
94+
95+
});
96+
2597
describe('hasScopeChanged', function () {
2698
it('is function', function () {
2799
var model = new DataStorage({
@@ -72,5 +144,56 @@ define([
72144
expect(model.hasScopeChanged(newParams)).toBeTruthy();
73145
});
74146
});
147+
describe('"getRequestData" method', function () {
148+
var model = new DataStorage({
149+
dataScope: 'magento'
150+
});
151+
it('Check for defined ', function () {
152+
expect(model.hasOwnProperty('getRequestData')).toBeDefined();
153+
});
154+
155+
it('Check method type', function () {
156+
var type = typeof model.getRequestData;
157+
158+
expect(type).toEqual('function');
159+
});
160+
161+
it('check "getRequestData" has been executed', function () {
162+
var request = {
163+
ids: [1,2,3]
164+
};
165+
expect(model.getRequestData(request)).toBeTruthy();
166+
});
167+
});
168+
169+
describe('"cacheRequest" method', function () {
170+
var model = new DataStorage({
171+
dataScope: 'magento'
172+
});
173+
it('Check for defined ', function () {
174+
expect(model.hasOwnProperty('cacheRequest')).toBeDefined();
175+
});
176+
177+
it('Check method type', function () {
178+
var type = typeof model.cacheRequest;
179+
180+
expect(type).toEqual('function');
181+
});
182+
183+
it('check "cacheRequest" has been executed', function () {
184+
var data = {
185+
items: [1,2,3],
186+
totalRecords: 3,
187+
errorMessage: ''
188+
},
189+
params = {
190+
namespace: 'magento',
191+
search: '',
192+
sorting: {},
193+
paging: {}
194+
};
195+
expect(model.cacheRequest(data, params)).toBeTruthy();
196+
});
197+
});
75198
});
76199
});

0 commit comments

Comments
 (0)