GIF89a=( �' 7IAXKgNgYvYx\%wh&h}t�h%�s%x�}9�R��&�0%� (�.��5�SD��&�a)�x5��;ͣ*ȡ&ղ)ׯ7׵<ѻ4�3�H֧KͯT��Y�aq��q��F� !� ' !� NETSCAPE2.0 , =( ��pH,�Ȥr�l:xШtJ�Z�جv��z��xL.:��z�n���|N�����~�������& !�0`9R�}��"�"a:S�~x��������g���E�������R���E����B�� ��ȸ��D���"�Ů� �H��L��D٫D�B�����D���T���H �G��A R�ڐ |�� ٭&��E8�S�kG�A�px�a��� R2XB��E8I���6X�:vT)�~��q�賥��"F~%x� � 4#Z�0O|-4Bs�X:= Q� Sal��yXJ`GȦ|s h��K3l7�B|�$'7Jީܪ0!��D�n=�P� ����0`�R�lj����v>���5 �.69�ϸd�����nlv�9��f{���Pbx �l5}�p� ��� �3a���I�O����!ܾ���i��9��#��)p�a ޽ �{�)vm��%D~ 6f��s}Œ�D�W E�`!� �&L8x� �ܝ{)x`X/>�}m��R�*|`D�=�_ ^�5 !_&'a�O�7�c��`DCx`�¥�9�Y�F���`?��"� �n@`�} lď��@4>�d S �v�xN��"@~d��=�g�s~G��� ���ud &p8Q�)ƫlXD����A~H�ySun�j���k*D�LH�] ��C"J��Xb~ʪwSt}6K,��q�S:9ت:���l�@�`�� �.۬�t9�S�[:��=`9N����{¿�A !R�:���6��x�0�_ �;������^���#����!����U���;0L1�����p% A��U̬ݵ��%�S��!���~`�G���� ���=4�np�3���������u�u�ٮ|%2�I��r�#0��J``8�@S@5� ���^`8E�]�.�S���7 � �0�j S�D� z���i�S�����!���l��w9*�D�I�nEX��� &A�Go�Qf��F��;���}�J����F5��Q|���X��T��y���]� o ��C=��:���PB@ D׽S�(>�C�x}`��xJЬ�۠��p+eE0`�}`A �/NE�� �9@��� H�7�!%B0`�l*��!8 2�%� �:�1�0E��ux%nP1�!�C)�P81l�ɸF#Ƭ{����B0>�� �b�`��O3��()yRpb��E.ZD8�H@% �Rx+%���c� ���f��b�d�`F�"8�XH"��-�|1�6iI, 2�$+](A*j� QT�o0.�U�`�R�}`�SN����yae�����b��o~ S)�y�@��3 �tT�0�&�+~L�f"�-|�~��>!�v��~�\Q1)}@�}h#aP72�"�$ !� " , =( &7IAXG]KgNgYvYxR"k\%w]'}h}t�h%�g+�s%r.m3ax3�x�}9��&��+�!7�0%� (�.�SD��&��;�"&ײ)׻4��6�K� �@pH,�Ȥr�l:xШtJ�Z�جv��z��xL.:��z�n���|N�����~�������& !�0`9R�}��"�"a:S�~x��������g �� E �� �������E �´��C���ǶR��D��"Ʒ�ʱH��M��GڬD�B����D��T����G���C�C� l&�~:'�tU�6ɹ#��)�'�.6�&��Ȼ K(8p0N�?!�2"��NIJX>R��OM '��2�*x�>#n� �@<[:�I�f ��T���Cdb��[�}E�5MBo��@�`@��tW-3 �x�B���jI�&E�9[T&$��ﯧ&"s��ȳ����dc�UUρ#���ldj?����`\}���u|3'�R]�6 �S#�!�FKL�*N E���`$�:e�YD�q�.�촁�s \-�jA 9�����-��M[�x(�s��x�|���p��}k�T�DpE@W� ��]k`1� ���Yb ��0l��*n0��"~zBd�~u�7�0Bl��0-�x~|U�U0 �h�*HS�|��e"#"?vp�i`e6^�+q��`m8 #V�� ��VS|`��"m"сSn|@:U���~`pb�G�ED����2F�I�? >�x� R� ��%~jx��<�a�9ij�2�D��&: Z`�]w���:�6��B�7eFJ|�ҧ�,���FǮcS�ʶ+B�,�ܺN���>PAD�HD��~���n��}�#�� Q��S���2�X�{�k�lQ�2�����w�|2� h9��G�,m���3��6-��E�L��I�³*K���q�`DwV�QXS��peS��� qܧTS����R�u �<�a�*At�lmE� � ��N[P1�ۦ��$��@`��Dpy�yXvCAy�B`}D� 0QwG#� �a[^�� $���Ǧ{L�"[��K�g�;�S~��GX.�goT.��ư��x���?1z��x~:�g�|�L� ��S`��0S]P�^p F<""�?!,�!N4&P� ����:T�@h�9%t��:�-~�I<`�9p I&.)^ 40D#p@�j4�ج:�01��rܼF2oW�#Z ;$Q q  �K��Nl#29 !F@�Bh�ᏬL!XF�LHKh�.�hE&J�G��<"WN!�����Y@� >R~19J"�2,/ &.GXB%�R�9B6�W]���W�I�$��9�RE8Y� ��"�A5�Q.axB�&ة�J�! �t)K%tS-�JF b�NMxL��)�R��"���6O!TH�H� 0 !� ) , =( &AXKgNgYvYxR"k\%wh&h}h%�g+�s%r.x3�x�}9��&��+�R,�!7�0%� (�.��5��&�a)��;�"&ף*Ȳ)ׯ7׻4�3��6�H֧KͻH�T��Y��q��h� ��pH,�Ȥr�l:xШtJ�Z�جv��z��xL.:��z�n���|N�����~�������& !�0`9R�}��"�"a:S�~x��������g �� E$����� � ����$E$��"��D� � ������R��C��� E ��H�M��G�D� �B��ϾD��a��`1r��Ӑ�� �o~�zU!L�C'�yW�UGt����ll�0���uG�)A�s[��x� �xO%��X2�  P�n:R/��aHae+�Dm?# ǣ6�8�J�x�Di�M���j���5oQ7�- <! *�l��R2r/a!l)d� A"�E���� &� ;��c �%����b��pe~C"B���H�eF2��`8qb�t_`ur`e� w�u3��Pv�h""�`�Íx�LĹ��3� �~ֺ�:���MDfJ� �۵�W�%�S�X �؁)�@��:E��w�u�Sxb8y\m�zS��Zb�E�L��w!y(>�"w�=�|��s�d �C�W)H�cC$�L �7r.�\{)@�`@ �X�$PD `aaG:���O�72E�amn]�"Rc�x�R� &dR8`g��i�xLR!�P &d����T���i�|�_ � Qi�#�`g:��:noM� :V �)p����W&a=�e�k� j���1߲s�x�W�jal|0��B0�, \j۴:6���C ��W��|��9���zĸV {�;��n��V�m�I��.��PN� ����C��+��By�ѾHŸ:��� 7�Y�FTk�SaoaY$D�S���29R�kt� ��f� ��:��Sp�3�I��DZ� �9���g��u�*3)O��[_hv ,���Et x�BH� �[��64M@�S�M7d�l�ܶ5-��U܍��z�R3Ԭ3~ ��P��5�g: ���kN�&0�j4���#{��3S�2�K�'ợl���2K{� {۶?~m𸧠�I�nE�='����^���_�=��~�#O���'���o..�Y�n��CSO��a��K��o,���b�����{�C�� "�{�K ��w��Ozdը�:$ ���v�] A#� ���a�z)Rx׿ƥ�d``�w-�y�f�K!����|��P��=�`�(f��'Pa ��BJa%��f�%`�}F����6>��`G"�}�=�!o`�^FP�ةQ�C���`(�}\�ݮ ��$<��n@dĠE#��U�I�!� #l��9`k���'Rr��Z�NB�MF �[�+9���-�wj���8�r� ,V�h"�|�S=�G_��"E� 0i*%̲��da0mVk�):;&6p>�jK ��# �D�:�c?:R Ӭf��I-�"�<�="��7�3S��c2RW ,�8(T"P0F¡Jh�" ; 403WebShell
403Webshell
Server IP : 173.249.157.85  /  Your IP : 3.144.235.50
Web Server : Apache
System : Linux server.frogzhost.com 3.10.0-1127.19.1.el7.x86_64 #1 SMP Tue Aug 25 17:23:54 UTC 2020 x86_64
User : econtech ( 1005)
PHP Version : 7.3.33
Disable Function : NONE
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/econtech/public_html/public/back/assets/vendors/general/toastr/tests/unit/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/econtech/public_html/public/back/assets/vendors/general/toastr/tests/unit/toastr-tests.js
/// <reference path="../../../toastr.js" />
/// <reference path="../qunit/qunit.js" />
(function () {
    var iconClasses = {
        error: 'toast-error',
        info: 'toast-info',
        success: 'toast-success',
        warning: 'toast-warning'
    };
    var positionClasses = {
        topRight: 'toast-top-right',
        bottomRight: 'toast-bottom-right',
        bottomLeft: 'toast-bottom-left',
        topLeft: 'toast-top-left',
        topCenter: 'toast-top-center',
        bottomCenter: 'toast-bottom-center'
    };
    var sampleMsg = 'I don\'t think they really exist';
    var sampleTitle = 'TEST';
    var selectors = {
        container: 'div#toast-container',
        toastInfo: 'div#toast-container > div.toast-info',
        toastWarning: 'div#toast-container > div.toast-success',
        toastError: 'div#toast-container > div.toast-error',
        toastSuccess: 'div#toast-container > div.toast-success'
    };

    toastr.options = {
        timeOut: 2000,
        extendedTimeOut: 0,
        fadeOut: 0,
        fadeIn: 0,
        showDuration: 0,
        hideDuration: 0,
        debug: false
    };

    var delay = toastr.options.timeOut + 500;

    // 'Clears' must go first
    module('clear');
    asyncTest('clear - show 3 toasts, clear the 2nd', 1, function () {
        //Arrange
        var $toast = [];
        $toast[0] = toastr.info(sampleMsg, sampleTitle + '-1');
        $toast[1] = toastr.info(sampleMsg, sampleTitle + '-2');
        $toast[2] = toastr.info(sampleMsg, sampleTitle + '-3');
        var $container = toastr.getContainer();
        //Act
        toastr.clear($toast[1]);
        //Assert
        setTimeout(function () {
            ok($container && $container.children().length === 2);
            //Teardown
            resetContainer();
            start();
        }, 1000);
    });
    asyncTest('clear - show 3 toasts, clear all 3, 0 left', 1, function () {
        //Arrange
        var $toast = [];
        $toast[0] = toastr.info(sampleMsg, sampleTitle + '-1');
        $toast[1] = toastr.info(sampleMsg, sampleTitle + '-2');
        $toast[2] = toastr.info(sampleMsg, sampleTitle + '-3');
        var $container = toastr.getContainer();
        //Act
        toastr.clear();
        //Assert
        setTimeout(function () {
            ok($container && $container.children().length === 0);
            //Teardown
            resetContainer();
            start();
        }, delay);
    });
    test('clear - after clear with force option toast with focus disappears', 1, function () {
        //Arrange
        var $toast;
        var msg = sampleMsg + '<br/><br/><button type="button">Clear</button>';
        //Act
        $toast = toastr.info(msg, sampleTitle + '-1');
        $toast.find('button').focus();
        toastr.clear($toast, { force: true });
        var $container = toastr.getContainer();
        //Assert
        ok($container && $container.children().length === 0, 'Focused toast after a clear with force is not visible');
        //Teardown
        resetContainer();
    });
    asyncTest('clear and show - show 2 toasts, clear both, then show 1 more', 2, function () {
        //Arrange
        var $toast = [];
        $toast[0] = toastr.info(sampleMsg, sampleTitle + '-1');
        $toast[1] = toastr.info(sampleMsg, sampleTitle + '-2');
        var $container = toastr.getContainer();
        toastr.clear();
        //Act
        setTimeout(function () {
            $toast[2] = toastr.info(sampleMsg, sampleTitle + '-3-Visible');
            //Assert
            equal($toast[2].find('div.toast-title').html(), sampleTitle + '-3-Visible', 'Finds toast after a clear');
            ok($toast[2].is(':visible'), 'Toast after a clear is visible');
            //Teardown
            resetContainer();
            start();
        }, delay);
    });
    asyncTest('clear and show - clear removes toast container', 2, function () {
        //Arrange
        var $toast = [];
        $toast[0] = toastr.info(sampleMsg, sampleTitle + '-1');
        $toast[1] = toastr.info(sampleMsg, sampleTitle + '-2');
        var $container = toastr.getContainer();
        toastr.clear();
        //Act
        setTimeout(function () {
            //Assert
            equal($(selectors.container).length, 0, 'Toast container does not exist');
            ok(!$toast[1].is(':visible'), 'Toast after a clear is visible');
            //Teardown
            resetContainer();
            start();
        }, delay);
    });
    asyncTest('clear and show - after clear new toast creates container', 1, function () {
        //Arrange
        var $toast = [];
        $toast[0] = toastr.info(sampleMsg, sampleTitle + '-1');
        $toast[1] = toastr.info(sampleMsg, sampleTitle + '-2');
        var $container = toastr.getContainer();
        toastr.clear();
        //Act
        setTimeout(function () {
            $toast[2] = toastr.info(sampleMsg, sampleTitle + '-3-Visible');
            //Assert
            equal($(selectors.container).find('div.toast-title').html(), sampleTitle + '-3-Visible', 'Finds toast after a clear'); //Teardown
            resetContainer();
            start();
        }, delay);
    });
    asyncTest('clear and show - clear toast after hover', 1, function () {
        //Arrange
        var $toast = toastr.info(sampleMsg, sampleTitle);
        var $container = toastr.getContainer();
        $toast.trigger("mouseout");
        //Act
        setTimeout(function () {
            //Assert
            ok($container.find('div.toast-title').length === 0, 'Toast clears after a mouse hover'); //Teardown
            resetContainer();
            start();
        }, 500);
    });
    asyncTest('clear and show - do not clear toast after hover', 1, function () {
        //Arrange
        var $toast = toastr.info(sampleMsg, sampleTitle, { closeOnHover: false });
        var $container = toastr.getContainer();
        $toast.trigger("mouseout");
        //Act
        setTimeout(function () {
            //Assert
            ok($container.find('div.toast-title').length === 1, 'Toast does not clear after a mouse hover'); //Teardown
            resetContainer();
            start();
        }, 500);
    });
    test('clear and show - after clear all toasts new toast still appears', 1, function () {
        //Arrange
        var $toast = [];
        //Act
        $toast[0] = toastr.info(sampleMsg, sampleTitle + '-1');
        $toast[1] = toastr.info(sampleMsg, sampleTitle + '-2');
        toastr.clear();
        $toast[2] = toastr.info(sampleMsg, sampleTitle + '-3-Visible');
        //Assert
        ok($toast[2].is(':visible'), 'Toast after a clear is visible');
        //Teardown
        resetContainer();
    });
    module('info');
    test('info - pass title and message', 3, function () {
        //Arrange
        //Act
        var $toast = toastr.info(sampleMsg, sampleTitle);
        //Assert
        equal($toast.find('div.toast-title').html(), sampleTitle, 'Sets title');
        equal($toast.find('div.toast-message').html(), sampleMsg, 'Sets message');
        ok($toast.hasClass(iconClasses.info), 'Sets info icon');
        //Teardown
        $toast.remove();
        clearContainerChildren();
    });
    test('info - pass message, but no title', 3, function () {
        //Arrange
        //Act
        var $toast = toastr.info(sampleMsg);
        //Assert
        equal($toast.find('div.toast-title').length, 0, 'Sets null title');
        equal($toast.find('div.toast-message').html(), sampleMsg, 'Sets message');
        ok($toast.hasClass(iconClasses.info), 'Sets info icon');
        //Teardown
        $toast.remove();
        clearContainerChildren();
    });
    test('info - pass no message nor title', 3, function () {
        //Arrange
        //Act
        var $toast = toastr.info(); //Assert
        equal($toast.find('div.toast-title').length, 0, 'Sets null title');
        equal($toast.find('div.toast-message').html(), null, 'Sets message');
        ok($toast.hasClass(iconClasses.info), 'Sets info icon');
        //Teardown
        $toast.remove();
        clearContainerChildren();
    });
    module('warning');
    test('warning - pass message and title', 3, function () {
        //Arrange
        //Act
        var $toast = toastr.warning(sampleMsg, sampleTitle);
        //Assert
        equal($toast.find('div.toast-title').html(), sampleTitle, 'Sets title');
        equal($toast.find('div.toast-message').html(), sampleMsg, 'Sets message');
        ok($toast.hasClass(iconClasses.warning), 'Sets warning icon');
        //Teardown
        $toast.remove();
        clearContainerChildren();
    });
    test('warning - pass message, but no title', 3, function () {
        //Arrange
        //Act
        var $toast = toastr.warning(sampleMsg);
        //Assert
        equal($toast.find('div.toast-title').length, 0, 'Sets empty title');
        equal($toast.find('div.toast-message').html(), sampleMsg, 'Sets message');
        ok($toast.hasClass(iconClasses.warning), 'Sets warning icon');
        //Teardown
        $toast.remove();
        clearContainerChildren();
    });
    test('warning - no message nor title', 3, function () {
        //Arrange
        //Act
        var $toast = toastr.warning('');
        //Assert
        equal($toast.find('div.toast-title').length, 0, 'Sets null title');
        equal($toast.find('div.toast-message').length, 0, 'Sets empty message');
        ok($toast.hasClass(iconClasses.warning), 'Sets warning icon');
        //Teardown
        $toast.remove();
        clearContainerChildren();
    });
    module('error');
    test('error - pass message and title', 3, function () {
        //Arrange
        //Act
        var $toast = toastr.error(sampleMsg, sampleTitle);
        //Assert
        equal($toast.find('div.toast-title').html(), sampleTitle, 'Sets title');
        equal($toast.find('div.toast-message').html(), sampleMsg, 'Sets message');
        ok($toast.hasClass(iconClasses.error), 'Sets error icon');
        //Teardown
        $toast.remove();
        clearContainerChildren();
    });
    test('error - pass message, but no title', 3, function () {
        //Arrange
        //Act
        var $toast = toastr.error(sampleMsg); //Assert
        equal($toast.find('div.toast-title').length, 0, 'Sets empty title');
        equal($toast.find('div.toast-message').html(), sampleMsg, 'Sets message');
        ok($toast.hasClass(iconClasses.error), 'Sets error icon');
        //Teardown
        $toast.remove();
        clearContainerChildren();
    });
    test('error - no message nor title', 3, function () {
        //Arrange
        //Act
        var $toast = toastr.error('');
        //Assert
        equal($toast.find('div.toast-title').length, 0, 'Sets empty title');
        equal($toast.find('div.toast-message').length, 0, 'Sets empty message');
        ok($toast.hasClass(iconClasses.error), 'Sets error icon');
        //Teardown
        $toast.remove();
        clearContainerChildren();
    });
    module('success');
    test('success - pass message and title', 3, function () {
        //Arrange
        //Act
        var $toast = toastr.success(sampleMsg, sampleTitle);
        //Assert
        equal($toast.find('div.toast-title').html(), sampleTitle, 'Sets title');
        equal($toast.find('div.toast-message').html(), sampleMsg, 'Sets message');
        ok($toast.hasClass(iconClasses.success), 'Sets success icon');
        //Teardown
        $toast.remove();
        clearContainerChildren();
    });
    test('success - pass message, but no title', 3, function () {
        //Arrange
        //Act
        var $toast = toastr.success(sampleMsg);
        //Assert
        equal($toast.find('div.toast-title').length, 0, 'Sets empty title');
        equal($toast.find('div.toast-message').html(), sampleMsg, 'Sets message');
        ok($toast.hasClass(iconClasses.success), 'Sets success icon');
        //Teardown
        $toast.remove();
        clearContainerChildren();
    });
    test('success - no message nor title', 3, function () {
        //Arrange
        //Act
        var $toast = toastr.success('');
        //Assert
        equal($toast.find('div.toast-title').length, 0, 'Sets null title');
        equal($toast.find('div.toast-message').length, 0, 'Sets empty message');
        ok($toast.hasClass(iconClasses.success), 'Sets success icon'); //Teardown
        $toast.remove();
        clearContainerChildren();
    });


    module('escape html', {
        teardown: function () {
            toastr.options.escapeHtml = false;
        }
    });
    test('info - escape html', 2, function () {
        //Arrange
        toastr.options.escapeHtml = true;
        //Act
        var $toast = toastr.info('html <strong>message</strong>', 'html <u>title</u>');
        //Assert
        equal($toast.find('div.toast-title').html(), 'html &lt;u&gt;title&lt;/u&gt;', 'Title is escaped');
        equal($toast.find('div.toast-message').html(), 'html &lt;strong&gt;message&lt;/strong&gt;', 'Message is escaped');
        //Teardown
        $toast.remove();
        clearContainerChildren();
    });
    test('warning - escape html', 2, function () {
        //Arrange
        toastr.options.escapeHtml = true;
        //Act
        var $toast = toastr.warning('html <strong>message</strong>', 'html <u>title</u>');
        //Assert
        equal($toast.find('div.toast-title').html(), 'html &lt;u&gt;title&lt;/u&gt;', 'Title is escaped');
        equal($toast.find('div.toast-message').html(), 'html &lt;strong&gt;message&lt;/strong&gt;', 'Message is escaped');
        //Teardown
        $toast.remove();
        clearContainerChildren();
    });
    test('error - escape html', 2, function () {
        //Arrange
        toastr.options.escapeHtml = true;
        //Act
        var $toast = toastr.error('html <strong>message</strong>', 'html <u>title</u>');
        //Assert
        equal($toast.find('div.toast-title').html(), 'html &lt;u&gt;title&lt;/u&gt;', 'Title is escaped');
        equal($toast.find('div.toast-message').html(), 'html &lt;strong&gt;message&lt;/strong&gt;', 'Message is escaped');
        //Teardown
        $toast.remove();
        clearContainerChildren();
    });
    test('success - escape html', 2, function () {
        //Arrange
        toastr.options.escapeHtml = true;
        //Act
        var $toast = toastr.success('html <strong>message</strong>', 'html <u>title</u>');
        //Assert
        equal($toast.find('div.toast-title').html(), 'html &lt;u&gt;title&lt;/u&gt;', 'Title is escaped');
        equal($toast.find('div.toast-message').html(), 'html &lt;strong&gt;message&lt;/strong&gt;', 'Message is escaped');
        //Teardown
        $toast.remove();
        clearContainerChildren();
    });

    module('closeButton', {
        teardown: function () {
            toastr.options.closeButton = false;
        }
    });
    test('close button disabled', 1, function () {
        //Arrange
        toastr.options.closeButton = false;
        //Act
        var $toast = toastr.success('');
        //Assert
        equal($toast.find('button.toast-close-button').length, 0, 'close button should not exist with closeButton=false');
        //Teardown
        $toast.remove();
        clearContainerChildren();
    });
    test('close button enabled', 1, function () {
        //Arrange
        toastr.options.closeButton = true;
        //Act
        var $toast = toastr.success('');
        //Assert
        equal($toast.find('button.toast-close-button').length, 1, 'close button should exist with closeButton=true');
        //Teardown
        $toast.remove();
        clearContainerChildren();
    });
    test('close button has type=button', 1, function () {
        //Arrange
        toastr.options.closeButton = true;
        //Act
        var $toast = toastr.success('');
        //Assert
        equal($toast.find('button[type="button"].toast-close-button').length, 1, 'close button should have type=button');
        //Teardown
        $toast.remove();
        clearContainerChildren();
    });
    asyncTest('close button duration', 1, function () {
        //Arrange
        toastr.options.closeButton = true;
        toastr.options.closeDuration = 0;
        toastr.options.hideDuration = 2000;
        var $container = toastr.getContainer();
        //Act
        var $toast = toastr.success('');
        $toast.find('button.toast-close-button').click();
        setTimeout(function () {
            //Assert
            ok($container && $container.children().length === 0, 'close button should support own hide animation');
            //Teardown
            toastr.options.hideDuration = 0;
            resetContainer();
            start();
        }, 500);
    });

    module('progressBar', {
        teardown: function () {
            toastr.options.progressBar = false;
        }
    });
    test('progress bar disabled', 1, function () {
        //Arrange
        toastr.options.progressBar = false;
        //Act
        var $toast = toastr.success('');
        //Assert
        equal($toast.find('div.toast-progress').length, 0, 'progress bar should not exist with progressBar=false');
        //Teardown
        $toast.remove();
        clearContainerChildren();
    });
    test('progress bar enabled', 1, function () {
        //Arrange
        toastr.options.progressBar = true;
        //Act
        var $toast = toastr.success('');
        //Assert
        equal($toast.find('div.toast-progress').length, 1, 'progress bar should exist with progressBar=true');
        //Teardown
        $toast.remove();
        clearContainerChildren();
    });

    module('rtl', {
        teardown: function () {
            toastr.options.rtl = false;
        }
    });
    test('toastr is ltr by default', 1, function () {
        //Arrange
        //Act
        //Assert
        toastr.subscribe(function(response) {
            equal(response.options.rtl, false, 'ltr by default (i.e. rtl=false)');
        });
        var $toast = toastr.success('');
        //Teardown
        toastr.subscribe(null);
        $toast.remove();
        clearContainerChildren();
    });
    test('ltr toastr does not have .rtl class', 1, function () {
        //Arrange
        //Act
        var $toast = toastr.success('');
        //Assert
        ok($toast.hasClass('rtl') === false, 'ltr div container does not have .rtl class');
        //Teardown
        $toast.remove();
        clearContainerChildren();
    });
    test('rtl toastr has .rtl class', 1, function () {
        //Arrange
        toastr.options.rtl = true;
        //Act
        var $toast = toastr.success('');
        //Assert
        ok($toast.hasClass('rtl'), 'rtl div container has .rtl class');
        //Teardown
        $toast.remove();
        clearContainerChildren();
    });

    module('accessibility');
    test('toastr success has aria polite',1,function() {
        // Arrange
        var $toast = toastr.success('');

        // Act
        ok($toast.attr('aria-live')==='polite', 'success toast has aria-live of polite');

        // Teardown
        $toast.remove();
        clearContainerChildren();
    });
    test('toastr info has aria polite',1,function() {
        // Arrange
        var $toast = toastr.info('');

        // Act
        ok($toast.attr('aria-live')==='polite', 'info toast has aria-live of polite');

        // Teardown
        $toast.remove();
        clearContainerChildren();
    });
    test('toastr warning has aria assertive',1,function() {
        // Arrange
        var $toast = toastr.warning('');

        // Act
        ok($toast.attr('aria-live')==='assertive', 'warning toast has aria-live of assertive');

        // Teardown
        $toast.remove();
        clearContainerChildren();
    });
    test('toastr error has aria assertive',1,function() {
        // Arrange
        var $toast = toastr.error('');

        // Act
        ok($toast.attr('aria-live')==='assertive', 'error toast has aria-live of assertive');

        // Teardown
        $toast.remove();
        clearContainerChildren();
    });

    module('event', {
        teardown: function () {
            toastr.options.closeButton = false;
            toastr.options.hideDuration = 0;
        }
    });
    asyncTest('event - onShown is executed', 1, function () {
        // Arrange
        var run = false;
        var onShown = function () { run = true; };
        toastr.options.onShown = onShown;
        // Act
        var $toast = toastr.success(sampleMsg, sampleTitle);
        setTimeout(function () {
            // Assert
            ok(run);
            //Teardown
            $toast.remove();
            clearContainerChildren();
            start();
        }, delay);
    });

    asyncTest('event - onHidden is executed', 1, function () {
        //Arrange
        var run = false;
        var onHidden = function () { run = true; };
        toastr.options.onHidden = onHidden;
        toastr.options.timeOut = 1;
        //Act
        var $toast = toastr.success(sampleMsg, sampleTitle);
        setTimeout(function () {
            // Assert
            ok(run); //Teardown
            $toast.remove();
            clearContainerChildren();
            start();
        }, delay);
    });

    asyncTest('event - onShown and onHidden are both executed', 2, function () {
        //Arrange
        var onShowRun = false;
        var onHideRun = false;
        var onShow = function () { onShowRun = true; };
        var onHide = function () { onHideRun = true; };
        toastr.options.onShown = onShow;
        toastr.options.onHidden = onHide;
        toastr.options.timeOut = 1;
        //Act
        var $toast = toastr.success(sampleMsg, sampleTitle);
        setTimeout(function () {
            // Assert
            ok(onShowRun);
            ok(onHideRun);
            //Teardown
            $toast.remove();
            clearContainerChildren();
            start();
        }, delay);
    });

    asyncTest('event - onCloseClick is executed', 1, function () {
        //Arrange
        var run = false;
        toastr.options.closeButton = true;
        toastr.options.closeDuration = 0;
        toastr.options.hideDuration = 2000;
        var onCloseClick = function () { run = true; };
        toastr.options.onCloseClick = onCloseClick;
        toastr.options.timeOut = 1;
        //Act
        var $toast = toastr.success(sampleMsg, sampleTitle);
        $toast.find('button.toast-close-button').click();
        setTimeout(function () {
            // Assert
            ok(run); //Teardown
            $toast.remove();
            clearContainerChildren();
            start();
        }, delay);
    });

    test('event - message appears when no show or hide method functions provided', 1, function () {
        //Arrange
        //Act
        var $toast = toastr.success(sampleMsg, sampleTitle);
        //Assert
        ok($toast.hasClass(iconClasses.success), 'Sets success icon');
        //Teardown
        $toast.remove();
        clearContainerChildren();
    });

    test('event - prevent duplicate sequential toasts.', 1, function(){
        toastr.options.preventDuplicates = true;

        var $toast = [];
        $toast[0] = toastr.info(sampleMsg, sampleTitle);
        $toast[1] = toastr.info(sampleMsg, sampleTitle);
        $toast[2] = toastr.info(sampleMsg + " 1", sampleTitle);
        $toast[3] = toastr.info(sampleMsg, sampleTitle);
        var $container = toastr.getContainer();

        ok($container && $container.children().length === 3);

        clearContainerChildren();
    });

    test('event - prevent duplicate sequential toasts, but allow previous after clear.', 1, function(){
        toastr.options.preventDuplicates = true;

        var $toast = [];
        $toast[0] = toastr.info(sampleMsg, sampleTitle);
        $toast[1] = toastr.info(sampleMsg, sampleTitle);
        clearContainerChildren();
        $toast[3] = toastr.info(sampleMsg, sampleTitle);
        var $container = toastr.getContainer();

        ok($container && $container.children().length === 1);

        clearContainerChildren();
    });

    test('event - allow duplicate sequential toasts.', 1, function(){
        toastr.options.preventDuplicates = false;

        var $toast = [];
        $toast[0] = toastr.info(sampleMsg, sampleTitle);
        $toast[1] = toastr.info(sampleMsg, sampleTitle);
        $toast[1] = toastr.info(sampleMsg, sampleTitle);
        var $container = toastr.getContainer();

        ok($container && $container.children().length === 3);

        clearContainerChildren();
    });

    test('event - allow preventDuplicates option to be overridden.', 1, function() {
        var $toast = [];

        $toast[0] = toastr.info(sampleMsg, sampleTitle, {
            preventDuplicates: true
        });
        $toast[1] = toastr.info(sampleMsg, sampleTitle, {
            preventDuplicates: true
        });
        $toast[2] = toastr.info(sampleMsg, sampleTitle);
        var $container = toastr.getContainer();

        ok($container && $container.children().length === 2);
        clearContainerChildren();
    });

    module('subscription');
    asyncTest('subscribe - triggers 2 visible and 2 hidden response notifications while clicking on a toast', 1, function () {
        //Arrange
        var $toast = [];
        var expectedReponses = [];
        //Act
        toastr.subscribe(function(response) {
          if(response.options.testId) {
            expectedReponses.push(response);
          }
        })

        $toast[0] = toastr.info(sampleMsg, sampleTitle, {testId : 1});
        $toast[1] = toastr.info(sampleMsg, sampleTitle, {testId : 2});

        $toast[1].click()

        setTimeout(function () {
            // Assert
            ok(expectedReponses.length === 4);
            //Teardown
            clearContainerChildren();
            toastr.subscribe(null);
            start();
        }, delay);
    });

    module('order of appearance');
    test('Newest toast on top', 1, function () {
        //Arrange
        resetContainer();
        toastr.options.newestOnTop = true;
        //Act
        var $first = toastr.success("First toast");
        var $second = toastr.success("Second toast");
        //Assert
        var containerHtml = toastr.getContainer().html();
        ok(containerHtml.indexOf("First toast") > containerHtml.indexOf("Second toast"), 'Newest toast is on top');
        //Teardown
        $first.remove();
        $second.remove();
        resetContainer();
    });

    test('Oldest toast on top', 1, function () {
        //Arrange
        resetContainer();
        toastr.options.newestOnTop = false;
        //Act
        var $first = toastr.success("First toast");
        var $second = toastr.success("Second toast");
        //Assert
        var containerHtml = toastr.getContainer().html();
        ok(containerHtml.indexOf("First toast") < containerHtml.indexOf("Second toast"), 'Oldest toast is on top');
        //Teardown
        $first.remove();
        $second.remove();
        resetContainer();
    });

    // These must go last
    module('positioning');
    test('Container - position top-right', 1, function () {
        //Arrange
        resetContainer();
        toastr.options.positionClass = positionClasses.topRight;
        //Act
        var $toast = toastr.success(sampleMsg);
        var $container = toastr.getContainer();
        //Assert
        ok($container.hasClass(positionClasses.topRight), 'Has position top right');
        //Teardown
        $toast.remove();
        resetContainer();
    });
    test('Container - position bottom-right', 1, function () {
        //Arrange
        resetContainer();
        toastr.options.positionClass = positionClasses.bottomRight;
        //Act
        var $toast = toastr.success(sampleMsg);
        var $container = toastr.getContainer();
        //Assert
        ok($container.hasClass(positionClasses.bottomRight), 'Has position bottom right');
        //Teardown
        $toast.remove();
        resetContainer();
    });
    test('Container - position bottom-left', 1, function () {
        //Arrange
        resetContainer();
        //$(selectors.container).remove()
        toastr.options.positionClass = positionClasses.bottomLeft;
        //Act
        var $toast = toastr.success(sampleMsg);
        var $container = toastr.getContainer();
        //Assert
        ok($container.hasClass(positionClasses.bottomLeft), 'Has position bottom left');
        //Teardown
        $toast.remove();
        resetContainer();
    });
    test('Container - position top-left', 1, function () {
        //Arrange
        resetContainer();
        toastr.options.positionClass = positionClasses.topLeft;
        //Act
        var $toast = toastr.success(sampleMsg);
        var $container = toastr.getContainer();
        //Assert
        ok($container.hasClass(positionClasses.topLeft), 'Has position top left');
        //Teardown
        $toast.remove();
        resetContainer();
    });
    test('Container - position top-center', 1, function () {
        //Arrange
        resetContainer();
        toastr.options.positionClass = positionClasses.topCenter;
        //Act
        var $toast = toastr.success(sampleMsg);
        var $container = toastr.getContainer();
        //Assert
        ok($container.hasClass(positionClasses.topCenter), 'Has position top center');
        //Teardown
        $toast.remove();
        resetContainer();
    });
    test('Container - position bottom-center', 1, function () {
        //Arrange
        resetContainer();
        toastr.options.positionClass = positionClasses.bottomCenter;
        //Act
        var $toast = toastr.success(sampleMsg);
        var $container = toastr.getContainer();
        //Assert
        ok($container.hasClass(positionClasses.bottomCenter), 'Has position bottom center');
        //Teardown
        $toast.remove();
        resetContainer();
    });

    function resetContainer() {
        var $container = toastr.getContainer();
        if ($container) {
            $container.remove();
        }
        $(selectors.container).remove();
        clearContainerChildren();
    }

    function clearContainerChildren() {
        toastr.clear();
    }

})();

Youez - 2016 - github.com/yon3zu
LinuXploit