Skip to content
Snippets Groups Projects
Commit 30acd70b authored by Maxim Medinskiy's avatar Maxim Medinskiy
Browse files

MAGETWO-59322: Incorrect scope filter caching in UI grids

parent ffc976c5
No related merge requests found
/** /**
* Copyright © 2016 Magento. All rights reserved. * Copyright © 2017 Magento. All rights reserved.
* See COPYING.txt for license details. * See COPYING.txt for license details.
*/ */
/*eslint max-nested-callbacks: 0*/ /*eslint max-nested-callbacks: 0*/
/*jscs:disable requirePaddingNewLinesInObjects*/
/*jscs:disable jsDoc*/
define([ define([
'Magento_Ui/js/grid/data-storage', 'Magento_Ui/js/grid/data-storage',
], function (DataStorage) { ], function (DataStorage) {
...@@ -17,6 +14,7 @@ define([ ...@@ -17,6 +14,7 @@ define([
dataScope: '', dataScope: '',
}), }),
type; type;
describe('"initConfig" method', function () { describe('"initConfig" method', function () {
it('Check for defined ', function () { it('Check for defined ', function () {
expect(obj.hasOwnProperty('initConfig')).toBeDefined(); expect(obj.hasOwnProperty('initConfig')).toBeDefined();
...@@ -26,9 +24,10 @@ define([ ...@@ -26,9 +24,10 @@ define([
expect(type).toEqual('function'); expect(type).toEqual('function');
}); });
it('Check method change "$this.dataScope" property', function () { it('Check method change "$this.dataScope" property', function () {
var obj = new DataStorage({dataScope: 'magento'}); var model = new DataStorage({dataScope: 'magento'});
obj.initConfig;
expect(obj.dataScope).toEqual(['magento']); model.initConfig;
expect(model.dataScope).toEqual(['magento']);
}); });
}); });
describe('"hasScopeChanged" method', function () { describe('"hasScopeChanged" method', function () {
...@@ -41,11 +40,13 @@ define([ ...@@ -41,11 +40,13 @@ define([
}); });
it('Check method with empty cached requests', function () { it('Check method with empty cached requests', function () {
var expectedResult; var expectedResult;
expectedResult = obj.hasScopeChanged(); expectedResult = obj.hasScopeChanged();
expect(expectedResult).toBeFalsy(); expect(expectedResult).toBeFalsy();
}); });
it('Check method with not empty cached requests', function () { it('Check method with not empty cached requests', function () {
var expectedResult, params, requestParams; var expectedResult, params, requestParams, model;
params = { params = {
namespace: "magento", namespace: "magento",
search: "", search: "",
...@@ -64,12 +65,12 @@ define([ ...@@ -64,12 +65,12 @@ define([
sorting: {}, sorting: {},
paging: {} paging: {}
}; };
var obj = new DataStorage( model = new DataStorage(
{ {
dataScope: ['filters.store_id'] //became after initConfig method call dataScope: ['filters.store_id'] //became after initConfig method call
} }
); );
spyOn(obj, "getRequest").and.returnValue({ spyOn(model, "getRequest").and.returnValue({
ids: [], ids: [],
params: { params: {
namespace: "magento", namespace: "magento",
...@@ -82,13 +83,13 @@ define([ ...@@ -82,13 +83,13 @@ define([
}, },
totalRecords: 0 totalRecords: 0
}); });
spyOn(obj, "removeRequest").and.callFake(function () { spyOn(model, "removeRequest").and.callFake(function () {
return false; return false;
}); });
obj.cacheRequest({totalRecords: 0}, params); model.cacheRequest({totalRecords: 0}, params);
expect(obj.getRequest).toHaveBeenCalled(); expect(model.getRequest).toHaveBeenCalled();
expect(obj.removeRequest).toHaveBeenCalled(); expect(model.removeRequest).toHaveBeenCalled();
expectedResult = obj.hasScopeChanged(requestParams); expectedResult = model.hasScopeChanged(requestParams);
expect(expectedResult).toBeTruthy(); expect(expectedResult).toBeTruthy();
}); });
}); });
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment