pgadmin4/web/regression/javascript/schema_ui_files/membership.ui.spec.js
2024-01-01 14:13:48 +05:30

66 lines
1.7 KiB
JavaScript

/////////////////////////////////////////////////////////////
//
// pgAdmin 4 - PostgreSQL Tools
//
// Copyright (C) 2013 - 2024, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
//////////////////////////////////////////////////////////////
import MembershipSchema from '../../../pgadmin/browser/server_groups/servers/static/js/membership.ui';
import * as nodeAjax from '../../../pgadmin/browser/static/js/node_ajax';
import BaseUISchema from '../../../pgadmin/static/js/SchemaView/base_schema.ui';
import {addNewDatagridRow, genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
class SchemaInColl extends BaseUISchema {
constructor(schemaObj) {
super();
this.schemaObj = schemaObj;
}
get baseFields() {
return [{
id: 'collection', label: '', type: 'collection',
schema: this.schemaObj,
editable: false,
canAdd: true, canEdit: false, canDelete: true, hasRole: true,
}];
}
}
describe('MembershipSchema', ()=>{
let schemaObj = new MembershipSchema(
()=>[]);
let getInitData = ()=>Promise.resolve({});
beforeEach(()=>{
genericBeforeEach();
});
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('MembershipMemberSchema', async ()=>{
jest.spyOn(nodeAjax, 'getNodeListByName').mockReturnValue([]);
const {ctrl, user} = await getCreateView(new SchemaInColl(schemaObj));
/* Make sure you hit every corner */
await addNewDatagridRow(user, ctrl);
});
});