Here goes the controller
export class SelectRegionController extends BaseController
{
//------------------------------------------------- Public static properties
static IID: string = "SelectRegionController";
static $inject: string[] = kp.common.Dependencies.injector;
//--------------------------------------------------------------------------
/**
* Constructor.
*
* @param $injector angular injector service
*/
//--------------------------------------------------------------------------
constructor(protected $injector:ng.auto.IInjectorService)
{
//------------------------------------------------------------- Initialize
super($injector);
//------------------------------------------------- Set region from cookie
var rop: string = this.getRop();
if (rop != null)
{
this.resetSearchForm(rop);
this.redirect(NavPath.search);
return;
}
//------------------------------------------------ Trigger webtrends event
var self = this;
setTimeout(function()
{
WebTrendsManager.landingPageEvent(self.$window,
self.getSearchForm(),
SearchPage.selectRegion);
}, 1000);
return;
} // constructor
//--------------------------------------------------------------------------
/*
* Public Interface
*/
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
/**
* Selects new region.
*
* @param region region value
*/
//--------------------------------------------------------------------------
public selectRegion(region: string): void
{
this.resetSearchForm(region);
return;
} // selectRegion
} // SelectRegionController
} // kp.fdl
and here goes the test code
now what is wrong in its test
module kp.fdl
{
'use strict';
class SelectRegionControllerTest {
//-------------------------------------Test run
public static run(): void {
beforeEach(module('kp.fdl'));
var controller: kp.fdl.SelectRegionController;
var injectorior: ng.auto.IInjectorService;
beforeEach(inject(function ( _$injector_) {
injectorior = _$injector_;
}));
it('Should initialize value to Loading',
inject(function($controller) {
controller = $controller('SelectRegionController', {
_$injector_: injectorior
});
expect(controller).not.toBeNull();
}));
}
}
describe('SelectRegion Controller', SelectRegionControllerTest.run);
} // kp.fdl
Somehow I can't get past this error "doctors-locations configuration
service is not loaded thrown" while going for a controller's instantiation
test.I think it should have called baseController's function, which is
loading this configuration service, but it doesn't maybe because 1) it
needs baseController defined first and then instantiate derived controllers
after copying scope created by baseController to drived's , and then I see
maybe I need to manually instantiate all libs objects present in
script/libs/kp, as they are used extensively in baseController, pretty
lengthy to approach if written in js, so falling back to typescript way of
writing testCase, i.e. to define a base test class for base controller,
then derive other classes using it. (I'm looking at this approach now) OR
2) It needs type annotation as dependency injection which for scope is
kp.common.NgValue.scope & for injector is kp.common.NgServiceName.injector
.but even If I do so it complains that NgValue not exported while I can
verify it is exported similarly as controller's are exported. (I'm blocked
at this)
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.