2022-09-07 08:50:03 -05:00
|
|
|
/////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
|
|
//
|
2024-01-01 02:43:48 -06:00
|
|
|
// Copyright (C) 2013 - 2024, The pgAdmin Development Team
|
2022-09-07 08:50:03 -05:00
|
|
|
// This software is released under the PostgreSQL Licence
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import React from 'react';
|
2023-10-23 07:13:17 -05:00
|
|
|
import { act, render } from '@testing-library/react';
|
|
|
|
|
2022-09-07 08:50:03 -05:00
|
|
|
import MockAdapter from 'axios-mock-adapter';
|
2023-08-01 02:34:06 -05:00
|
|
|
import axios from 'axios';
|
2022-09-07 08:50:03 -05:00
|
|
|
|
2023-10-23 07:13:17 -05:00
|
|
|
import pgAdmin from 'sources/pgadmin';
|
2022-09-07 08:50:03 -05:00
|
|
|
import pgWindow from 'sources/window';
|
|
|
|
import url_for from 'sources/url_for';
|
|
|
|
|
2023-10-23 07:13:17 -05:00
|
|
|
|
2022-09-07 08:50:03 -05:00
|
|
|
import Theme from '../../../pgadmin/static/js/Theme';
|
|
|
|
import SchemaDiffComponent from '../../../pgadmin/tools/schema_diff/static/js/components/SchemaDiffComponent';
|
|
|
|
import SchemaDiff from '../../../pgadmin/tools/schema_diff/static/js/SchemaDiffModule';
|
|
|
|
|
|
|
|
|
|
|
|
describe('Schema Diff Component', () => {
|
2023-10-23 07:13:17 -05:00
|
|
|
|
2022-09-07 08:50:03 -05:00
|
|
|
let params;
|
|
|
|
let networkMock;
|
|
|
|
let schemaDiffInstance;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
2023-10-23 07:13:17 -05:00
|
|
|
pgWindow.pgAdmin = pgAdmin;
|
2022-09-07 08:50:03 -05:00
|
|
|
schemaDiffInstance = new SchemaDiff(pgWindow.pgAdmin, pgWindow.pgAdmin.Browser);
|
|
|
|
|
|
|
|
params = {
|
|
|
|
transId: 1234,
|
|
|
|
schemaDiff: schemaDiffInstance,
|
|
|
|
};
|
|
|
|
networkMock = new MockAdapter(axios);
|
|
|
|
});
|
|
|
|
|
2023-10-23 07:13:17 -05:00
|
|
|
it('SchemaDiff Init', async () => {
|
2022-09-07 08:50:03 -05:00
|
|
|
networkMock.onGet(url_for('schema_diff.servers')).reply(200,
|
|
|
|
{'success':1,
|
|
|
|
'errormsg':'',
|
|
|
|
'info':'',
|
|
|
|
'result':null,
|
|
|
|
'data':{
|
|
|
|
'Servers':[
|
|
|
|
{'value':1,'label':'PostgreSQL 12','image':'icon-pg','_id':1,'connected':true},
|
|
|
|
{'value':2,'label':'PostgreSQL 10','image':'icon-server-not-connected','_id':2,'connected':false},
|
|
|
|
{'value':3,'label':'PostgreSQL 11','image':'icon-server-not-connected','_id':3,'connected':false},
|
|
|
|
{'value':4,'label':'PostgreSQL 13','image':'icon-server-not-connected','_id':4,'connected':false},
|
|
|
|
{'value':5,'label':'PostgreSQL 9.6','image':'icon-server-not-connected','_id':5,'connected':false},
|
|
|
|
{'value':8,'label':'test1234yo','image':'icon-server-not-connected','_id':8,'connected':false}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
2023-10-23 07:13:17 -05:00
|
|
|
await act(async ()=>{
|
|
|
|
render(
|
|
|
|
<Theme>
|
|
|
|
<SchemaDiffComponent
|
|
|
|
params={{ transId: params.transId, pgAdmin: pgWindow.pgAdmin }}
|
|
|
|
>
|
|
|
|
</SchemaDiffComponent>
|
|
|
|
</Theme>
|
|
|
|
);
|
|
|
|
});
|
2022-09-07 08:50:03 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|