All files / web/bundles/pimui/js/controller redirect.js

83.33% Statements 5/6
50% Branches 2/4
100% Functions 3/3
83.33% Lines 5/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33    3x     3x         4x                 4x       4x                  
'use strict';
 
define(
    ['jquery', 'underscore', 'pim/controller/base', 'pim/router'],
    function ($, _, BaseController, router) {
        return BaseController.extend({
            /**
             * {@inheritdoc}
             */
            renderRoute: function (route, path) {
                return $.get(path).then(this.redirect.bind(this)).promise();
            },
 
            /**
             * Redirect to the given route
             *
             * @param {Object} response
             */
            redirect: function (response) {
                Iif (!this.active) {
                    return;
                }
 
                router.redirectToRoute(
                    response.route,
                    response.params ? response.params : {},
                    {trigger: true}
                );
            }
        });
    }
);