pgadmin4/web/regression/javascript/erd/ui_components/FloatingNote.spec.js
Aditya Toshniwal 0f46f070ed Port the remaining components of the ERD Tool to React. Fixes #7343
1. Make use of MUI styles and remove SCSS.
2. Use the new common components for buttons and tooltips, so that they are consistent.
3. UI design should be aligned with the query tool.
4. Remove tippyjs and Alertify dependencies.
2022-09-06 18:09:13 +05:30

46 lines
1.1 KiB
JavaScript

import jasmineEnzyme from 'jasmine-enzyme';
import React from 'react';
import {mount} from 'enzyme';
import '../../helper/enzyme.helper';
import FloatingNote from 'pgadmin.tools.erd/erd_tool/components/FloatingNote';
import Theme from '../../../../pgadmin/static/js/Theme';
describe('ERD FloatingNote', ()=>{
beforeEach(()=>{
jasmineEnzyme();
});
it('<FloatingNote /> on OK click', ()=>{
let floatNote = null;
let onClose = jasmine.createSpy('onClose');
let noteNode = {
getNote: function() {
return 'some note';
},
setNote: jasmine.createSpy('setNote'),
getSchemaTableName: function() {
return ['schema1', 'table1'];
},
};
floatNote = mount(
<Theme>
<FloatingNote
open={true} onClose={onClose} anchorEl={document.body} rows={8} noteNode={noteNode}
/>
</Theme>);
floatNote.find('textarea').simulate('change', {
target: {
value: 'the new note',
},
});
floatNote.find('DefaultButton').simulate('click');
expect(noteNode.setNote).toHaveBeenCalledWith('the new note');
expect(onClose).toHaveBeenCalled();
});
});