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/scripts.test.js
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

define([
    'tests/assets/tools',
    'tests/assets/script/index',
    'mage/apply/scripts'
], function (tools, config, processScripts) {
    'use strict';

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

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

        it('exports function', function () {
            expect(typeof processScripts).toBe('function');
        });

        it('removes script node after processing it', function () {
            var preset = config.virtual;

            /**
             * Checks if script node exists.
             *
             * @returns {Boolean}
             */
            function hasNode() {
                return !!document.getElementById(preset.scriptId);
            }

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

            expect(hasNode()).toBe(true);

            processScripts();

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

        it('parses custom script nodes without element selector', function () {
            var virtuals,
                preset = config.virtual;

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

            virtuals = processScripts();

            expect(virtuals).toBeDefined();
            expect(virtuals.length).toBeGreaterThan(0);
        });

        it('extends data-mage-init attribute of a found node', function () {
            var preset = config.bySelector,
                elem,
                result;

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

            processScripts();

            elem = document.getElementById(preset.nodeId);
            result = elem.getAttribute(preset.dataAttr);

            expect(result).toEqual(JSON.stringify(preset.merged));
        });
    });
});

Spamworldpro Mini