2018-03-07 11:52:02 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
|
|
|
//
|
2024-01-01 14:13:48 +05:30
|
|
|
// Copyright (C) 2013 - 2024, The pgAdmin Development Team
|
2018-03-07 11:52:02 +00:00
|
|
|
// This software is released under the PostgreSQL Licence
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2018-04-30 17:51:57 +05:30
|
|
|
import {nodeHasStatistics} from '../../../../pgadmin/static/js/misc/statistics/statistics';
|
2018-03-07 11:52:02 +00:00
|
|
|
|
|
|
|
|
describe('#nodeHasStatistics', () => {
|
|
|
|
|
describe('when node hasStatistics is not a function', () => {
|
|
|
|
|
it('return the value of hasStatistics', () => {
|
|
|
|
|
const node = {
|
|
|
|
|
hasStatistics: true,
|
|
|
|
|
};
|
2021-09-27 16:44:26 +05:30
|
|
|
expect(nodeHasStatistics({}, node, {})).toEqual(true);
|
2018-03-07 11:52:02 +00:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('when node hasStatistics is a function', () => {
|
|
|
|
|
describe('when the function returns true', () => {
|
|
|
|
|
it('returns true', () => {
|
|
|
|
|
const node = {
|
|
|
|
|
hasStatistics: () => true,
|
2021-09-27 16:44:26 +05:30
|
|
|
};
|
|
|
|
|
const pgBrowser = {
|
|
|
|
|
tree: {
|
2023-10-23 17:43:17 +05:30
|
|
|
getTreeNodeHierarchy: jest.fn(),
|
2021-09-27 16:44:26 +05:30
|
|
|
}
|
2018-03-07 11:52:02 +00:00
|
|
|
};
|
|
|
|
|
const item = {};
|
|
|
|
|
|
2021-09-27 16:44:26 +05:30
|
|
|
expect(nodeHasStatistics(pgBrowser, node, item)).toEqual(true);
|
|
|
|
|
expect(pgBrowser.tree.getTreeNodeHierarchy).toHaveBeenCalledWith(item);
|
2018-03-07 11:52:02 +00:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|