Sha256: d6dbe028f1764e09480ac8f2541c92453b5f7320441d5555c26bf82d5af5fcc4

Contents?: true

Size: 1.73 KB

Versions: 62

Compression:

Stored size: 1.73 KB

Contents

(function () {
    'use strict';

    describe('WORKAREA.messages', function () {
        describe('insertMessage', function () {
            it('adds a flash message if no $parent is provided', function () {
                fixture.set('<p class="page-messages"></p>');

                WORKAREA.messages.insertMessage('foo', 'bar');

                expect($('.page-messages').text()).to.include('foo');
            });

            it('adds a static message if $parent is provided', function () {
                fixture.set('<p id="my-message"></p>');

                WORKAREA.messages.insertMessage('baz', 'bat', $('#my-message'));

                expect($('#my-message').text()).to.include('baz');
            });
        });

        describe('insertPageMessages', function() {
            it('will not add the same message twice', function () {
                var event = {},
                    xhr = {
                        getResponseHeader: function() {
                            return JSON.stringify({ ball: 'fuzz' });
                        }
                    };
                fixture.set('<p class="page-messages"></p>');

                WORKAREA.messages.insertPageMessages(event, xhr);
                WORKAREA.messages.insertPageMessages(event, xhr);

                expect($('.page-messages .message').length).to.equal(1);
            });
        });

        describe('initMessage', function () {
            it('does not add a dismiss if told not to', function () {
                fixture.set('<div class="messages" data-message-show-dismiss="false"></div>');

                WORKAREA.messages.init($(this.fixtures));

                expect($('.message__dismiss-action').length).to.equal(0);
            });
        });
    });
}());

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-storefront-3.4.13 test/javascripts/messages_spec.js
workarea-storefront-3.4.12 test/javascripts/messages_spec.js