Files
pgadmin4/web/regression/javascript/schema_ui_files/restore.ui.spec.js
T

49 lines
1.7 KiB
JavaScript
Raw Normal View History

2021-12-28 13:45:59 +05:30
/////////////////////////////////////////////////////////////
//
// pgAdmin 4 - PostgreSQL Tools
//
2026-01-05 13:33:45 +05:30
// Copyright (C) 2013 - 2026, The pgAdmin Development Team
2021-12-28 13:45:59 +05:30
// This software is released under the PostgreSQL License
//
//////////////////////////////////////////////////////////////
2021-12-28 13:45:59 +05:30
import pgAdmin from 'sources/pgadmin';
import RestoreSchema, {getRestoreSaveOptSchema, getRestoreDisableOptionSchema, getRestoreMiscellaneousSchema, getRestoreTypeObjSchema, getRestoreSectionSchema} from '../../../pgadmin/tools/restore/static/js/restore.ui';
import {getCreateView} from '../genericFunctions';
2021-12-28 13:45:59 +05:30
describe('RestoreSchema', ()=>{
const createSchemaObj = () => new RestoreSchema(
2021-12-28 13:45:59 +05:30
()=>getRestoreSectionSchema({selectedNodeType: 'table'}),
()=>getRestoreTypeObjSchema({selectedNodeType: 'table'}),
()=>getRestoreSaveOptSchema({nodeInfo: {server: {version: 11000}}}),
()=>getRestoreDisableOptionSchema({nodeInfo: {server: {version: 11000}}}),
()=>getRestoreMiscellaneousSchema({nodeInfo: {server: {version: 11000}}}),
{
role: ()=>[],
encoding: ()=>[],
nodeType: '',
2021-12-28 13:45:59 +05:30
},
{server: {version: 11000}},
pgAdmin.pgBrowser
);
it('restore dialog', async ()=>{
await getCreateView(createSchemaObj());
2021-12-28 13:45:59 +05:30
});
it('restore validate', () => {
let restoreSchemaObj = createSchemaObj();
2021-12-28 13:45:59 +05:30
let state = { file: undefined }; //validating for empty file
let setError = jest.fn();
2021-12-28 13:45:59 +05:30
restoreSchemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('file', 'Please provide a filename.');
state.file = '/home/dir/restore.sql'; //validating for valid file name
restoreSchemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('file', null);
});
});