Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/dev/tests/js/jasmine/tests/lib/mage/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/dev/tests/js/jasmine/tests/lib/mage/apply.test.js
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

/* eslint-disable max-nested-callbacks */
define([
    'underscore',
    'tests/assets/tools',
    'tests/assets/apply/index',
    'mage/apply/main'
], function (_, tools, config, mage) {
    'use strict';

    describe('mage/apply/main', function () {
        var body = document.body;

        afterEach(function () {
            tools.removeContainer(config.base.containerId);
        });

        it('exports object', function () {
            expect(_.isFunction(mage) || _.isObject(mage)).toBe(true);
        });

        it('removes data-mage-init attribute affter processing', function () {
            var preset = config.fn,
                elem;

            /**
             * Checks if element has data attribute.
             *
             * @returns {Boolean}
             */
            function hasAttr() {
                return elem.hasAttribute(preset.dataAttr);
            }

            body.insertAdjacentHTML('beforeend', preset.tmpl);

            elem = document.getElementById(preset.nodeId);

            expect(hasAttr()).toBe(true);

            mage.apply();

            expect(hasAttr()).toBe(false);
        });

        it('calls function returned from module', function (done) {
            var preset = config.fn,
                node;

            spyOn(preset.component, 'testCallback').and.callThrough();

            body.insertAdjacentHTML('beforeend', preset.tmpl);

            node = document.getElementById(preset.nodeId);

            mage.apply();

            setTimeout(function () {
                expect(preset.component.testCallback)
                    .toHaveBeenCalledWith(jasmine.any(Object), node);

                done();
            }, 100);
        });
    });
});

Spamworldpro Mini