Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/wincloud_gateway/node_modules/react-virtualized/dist/commonjs/utils/ drwxr-xr-x | |
| Viewing file: Select action/file-type: "use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _createCallbackMemoizer = _interopRequireDefault(require("./createCallbackMemoizer"));
describe('createCallbackMemoizer', function () {
function OnRowsRendered() {
var _numCalls = 0;
var _overscanStartIndex;
var _overscanStopIndex;
var _startIndex;
var _stopIndex;
return {
numCalls: function numCalls() {
return _numCalls;
},
overscanStartIndex: function overscanStartIndex() {
return _overscanStartIndex;
},
overscanStopIndex: function overscanStopIndex() {
return _overscanStopIndex;
},
startIndex: function startIndex() {
return _startIndex;
},
stopIndex: function stopIndex() {
return _stopIndex;
},
update: function update(params) {
_overscanStartIndex = params.overscanStartIndex;
_overscanStopIndex = params.overscanStopIndex;
_startIndex = params.startIndex;
_stopIndex = params.stopIndex;
_numCalls++;
}
};
}
it('should not call onRowsRendered if startIndex or stopIndex are invalid', function () {
var util = new OnRowsRendered();
var helper = (0, _createCallbackMemoizer["default"])();
helper({
callback: util.update,
indices: {
startIndex: 0,
stopIndex: undefined
}
});
expect(util.numCalls()).toEqual(0);
helper({
callback: util.update,
indices: {
startIndex: undefined,
stopIndex: 0
}
});
expect(util.numCalls()).toEqual(0);
});
it('should call onRowsRendered if startIndex and stopIndex are valid', function () {
var util = new OnRowsRendered();
var helper = (0, _createCallbackMemoizer["default"])();
helper({
callback: util.update,
indices: {
startIndex: 0,
stopIndex: 1
}
});
expect(util.numCalls()).toEqual(1);
expect(util.startIndex()).toEqual(0);
expect(util.stopIndex()).toEqual(1);
});
it('should call onRowsRendered if startIndex and stopIndex are invalid but :requireAllKeys is false', function () {
var util = new OnRowsRendered();
var helper = (0, _createCallbackMemoizer["default"])(false);
helper({
callback: util.update,
indices: {
startIndex: undefined,
stopIndex: 1
}
});
expect(util.numCalls()).toEqual(1);
expect(util.startIndex()).toEqual(undefined);
expect(util.stopIndex()).toEqual(1);
});
it('should not call onRowsRendered if startIndex or stopIndex have not changed', function () {
var util = new OnRowsRendered();
var helper = (0, _createCallbackMemoizer["default"])();
helper({
callback: util.update,
indices: {
startIndex: 0,
stopIndex: 1
}
});
expect(util.numCalls()).toEqual(1);
expect(util.startIndex()).toEqual(0);
expect(util.stopIndex()).toEqual(1);
helper({
callback: util.update,
indices: {
startIndex: 0,
stopIndex: 1
}
});
expect(util.numCalls()).toEqual(1);
});
it('should not call onRowsRendered if startIndex or stopIndex have changed', function () {
var util = new OnRowsRendered();
var helper = (0, _createCallbackMemoizer["default"])();
helper({
callback: util.update,
indices: {
startIndex: 0,
stopIndex: 1
}
});
expect(util.numCalls()).toEqual(1);
expect(util.startIndex()).toEqual(0);
expect(util.stopIndex()).toEqual(1);
helper({
callback: util.update,
indices: {
startIndex: 1,
stopIndex: 1
}
});
expect(util.numCalls()).toEqual(2);
expect(util.startIndex()).toEqual(1);
expect(util.stopIndex()).toEqual(1);
helper({
callback: util.update,
indices: {
startIndex: 1,
stopIndex: 2
}
});
expect(util.numCalls()).toEqual(3);
expect(util.startIndex()).toEqual(1);
expect(util.stopIndex()).toEqual(2);
});
it('should call onRowsRendered if :overscanCellsCount changes', function () {
var util = new OnRowsRendered();
var helper = (0, _createCallbackMemoizer["default"])();
helper({
callback: util.update,
indices: {
overscanStartIndex: 0,
overscanStopIndex: 2,
startIndex: 0,
stopIndex: 1
}
});
expect(util.numCalls()).toEqual(1);
expect(util.startIndex()).toEqual(0);
expect(util.stopIndex()).toEqual(1);
expect(util.overscanStartIndex()).toEqual(0);
expect(util.overscanStopIndex()).toEqual(2);
helper({
callback: util.update,
indices: {
overscanStartIndex: 0,
overscanStopIndex: 3,
startIndex: 0,
stopIndex: 1
}
});
expect(util.numCalls()).toEqual(2);
expect(util.startIndex()).toEqual(0);
expect(util.stopIndex()).toEqual(1);
expect(util.overscanStartIndex()).toEqual(0);
expect(util.overscanStopIndex()).toEqual(3);
});
it('should support an array of indices', function () {
var numCalls = 0;
var indices;
var callback = function callback(params) {
indices = params;
numCalls++;
};
var helper = (0, _createCallbackMemoizer["default"])();
helper({
callback: callback,
indices: [0, 1, 2]
});
expect(numCalls).toEqual(1);
expect(indices).toEqual([0, 1, 2]);
helper({
callback: callback,
indices: [0, 1]
});
expect(numCalls).toEqual(2);
expect(indices).toEqual([0, 1]);
});
it('should support an attribute containing an array of indices', function () {
var numCalls = 0;
var indices;
var callback = function callback(params) {
indices = params.indices;
numCalls++;
};
var helper = (0, _createCallbackMemoizer["default"])();
helper({
callback: callback,
indices: {
indices: [0, 1, 2]
}
});
expect(numCalls).toEqual(1);
expect(indices).toEqual([0, 1, 2]);
helper({
callback: callback,
indices: {
indices: [0, 1]
}
});
expect(numCalls).toEqual(2);
expect(indices).toEqual([0, 1]);
});
}); |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0041 ]-- |