2018-04-03 08:52:13 -05:00
|
|
|
/////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
|
|
//
|
2020-01-02 08:43:50 -06:00
|
|
|
// Copyright (C) 2013 - 2020, The pgAdmin Development Team
|
2018-04-03 08:52:13 -05:00
|
|
|
// This software is released under the PostgreSQL Licence
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
|
2018-04-30 07:21:57 -05:00
|
|
|
import $ from 'jquery';
|
|
|
|
import modifyAnimation from 'sources/modify_animation';
|
2018-04-03 08:52:13 -05:00
|
|
|
|
|
|
|
|
|
|
|
describe('modifyAnimation', function () {
|
|
|
|
let pgBrowser;
|
|
|
|
let dummyElement;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
2018-04-30 07:21:57 -05:00
|
|
|
pgBrowser = jasmine.createSpyObj('pgBrowser', ['get_preference', 'tree']);
|
2018-04-03 08:52:13 -05:00
|
|
|
pgBrowser.tree = jasmine.createSpyObj('tree', ['options']);
|
|
|
|
pgBrowser.tree.options.and.returnValue({
|
2018-04-30 07:21:57 -05:00
|
|
|
show: {},
|
|
|
|
hide: {},
|
|
|
|
view: {},
|
2018-04-03 08:52:13 -05:00
|
|
|
});
|
|
|
|
dummyElement = document.createElement('link');
|
|
|
|
spyOn($.fn, 'find').and.returnValue($(dummyElement));
|
2019-10-10 01:35:28 -05:00
|
|
|
spyOn($.fn, 'removeClass');
|
|
|
|
spyOn($.fn, 'addClass');
|
2018-04-03 08:52:13 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('When browser tree animation is disabled', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
pgBrowser.get_preference.and.returnValue({value: false});
|
2018-04-10 05:09:59 -05:00
|
|
|
modifyAnimation.modifyAcitreeAnimation(pgBrowser);
|
2018-04-03 08:52:13 -05:00
|
|
|
});
|
|
|
|
it('tree options to animate should be disabled', function() {
|
|
|
|
expect(pgBrowser.get_preference).toHaveBeenCalled();
|
|
|
|
expect(pgBrowser.tree.options).toHaveBeenCalledTimes(4);
|
|
|
|
expect(pgBrowser.tree.options).toHaveBeenCalledWith({
|
|
|
|
animateRoot: false,
|
|
|
|
unanimated: true,
|
|
|
|
show: {duration: 0},
|
|
|
|
hide: {duration: 0},
|
|
|
|
view: {duration: 0},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('When browser tree animation is enabled', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
pgBrowser.get_preference.and.returnValue({value: true});
|
2018-04-10 05:09:59 -05:00
|
|
|
modifyAnimation.modifyAcitreeAnimation(pgBrowser);
|
2018-04-03 08:52:13 -05:00
|
|
|
});
|
|
|
|
it('tree options to animate should be enabled', function() {
|
|
|
|
expect(pgBrowser.get_preference).toHaveBeenCalled();
|
|
|
|
expect(pgBrowser.tree.options).toHaveBeenCalledTimes(4);
|
|
|
|
expect(pgBrowser.tree.options).toHaveBeenCalledWith({
|
|
|
|
animateRoot: true,
|
|
|
|
unanimated: false,
|
|
|
|
show: {duration: 75},
|
|
|
|
hide: {duration: 75},
|
|
|
|
view: {duration: 75},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('When alertify animation is disabled', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
pgBrowser.get_preference.and.returnValue({value: false});
|
2018-04-10 05:09:59 -05:00
|
|
|
modifyAnimation.modifyAlertifyAnimation(pgBrowser);
|
2018-04-03 08:52:13 -05:00
|
|
|
|
|
|
|
});
|
|
|
|
it('alertify disalogue/notification animation should be disabled', function() {
|
|
|
|
expect(pgBrowser.get_preference).toHaveBeenCalled();
|
|
|
|
expect($.fn.find).toHaveBeenCalled();
|
2019-10-10 01:35:28 -05:00
|
|
|
expect($.fn.addClass).toHaveBeenCalledWith('alertify-no-animation');
|
2018-04-03 08:52:13 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('When alertify animation is enabled', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
pgBrowser.get_preference.and.returnValue({value: true});
|
2018-04-10 05:09:59 -05:00
|
|
|
modifyAnimation.modifyAlertifyAnimation(pgBrowser);
|
2018-04-03 08:52:13 -05:00
|
|
|
});
|
|
|
|
it('alertify disalogue/notification animation should be enabled', function() {
|
|
|
|
expect(pgBrowser.get_preference).toHaveBeenCalled();
|
|
|
|
expect($.fn.find).toHaveBeenCalled();
|
2019-10-10 01:35:28 -05:00
|
|
|
expect($.fn.removeClass).toHaveBeenCalledWith('alertify-no-animation');
|
2018-04-03 08:52:13 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|