lundi 16 octobre 2017

Error: Could not resolve '' from state '' caused by state.$go

I'm applying unit testing on the following function and the error is appearing:

Error: Could not resolve '' from state ''. This error is generated because of the state.$go

 function onSetInstance(e, args) {
    var selected = args.inst;
    _storage[storage].set("instance_id", selected.ID);
    _storage[storage].set("instance_name", selected.NAME);
    _storage.local.set("instance_name", selected.NAME);
    _storage.local.set("instanceSelected", JSON.stringify(selected));
    _storage.session.set("instanceSelected", JSON.stringify(selected));
    rootScope.instanceSelected = selected;
    rootScope.displaySelectionInstance = false;
    // console.log(rootScope.instanceSelected);
    rootScope.instance_id = parseInt(selected.ID);
    rootScope.instance_name = selected.NAME;
    rootScope.$broadcast("getInstanceName", null);

    var msg = "Instância '" + selected.NAME + "' selecionada.";
    var key = "Seleção de instância";

    _toastr.success(msg, t(key));

    var element = $("#shaker");

    animate.addClass(element, 'shake').then(function () {
        animate.removeClass(element, 'shake');
    });

    $state.go($state.current.name, {instance_id: selected.ID}, {reload: true})
}

My test is this.

  it('testing if the onSetInstance function', function(){    
    srv.onSetInstance();
    state.go( 'master.webadmin', {instance_id: {selected:{ID: 10}}}, {reload: true});
    rootScope.$emit('setInstance', {inst:''});

});

I would like to know the reason for this error and how to arrange to be able to validate my unit test

Aucun commentaire:

Enregistrer un commentaire