vendredi 19 février 2016

Do not know how to test angular.bootstrap wrapper

I'm writing unit test for our code and I have some functionality that uses angular.bootstrap and I have no idea how to test it using karma as by then is not part of any module or anything

(function () {
'use strict';

function fetchData() {

    var initInjector = angular.injector(['ng']);

    var $http = initInjector.get('$http');

    return $http.get('./app/config/app.config.json').then(function (response) {
        angular.module('myModule').value('globalConfig', response.data);
        return $http.get('./app/config/routes.config.json').then(function (response) {
            angular.module('myModule').value('routesConfig', response.data);
        }, function (errorResponse) {
            // Handle error case
            console.log('Error on loading routes:', errorResponse);
        });
    }, function (errorResponse) {
        // Handle error case
        console.log('Error on bootstrapping:', errorResponse);
    });
}

function bootstrapApplication() {
    angular.element(document).ready(function () {
        angular.bootstrap(document, ['myModule']);
    });
}

fetchData().then(bootstrapApplication);
}());

Aucun commentaire:

Enregistrer un commentaire