mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Replaced alertifyjs notifiers with React-based notistack. Fixes #7004
This commit is contained in:
@@ -1,116 +0,0 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgAdmin 4 - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2013 - 2021, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
import alertify from 'pgadmin.alertifyjs';
|
||||
import * as $ from 'jquery';
|
||||
import gettext from 'sources/gettext';
|
||||
|
||||
|
||||
describe('alertify_wrapper', function () {
|
||||
var env = jasmine.getEnv();
|
||||
|
||||
env.allowRespy(true);
|
||||
|
||||
describe('alertify_success', function () {
|
||||
it('calls the success function from alertify and adds the checkmark to the element', function () {
|
||||
let spyObj = spyOn(alertify, 'orig_success').and.callThrough();
|
||||
|
||||
alertify.success('Yay, congrats!', 1);
|
||||
|
||||
expect(spyObj).toHaveBeenCalled();
|
||||
expect(spyObj.calls.mostRecent().args[0]).toContain('Yay, congrats!');
|
||||
expect(spyObj.calls.mostRecent().args[0]).toContain('class="fa fa-check"');
|
||||
});
|
||||
});
|
||||
|
||||
describe('alertify_error calls the error function', function() {
|
||||
it('and adds the warning symbol to the element', function () {
|
||||
let spyOrigError = spyOn(alertify, 'orig_error').and.callThrough();
|
||||
alertify.error('bad, very bad', 1);
|
||||
|
||||
expect(spyOrigError).toHaveBeenCalled();
|
||||
expect(spyOrigError.calls.mostRecent().args[0]).toContain('bad, very bad');
|
||||
expect(spyOrigError.calls.mostRecent().args[0]).toContain('class="fa fa-exclamation-triangle"');
|
||||
});
|
||||
});
|
||||
|
||||
describe('alertify_error calls pgRespErrorNotify notifier', function() {
|
||||
it('which alertifies response error for ajax calls', (done) => {
|
||||
$.ajax({
|
||||
url: 'http://some/dummy/url',
|
||||
dataType: 'json',
|
||||
error: function(xhr, status, error) {
|
||||
let spyOrigError = spyOn(alertify, 'orig_error').and.callThrough(),
|
||||
spyNotify = spyOn(alertify, 'notify').and.callThrough();
|
||||
|
||||
/*When connection lost*/
|
||||
xhr.status = 0;
|
||||
alertify.pgRespErrorNotify(xhr, error);
|
||||
expect(spyOrigError).toHaveBeenCalled();
|
||||
expect(spyOrigError.calls.mostRecent().args[0]).toContain(
|
||||
gettext('Connection to the server has been lost.')
|
||||
);
|
||||
|
||||
/*When some exception occurs at back end*/
|
||||
xhr.status = 4;
|
||||
var orig_getResponseHeader = xhr.getResponseHeader;
|
||||
|
||||
/*Exception handled by back end*/
|
||||
xhr.getResponseHeader = (header) => {
|
||||
if(header === 'Content-Type') {
|
||||
return 'application/json';
|
||||
}
|
||||
else {
|
||||
return orig_getResponseHeader(header);
|
||||
}
|
||||
};
|
||||
xhr.responseText = '{"errormsg":"Exception XYZ"}';
|
||||
alertify.pgRespErrorNotify(xhr, error);
|
||||
expect(spyOrigError).toHaveBeenCalled();
|
||||
expect(spyOrigError.calls.mostRecent().args[0]).toContain(
|
||||
gettext('Exception XYZ')
|
||||
);
|
||||
|
||||
/*Exception not handled by back end*/
|
||||
xhr.getResponseHeader = (header) => {
|
||||
if(header === 'Content-Type') {
|
||||
return 'text/html';
|
||||
}
|
||||
else {
|
||||
return orig_getResponseHeader(header);
|
||||
}
|
||||
};
|
||||
xhr.responseText = '<p>Some Exception Occurred</p>';
|
||||
alertify.pgRespErrorNotify(xhr, error);
|
||||
expect(spyNotify).toHaveBeenCalled();
|
||||
expect(spyNotify.calls.mostRecent().args[0]).toContain(
|
||||
gettext('INTERNAL SERVER ERROR')
|
||||
);
|
||||
|
||||
/*With prefixMsg*/
|
||||
xhr.getResponseHeader = (header) => {
|
||||
if(header === 'Content-Type') {
|
||||
return 'application/json';
|
||||
}
|
||||
else {
|
||||
return orig_getResponseHeader(header);
|
||||
}
|
||||
};
|
||||
xhr.responseText = '{"errormsg":"Exception XYZ"}';
|
||||
alertify.pgRespErrorNotify(xhr, error, gettext('Some prefix message'));
|
||||
expect(spyOrigError).toHaveBeenCalled();
|
||||
expect(spyOrigError.calls.mostRecent().args[0]).toContain(
|
||||
gettext('Some prefix message')
|
||||
);
|
||||
|
||||
done();
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -17,10 +17,10 @@ import { OutlinedInput, FormHelperText, IconButton, FormControlLabel,
|
||||
import Select from 'react-select';
|
||||
import CreatableSelect from 'react-select/creatable';
|
||||
import CheckRoundedIcon from '@material-ui/icons/CheckRounded';
|
||||
import ReportProblemIcon from '@material-ui/icons/ReportProblemRounded';
|
||||
import InfoIcon from '@material-ui/icons/InfoRounded';
|
||||
import InfoRoundedIcon from '@material-ui/icons/InfoRounded';
|
||||
import CloseIcon from '@material-ui/icons/CloseRounded';
|
||||
import CheckIcon from '@material-ui/icons/CheckCircleOutlineRounded';
|
||||
import ErrorRoundedIcon from '@material-ui/icons/ErrorOutlineRounded';
|
||||
import WarningRoundedIcon from '@material-ui/icons/WarningRounded';
|
||||
|
||||
|
||||
import {FormInputText, FormInputFileSelect, FormInputSQL,
|
||||
@@ -560,7 +560,7 @@ describe('FormComponents', ()=>{
|
||||
});
|
||||
|
||||
it('init', ()=>{
|
||||
expect(ctrl.find(CheckIcon).exists()).toBeTrue();
|
||||
expect(ctrl.find(CheckRoundedIcon).exists()).toBeTrue();
|
||||
expect(ctrl.text()).toBe('Some message');
|
||||
});
|
||||
|
||||
@@ -568,12 +568,17 @@ describe('FormComponents', ()=>{
|
||||
ctrl.setProps({
|
||||
type: MESSAGE_TYPE.ERROR,
|
||||
});
|
||||
expect(ctrl.find(ReportProblemIcon).exists()).toBeTrue();
|
||||
expect(ctrl.find(ErrorRoundedIcon).exists()).toBeTrue();
|
||||
|
||||
ctrl.setProps({
|
||||
type: MESSAGE_TYPE.INFO,
|
||||
});
|
||||
expect(ctrl.find(InfoIcon).exists()).toBeTrue();
|
||||
expect(ctrl.find(InfoRoundedIcon).exists()).toBeTrue();
|
||||
|
||||
ctrl.setProps({
|
||||
type: MESSAGE_TYPE.WARNING,
|
||||
});
|
||||
expect(ctrl.find(WarningRoundedIcon).exists()).toBeTrue();
|
||||
});
|
||||
|
||||
it('closable', ()=>{
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
beforeAll(function () {
|
||||
spyOn(console, 'warn').and.callThrough();
|
||||
spyOn(console, 'error').and.callThrough();
|
||||
jasmine.getEnv().allowRespy(true);
|
||||
});
|
||||
|
||||
afterEach(function (done) {
|
||||
|
||||
@@ -11,7 +11,7 @@ import {callRenderAfterPoll} from '../../../pgadmin/static/js/sqleditor/call_ren
|
||||
import moment from 'moment';
|
||||
|
||||
describe('#callRenderAfterPoll', () => {
|
||||
let sqlEditorSpy, queryResult, alertify;
|
||||
let sqlEditorSpy, queryResult, Notify;
|
||||
beforeEach(() => {
|
||||
let today = moment('2018-01-01 10:12:31').toDate();
|
||||
jasmine.clock().install();
|
||||
@@ -28,7 +28,7 @@ describe('#callRenderAfterPoll', () => {
|
||||
check_db_name_change: jasmine.createSpy('SQLEditor.check_db_name_change'),
|
||||
query_start_time: new Date(),
|
||||
};
|
||||
alertify = jasmine.createSpyObj('alertify', ['success']);
|
||||
Notify = jasmine.createSpyObj('Notify', ['success']);
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
@@ -50,19 +50,19 @@ describe('#callRenderAfterPoll', () => {
|
||||
});
|
||||
|
||||
it('renders the editor', () => {
|
||||
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
|
||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
||||
|
||||
expect(sqlEditorSpy._render).toHaveBeenCalledWith(queryResult);
|
||||
});
|
||||
|
||||
it('inform sqleditor that the query stopped running', () => {
|
||||
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
|
||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
||||
|
||||
expect(sqlEditorSpy.setIsQueryRunning).toHaveBeenCalledWith(false);
|
||||
});
|
||||
|
||||
it('hides the loading icon', () => {
|
||||
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
|
||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
||||
|
||||
expect(sqlEditorSpy.trigger).toHaveBeenCalledWith('pgadmin-sqleditor:loading-icon:hide');
|
||||
});
|
||||
@@ -79,7 +79,7 @@ describe('#callRenderAfterPoll', () => {
|
||||
});
|
||||
|
||||
it('saves execution information in the history', () => {
|
||||
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
|
||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
||||
|
||||
expect(sqlEditorSpy.update_msg_history).toHaveBeenCalledWith(
|
||||
true,
|
||||
@@ -89,19 +89,19 @@ describe('#callRenderAfterPoll', () => {
|
||||
});
|
||||
|
||||
it('resets the changed data store', () => {
|
||||
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
|
||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
||||
|
||||
expect(sqlEditorSpy.reset_data_store).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('inform sqleditor that the query stopped running', () => {
|
||||
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
|
||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
||||
|
||||
expect(sqlEditorSpy.setIsQueryRunning).toHaveBeenCalledWith(false);
|
||||
});
|
||||
|
||||
it('hides the loading icon', () => {
|
||||
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
|
||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
||||
|
||||
expect(sqlEditorSpy.trigger).toHaveBeenCalledWith('pgadmin-sqleditor:loading-icon:hide');
|
||||
});
|
||||
@@ -109,9 +109,9 @@ describe('#callRenderAfterPoll', () => {
|
||||
describe('notifications are enabled', () => {
|
||||
it('display notification', () => {
|
||||
sqlEditorSpy.info_notifier_timeout = 10;
|
||||
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
|
||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
||||
|
||||
expect(alertify.success).toHaveBeenCalledWith(
|
||||
expect(Notify.success).toHaveBeenCalledWith(
|
||||
'Query returned successfully in 0 msec.',
|
||||
10
|
||||
);
|
||||
@@ -119,7 +119,7 @@ describe('#callRenderAfterPoll', () => {
|
||||
});
|
||||
|
||||
it('disables the save results button', () => {
|
||||
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
|
||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
||||
|
||||
expect(sqlEditorSpy.enable_disable_download_btn).toHaveBeenCalledWith(true);
|
||||
|
||||
@@ -143,25 +143,25 @@ describe('#callRenderAfterPoll', () => {
|
||||
});
|
||||
|
||||
it('renders the editor', () => {
|
||||
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
|
||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
||||
|
||||
expect(sqlEditorSpy._render).toHaveBeenCalledWith(queryResult);
|
||||
});
|
||||
|
||||
it('inform sqleditor that the query stopped running', () => {
|
||||
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
|
||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
||||
|
||||
expect(sqlEditorSpy.setIsQueryRunning).toHaveBeenCalledWith(false);
|
||||
});
|
||||
|
||||
it('hides the loading icon', () => {
|
||||
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
|
||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
||||
|
||||
expect(sqlEditorSpy.trigger).toHaveBeenCalledWith('pgadmin-sqleditor:loading-icon:hide');
|
||||
});
|
||||
|
||||
it('enables sqleditor tools buttons', () => {
|
||||
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
|
||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
||||
|
||||
expect(sqlEditorSpy.disable_tool_buttons).toHaveBeenCalledWith(false);
|
||||
});
|
||||
@@ -178,7 +178,7 @@ describe('#callRenderAfterPoll', () => {
|
||||
});
|
||||
|
||||
it('saves execution information in the history', () => {
|
||||
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
|
||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
||||
|
||||
expect(sqlEditorSpy.update_msg_history).toHaveBeenCalledWith(
|
||||
true,
|
||||
@@ -188,25 +188,25 @@ describe('#callRenderAfterPoll', () => {
|
||||
});
|
||||
|
||||
it('resets the changed data store', () => {
|
||||
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
|
||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
||||
|
||||
expect(sqlEditorSpy.reset_data_store).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('inform sqleditor that the query stopped running', () => {
|
||||
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
|
||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
||||
|
||||
expect(sqlEditorSpy.setIsQueryRunning).toHaveBeenCalledWith(false);
|
||||
});
|
||||
|
||||
it('hides the loading icon', () => {
|
||||
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
|
||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
||||
|
||||
expect(sqlEditorSpy.trigger).toHaveBeenCalledWith('pgadmin-sqleditor:loading-icon:hide');
|
||||
});
|
||||
|
||||
it('enables sqleditor tools buttons', () => {
|
||||
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
|
||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
||||
|
||||
expect(sqlEditorSpy.disable_tool_buttons).toHaveBeenCalledWith(false);
|
||||
});
|
||||
@@ -214,9 +214,9 @@ describe('#callRenderAfterPoll', () => {
|
||||
describe('notifications are enabled', () => {
|
||||
it('display notification', () => {
|
||||
sqlEditorSpy.info_notifier_timeout = 10;
|
||||
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
|
||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
||||
|
||||
expect(alertify.success).toHaveBeenCalledWith(
|
||||
expect(Notify.success).toHaveBeenCalledWith(
|
||||
'Query returned successfully in 0 msec.',
|
||||
10
|
||||
);
|
||||
@@ -224,7 +224,7 @@ describe('#callRenderAfterPoll', () => {
|
||||
});
|
||||
|
||||
it('disables the save results button', () => {
|
||||
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
|
||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
||||
|
||||
expect(sqlEditorSpy.enable_disable_download_btn).toHaveBeenCalledWith(true);
|
||||
|
||||
@@ -232,7 +232,7 @@ describe('#callRenderAfterPoll', () => {
|
||||
});
|
||||
|
||||
it('check whether database has been moved/renamed', () => {
|
||||
callRenderAfterPoll(sqlEditorSpy, alertify, queryResult);
|
||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
||||
|
||||
expect(sqlEditorSpy.trigger).toHaveBeenCalledWith('pgadmin-sqleditor:check_synchronous_db_name_change', queryResult);
|
||||
|
||||
|
||||
@@ -197,8 +197,6 @@ describe('queryToolActions', () => {
|
||||
spyOn(queryToolActions, '_costsEnabled').and.returnValue(true);
|
||||
spyOn(queryToolActions, '_summary').and.returnValue(false);
|
||||
spyOn(queryToolActions, '_settings').and.returnValue(false);
|
||||
spyOn(queryToolActions, '_summary').and.returnValue(false);
|
||||
spyOn(queryToolActions, '_settings').and.returnValue(false);
|
||||
});
|
||||
|
||||
it('calls the execute function', () => {
|
||||
|
||||
@@ -19,7 +19,7 @@ import {TreeNode} from '../../../pgadmin/static/js/tree/tree_nodes';
|
||||
describe('#enableTriggers', () => {
|
||||
let networkMock;
|
||||
let tree;
|
||||
let alertify;
|
||||
let Notify;
|
||||
let generateUrlSpy;
|
||||
beforeEach(() => {
|
||||
networkMock = new MockAdapter(axios);
|
||||
@@ -47,7 +47,7 @@ describe('#enableTriggers', () => {
|
||||
const tableNoData = tree.addNewNode('table-no-data', undefined, ['<li>table-no-data</li>']);
|
||||
tree.addChild(schema1, tableNoData);
|
||||
|
||||
alertify = jasmine.createSpyObj('alertify', ['success', 'error']);
|
||||
Notify = jasmine.createSpyObj('Notify', ['success', 'error']);
|
||||
generateUrlSpy = jasmine.createSpy('generateUrl');
|
||||
generateUrlSpy.and.returnValue('/some/place');
|
||||
});
|
||||
@@ -58,7 +58,7 @@ describe('#enableTriggers', () => {
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
expect(enableTriggers(tree, alertify, generateUrlSpy, {})).toEqual(false);
|
||||
expect(enableTriggers(tree, Notify, generateUrlSpy, {})).toEqual(false);
|
||||
done();
|
||||
}, 0);
|
||||
});
|
||||
@@ -73,7 +73,7 @@ describe('#enableTriggers', () => {
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
expect(enableTriggers(tree, alertify, generateUrlSpy, {})).toEqual(false);
|
||||
expect(enableTriggers(tree, Notify, generateUrlSpy, {})).toEqual(false);
|
||||
done();
|
||||
}, 0);
|
||||
});
|
||||
@@ -95,15 +95,15 @@ describe('#enableTriggers', () => {
|
||||
|
||||
it('displays an alert box with success', (done) => {
|
||||
tree.selectNode([{id: 'table1'}]);
|
||||
enableTriggers(tree, alertify, generateUrlSpy, {});
|
||||
enableTriggers(tree, Notify, generateUrlSpy, {});
|
||||
setTimeout(() => {
|
||||
expect(alertify.success).toHaveBeenCalledWith('some information');
|
||||
expect(Notify.success).toHaveBeenCalledWith('some information');
|
||||
done();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
it('reloads the node', (done) => {
|
||||
enableTriggers(tree, alertify, generateUrlSpy, {item: [{id: 'table1'}]});
|
||||
enableTriggers(tree, Notify, generateUrlSpy, {item: [{id: 'table1'}]});
|
||||
setTimeout(() => {
|
||||
expect(tree.selected()).toEqual(['<li>table1</li>']);
|
||||
done();
|
||||
@@ -111,7 +111,7 @@ describe('#enableTriggers', () => {
|
||||
});
|
||||
|
||||
it('call backend with the correct parameters', (done) => {
|
||||
enableTriggers(tree, alertify, generateUrlSpy, {item: [{id: 'table1'}]});
|
||||
enableTriggers(tree, Notify, generateUrlSpy, {item: [{id: 'table1'}]});
|
||||
setTimeout(() => {
|
||||
expect(networkMockCalledWith.data).toEqual(JSON.stringify({is_enable_trigger: 'O'}));
|
||||
done();
|
||||
@@ -131,15 +131,15 @@ describe('#enableTriggers', () => {
|
||||
|
||||
it('displays an error alert', (done) => {
|
||||
tree.selectNode([{id: 'table1'}]);
|
||||
enableTriggers(tree, alertify, generateUrlSpy, {});
|
||||
enableTriggers(tree, Notify, generateUrlSpy, {});
|
||||
setTimeout(() => {
|
||||
expect(alertify.error).toHaveBeenCalledWith('some error message');
|
||||
expect(Notify.error).toHaveBeenCalledWith('some error message');
|
||||
done();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
it('unload the node', (done) => {
|
||||
enableTriggers(tree, alertify, generateUrlSpy, {item: [{id: 'table1'}]});
|
||||
enableTriggers(tree, Notify, generateUrlSpy, {item: [{id: 'table1'}]});
|
||||
|
||||
setTimeout(() => {
|
||||
expect(tree.findNodeByDomElement([{id: 'table1'}]).children.length).toEqual(0);
|
||||
@@ -154,7 +154,7 @@ describe('#enableTriggers', () => {
|
||||
describe('#disableTriggers', () => {
|
||||
let networkMock;
|
||||
let tree;
|
||||
let alertify;
|
||||
let Notify;
|
||||
let generateUrlSpy;
|
||||
beforeEach(() => {
|
||||
networkMock = new MockAdapter(axios);
|
||||
@@ -175,7 +175,7 @@ describe('#disableTriggers', () => {
|
||||
const tableNoData = new TreeNode('table-no-data', undefined, ['<li>table-no-data</li>']);
|
||||
tree.addChild(schema1, tableNoData);
|
||||
|
||||
alertify = jasmine.createSpyObj('alertify', ['success', 'error']);
|
||||
Notify = jasmine.createSpyObj('Notify', ['success', 'error']);
|
||||
generateUrlSpy = jasmine.createSpy('generateUrl');
|
||||
generateUrlSpy.and.returnValue('/some/place');
|
||||
spyOn(tree, 'unload').and.callFake(function() {
|
||||
@@ -192,7 +192,7 @@ describe('#disableTriggers', () => {
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
expect(disableTriggers(tree, alertify, generateUrlSpy, {})).toEqual(false);
|
||||
expect(disableTriggers(tree, Notify, generateUrlSpy, {})).toEqual(false);
|
||||
done();
|
||||
}, 0);
|
||||
});
|
||||
@@ -207,7 +207,7 @@ describe('#disableTriggers', () => {
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
expect(disableTriggers(tree, alertify, generateUrlSpy, {})).toEqual(false);
|
||||
expect(disableTriggers(tree, Notify, generateUrlSpy, {})).toEqual(false);
|
||||
done();
|
||||
}, 0);
|
||||
});
|
||||
@@ -229,15 +229,15 @@ describe('#disableTriggers', () => {
|
||||
|
||||
it('displays an alert box with success', (done) => {
|
||||
tree.selectNode([{id: 'table1'}]);
|
||||
disableTriggers(tree, alertify, generateUrlSpy, {});
|
||||
disableTriggers(tree, Notify, generateUrlSpy, {});
|
||||
setTimeout(() => {
|
||||
expect(alertify.success).toHaveBeenCalledWith('some information');
|
||||
expect(Notify.success).toHaveBeenCalledWith('some information');
|
||||
done();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
it('reloads the node', (done) => {
|
||||
disableTriggers(tree, alertify, generateUrlSpy, {item: [{id: 'table1'}]});
|
||||
disableTriggers(tree, Notify, generateUrlSpy, {item: [{id: 'table1'}]});
|
||||
setTimeout(() => {
|
||||
expect(tree.selected()).toEqual(['<li>table1</li>']);
|
||||
done();
|
||||
@@ -245,7 +245,7 @@ describe('#disableTriggers', () => {
|
||||
});
|
||||
|
||||
it('call backend with the correct parameters', (done) => {
|
||||
disableTriggers(tree, alertify, generateUrlSpy, {item: [{id: 'table1'}]});
|
||||
disableTriggers(tree, Notify, generateUrlSpy, {item: [{id: 'table1'}]});
|
||||
setTimeout(() => {
|
||||
expect(networkMockCalledWith.data).toEqual(JSON.stringify({is_enable_trigger: 'D'}));
|
||||
done();
|
||||
@@ -265,15 +265,15 @@ describe('#disableTriggers', () => {
|
||||
|
||||
it('displays an error alert', (done) => {
|
||||
tree.selectNode([{id: 'table1'}]);
|
||||
disableTriggers(tree, alertify, generateUrlSpy, {});
|
||||
disableTriggers(tree, Notify, generateUrlSpy, {});
|
||||
setTimeout(() => {
|
||||
expect(alertify.error).toHaveBeenCalledWith('some error message');
|
||||
expect(Notify.error).toHaveBeenCalledWith('some error message');
|
||||
done();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
it('unload the node', (done) => {
|
||||
disableTriggers(tree, alertify, generateUrlSpy, {item: [{id: 'table1'}]});
|
||||
disableTriggers(tree, Notify, generateUrlSpy, {item: [{id: 'table1'}]});
|
||||
|
||||
setTimeout(() => {
|
||||
expect(tree.findNodeByDomElement([{id: 'table1'}]).children.length).toEqual(0);
|
||||
|
||||
Reference in New Issue
Block a user