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

55 lines
1.9 KiB
JavaScript
Raw Normal View History

/////////////////////////////////////////////////////////////
//
// pgAdmin 4 - PostgreSQL Tools
//
2023-01-02 00:23:55 -06:00
// Copyright (C) 2013 - 2023, The pgAdmin Development Team
// This software is released under the PostgreSQL License
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import pgAdmin from 'sources/pgadmin';
import RestoreSchema, {getRestoreSaveOptSchema, getRestoreDisableOptionSchema, getRestoreMiscellaneousSchema, getRestoreTypeObjSchema, getRestoreSectionSchema} from '../../../pgadmin/tools/restore/static/js/restore.ui';
import {getCreateView} from '../genericFunctions';
describe('RestoreSchema', ()=>{
let mount;
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
let restoreSchemaObj = new RestoreSchema(
()=>getRestoreSectionSchema({selectedNodeType: 'table'}),
()=>getRestoreTypeObjSchema({selectedNodeType: 'table'}),
()=>getRestoreSaveOptSchema({nodeInfo: {server: {version: 11000}}}),
()=>getRestoreDisableOptionSchema({nodeInfo: {server: {version: 11000}}}),
()=>getRestoreMiscellaneousSchema({nodeInfo: {server: {version: 11000}}}),
{
role: ()=>[],
encoding: ()=>[],
},
{server: {version: 11000}},
pgAdmin.pgBrowser
);
it('restore dialog', ()=>{
mount(getCreateView(restoreSchemaObj));
});
it('restore validate', () => {
let state = { file: undefined }; //validating for empty file
let setError = jasmine.createSpy('setError');
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);
});
});