2021-07-15 07:19:20 +00:00
|
|
|
/////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
|
|
//
|
2023-01-02 06:23:55 +00:00
|
|
|
// Copyright (C) 2013 - 2023, The pgAdmin Development Team
|
2021-07-15 07:19:20 +00:00
|
|
|
// This software is released under the PostgreSQL Licence
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
|
2023-10-23 12:13:17 +00:00
|
|
|
|
2021-07-15 07:19:20 +00:00
|
|
|
import SynonymSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/synonyms/static/js/synonym.ui';
|
2022-01-28 11:50:34 +00:00
|
|
|
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
|
2021-07-15 07:19:20 +00:00
|
|
|
|
|
|
|
describe('SynonymSchema', ()=>{
|
2023-10-23 12:13:17 +00:00
|
|
|
|
2021-07-15 07:19:20 +00:00
|
|
|
let schemaObj = new SynonymSchema(
|
|
|
|
{
|
|
|
|
role: ()=>[],
|
|
|
|
schema: ()=>[],
|
|
|
|
synobjschema: ()=>[],
|
|
|
|
getTargetObjectOptions: ()=>[],
|
|
|
|
},
|
|
|
|
[],
|
|
|
|
{
|
|
|
|
owner: 'postgres',
|
|
|
|
schema: 'public',
|
|
|
|
synobjschema: 'public',
|
|
|
|
}
|
|
|
|
);
|
|
|
|
let getInitData = ()=>Promise.resolve({});
|
|
|
|
|
|
|
|
|
2023-10-23 12:13:17 +00:00
|
|
|
|
|
|
|
|
2021-07-15 07:19:20 +00:00
|
|
|
|
|
|
|
beforeEach(()=>{
|
2022-01-28 11:50:34 +00:00
|
|
|
genericBeforeEach();
|
2021-07-15 07:19:20 +00:00
|
|
|
});
|
|
|
|
|
2023-10-23 12:13:17 +00:00
|
|
|
it('create', async ()=>{
|
|
|
|
await getCreateView(schemaObj);
|
2021-07-15 07:19:20 +00:00
|
|
|
});
|
|
|
|
|
2023-10-23 12:13:17 +00:00
|
|
|
it('edit', async ()=>{
|
|
|
|
await getEditView(schemaObj, getInitData);
|
2021-07-15 07:19:20 +00:00
|
|
|
});
|
|
|
|
|
2023-10-23 12:13:17 +00:00
|
|
|
it('properties', async ()=>{
|
|
|
|
await getPropertiesView(schemaObj, getInitData);
|
2021-07-15 07:19:20 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('validate', ()=>{
|
|
|
|
let state = {};
|
2023-10-23 12:13:17 +00:00
|
|
|
let setError = jest.fn();
|
2021-07-15 07:19:20 +00:00
|
|
|
|
|
|
|
state.name = null;
|
|
|
|
schemaObj.validate(state, setError);
|
|
|
|
expect(setError).toHaveBeenCalledWith('name', '\'Name\' cannot be empty.');
|
|
|
|
|
|
|
|
state.name = 'my_syn';
|
|
|
|
state.synobjschema = null;
|
|
|
|
schemaObj.validate(state, setError);
|
|
|
|
expect(setError).toHaveBeenCalledWith('synobjschema', '\'Target schema\' cannot be empty.');
|
|
|
|
|
|
|
|
state.synobjschema = 'public';
|
|
|
|
state.synobjname = null;
|
|
|
|
schemaObj.validate(state, setError);
|
|
|
|
expect(setError).toHaveBeenCalledWith('synobjname', '\'Target object\' cannot be empty.');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|