mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Extract the tests and refactor some of the methods.
Extract some of the ACI Tree functionalities, and decouple it from the main source. Also - create some abstractions from the repeated code around the enable/disable the schema children object create/edit/delete functionalities, and also created the dialog wrappers for backup and restore dialogs. Reviewed by: Khushboo and Ashesh Refactored by: Ashesh
This commit is contained in:
committed by
Ashesh Vashi
parent
920934759f
commit
7dd6372eeb
253
web/regression/javascript/nodes/schema/child_menu_spec.js
Normal file
253
web/regression/javascript/nodes/schema/child_menu_spec.js
Normal file
@@ -0,0 +1,253 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgAdmin 4 - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2013 - 2018, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
import {
|
||||
isTreeItemOfChildOfSchema, childCreateMenuEnabled,
|
||||
} from 'pgadmin.schema.dir/schema_child_tree_node';
|
||||
|
||||
import * as pgBrowser from 'pgbrowser/browser';
|
||||
import {TreeFake} from '../../tree/tree_fake';
|
||||
|
||||
describe('#childCreateMenuEnabled', () => {
|
||||
let data;
|
||||
let tree;
|
||||
|
||||
describe(' - when data is not null', () => {
|
||||
beforeEach(() => {
|
||||
data = {};
|
||||
});
|
||||
describe(' and check is false', () => {
|
||||
beforeEach(() => {
|
||||
data = {check: false};
|
||||
});
|
||||
it(', then it returns true', () => {
|
||||
expect(childCreateMenuEnabled({}, {}, data)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe(' and check', () => {
|
||||
describe(' is true', () => {
|
||||
beforeEach(() => {
|
||||
data = {check: true};
|
||||
});
|
||||
|
||||
describe(', on schema node', () => {
|
||||
beforeEach(() => {
|
||||
let hierarchy = {
|
||||
id: 'root',
|
||||
children: [{
|
||||
id: 'level2',
|
||||
data: {_type: 'schema'},
|
||||
}],
|
||||
};
|
||||
|
||||
tree = TreeFake.build(hierarchy);
|
||||
pgBrowser.treeMenu = tree;
|
||||
});
|
||||
it(' it is true', () => {
|
||||
expect(childCreateMenuEnabled(
|
||||
{}, [{id: 'level2'}], data
|
||||
)).toBe(true);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
describe(', on child collection node under schema node ', () => {
|
||||
beforeEach(() => {
|
||||
let hierarchy = {
|
||||
id: 'root',
|
||||
children: [{
|
||||
id: 'level2',
|
||||
data: {_type: 'schema'},
|
||||
children: [{
|
||||
id: 'coll-table',
|
||||
data: {_type: 'coll-table'},
|
||||
}],
|
||||
}],
|
||||
};
|
||||
|
||||
tree = TreeFake.build(hierarchy);
|
||||
pgBrowser.treeMenu = tree;
|
||||
});
|
||||
|
||||
it(' it is true', () => {
|
||||
expect(childCreateMenuEnabled(
|
||||
{}, [{id: 'coll-table'}], data
|
||||
)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe(', on one of the child node under schema node ', () => {
|
||||
beforeEach(() => {
|
||||
let hierarchy = {
|
||||
id: 'root',
|
||||
children: [{
|
||||
id: 'level2',
|
||||
data: {_type: 'schema'},
|
||||
children: [{
|
||||
id: 'coll-table',
|
||||
data: {_type: 'coll-table'},
|
||||
children: [{
|
||||
id: 'table/1',
|
||||
data: {_type: 'table'},
|
||||
}],
|
||||
}],
|
||||
}],
|
||||
};
|
||||
|
||||
tree = TreeFake.build(hierarchy);
|
||||
pgBrowser.treeMenu = tree;
|
||||
});
|
||||
|
||||
it(' it is true', () => {
|
||||
expect(childCreateMenuEnabled(
|
||||
{}, [{id: 'table/1'}], data
|
||||
)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe(', on catalog node', () => {
|
||||
beforeEach(() => {
|
||||
let hierarchy = {
|
||||
id: 'root',
|
||||
children: [{
|
||||
id: 'level2',
|
||||
data: {_type: 'catalog'},
|
||||
}],
|
||||
};
|
||||
|
||||
tree = TreeFake.build(hierarchy);
|
||||
pgBrowser.treeMenu = tree;
|
||||
});
|
||||
it(' it is false', () => {
|
||||
expect(
|
||||
childCreateMenuEnabled({}, [{id: 'level2'}], data)
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe(', on child collection node under catalog node ', () => {
|
||||
beforeEach(() => {
|
||||
let hierarchy = {
|
||||
id: 'root',
|
||||
children: [{
|
||||
id: 'level2',
|
||||
data: {_type: 'catalog'},
|
||||
children: [{
|
||||
id: 'coll-table',
|
||||
data: {_type: 'coll-table'},
|
||||
}],
|
||||
}],
|
||||
};
|
||||
|
||||
tree = TreeFake.build(hierarchy);
|
||||
pgBrowser.treeMenu = tree;
|
||||
});
|
||||
|
||||
it(' it is false', () => {
|
||||
expect(childCreateMenuEnabled(
|
||||
{}, [{id: 'coll-table'}], data
|
||||
)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe(', on one of the child node under catalog node ', () => {
|
||||
beforeEach(() => {
|
||||
let hierarchy = {
|
||||
id: 'root',
|
||||
children: [{
|
||||
id: 'level2',
|
||||
data: {_type: 'catalog'},
|
||||
children: [{
|
||||
id: 'coll-table',
|
||||
data: {_type: 'coll-table'},
|
||||
children: [{
|
||||
id: 'table/1',
|
||||
data: {_type: 'table'},
|
||||
}],
|
||||
}],
|
||||
}],
|
||||
};
|
||||
|
||||
tree = TreeFake.build(hierarchy);
|
||||
pgBrowser.treeMenu = tree;
|
||||
});
|
||||
|
||||
it(' it is false', () => {
|
||||
expect(childCreateMenuEnabled(
|
||||
{}, [{id: 'table/1'}], data
|
||||
)).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#childDropMenuEnabled', () => {
|
||||
let tree;
|
||||
|
||||
describe(' - the child node under schema node ', () => {
|
||||
beforeEach(() => {
|
||||
let hierarchy = {
|
||||
id: 'root',
|
||||
children: [{
|
||||
id: 'level2',
|
||||
data: {_type: 'schema'},
|
||||
children: [{
|
||||
id: 'coll-table',
|
||||
data: {_type: 'coll-table'},
|
||||
children: [{
|
||||
id: 'table/1',
|
||||
data: {_type: 'table'},
|
||||
}],
|
||||
}],
|
||||
}],
|
||||
};
|
||||
|
||||
tree = TreeFake.build(hierarchy);
|
||||
pgBrowser.treeMenu = tree;
|
||||
});
|
||||
|
||||
it(' it is true', () => {
|
||||
expect(isTreeItemOfChildOfSchema(
|
||||
{}, [{id: 'table/1'}]
|
||||
)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('- the child node under the catalog node ', () => {
|
||||
beforeEach(() => {
|
||||
let hierarchy = {
|
||||
id: 'root',
|
||||
children: [{
|
||||
id: 'level2',
|
||||
data: {_type: 'catalog'},
|
||||
children: [{
|
||||
id: 'coll-table',
|
||||
data: {_type: 'coll-table'},
|
||||
children: [{
|
||||
id: 'table/1',
|
||||
data: {_type: 'table'},
|
||||
}],
|
||||
}],
|
||||
}],
|
||||
};
|
||||
|
||||
tree = TreeFake.build(hierarchy);
|
||||
pgBrowser.treeMenu = tree;
|
||||
});
|
||||
|
||||
it(' it is false', () => {
|
||||
expect(isTreeItemOfChildOfSchema(
|
||||
{}, [{id: 'table/1'}]
|
||||
)).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user