#487 step-control.js front unit test
This commit is contained in:
parent
eba193999c
commit
c0c4961717
client/core/src/components/step-control
|
@ -12,13 +12,36 @@ describe('Component vnStepControl', () => {
|
||||||
beforeEach(angular.mock.inject((_$componentController_, _$state_) => {
|
beforeEach(angular.mock.inject((_$componentController_, _$state_) => {
|
||||||
$componentController = _$componentController_;
|
$componentController = _$componentController_;
|
||||||
$state = _$state_;
|
$state = _$state_;
|
||||||
|
spyOn($state, 'go');
|
||||||
controller = $componentController('vnStepControl', {$state: $state});
|
controller = $componentController('vnStepControl', {$state: $state});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
describe('steps()', () => {
|
||||||
|
it(`should do nothing if called without args`, () => {
|
||||||
|
controller.steps = undefined;
|
||||||
|
|
||||||
|
expect(controller._steps).not.toEqual(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should set _steps property in the controller and call state.go()`, () => {
|
||||||
|
controller.$state.current.name = 'test';
|
||||||
|
controller.steps = [{state: 'nothing'}, {state: 'test'}];
|
||||||
|
|
||||||
|
expect(controller._steps).toEqual([{state: 'nothing'}, {state: 'test'}]);
|
||||||
|
expect(controller.currentStepIndex).toEqual(1);
|
||||||
|
expect(controller.$state.go).toHaveBeenCalledWith('nothing');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('currentState()', () => {
|
describe('currentState()', () => {
|
||||||
|
it(`should call the go method if the's no onStepChange`, () => {
|
||||||
|
controller.currentState = 'hello state!';
|
||||||
|
|
||||||
|
expect(controller.$state.go).toHaveBeenCalledWith('hello state!');
|
||||||
|
});
|
||||||
|
|
||||||
it(`should call the onStepChange method then return false and never call the go method`, () => {
|
it(`should call the onStepChange method then return false and never call the go method`, () => {
|
||||||
controller.onStepChange = jasmine.createSpy(controller, 'onStepChange').and.returnValue(false);
|
controller.onStepChange = jasmine.createSpy(controller, 'onStepChange').and.returnValue(false);
|
||||||
spyOn(controller.$state, 'go');
|
|
||||||
|
|
||||||
controller.currentState = "something";
|
controller.currentState = "something";
|
||||||
|
|
||||||
|
@ -28,7 +51,6 @@ describe('Component vnStepControl', () => {
|
||||||
|
|
||||||
it(`should call the onStepChange method then return true and finally call the go method`, () => {
|
it(`should call the onStepChange method then return true and finally call the go method`, () => {
|
||||||
controller.onStepChange = jasmine.createSpy(controller, 'onStepChange').and.returnValue(true);
|
controller.onStepChange = jasmine.createSpy(controller, 'onStepChange').and.returnValue(true);
|
||||||
spyOn(controller.$state, 'go');
|
|
||||||
|
|
||||||
controller.currentState = "something";
|
controller.currentState = "something";
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue