85 lines
2.5 KiB
TypeScript
85 lines
2.5 KiB
TypeScript
import {Mod as CoreModule} from '../../core/core.mod';
|
|
import {Mod as WindowListMod} from '../window-list.mod';
|
|
import {ComponentTest} from '../../infrastructure/ComponentHelper';
|
|
import {Directive, Controller, IFlightWindow} from './window-list';
|
|
|
|
|
|
class WindowListTest extends ComponentTest {
|
|
public api: any;
|
|
public $state: ng.ui.IStateService;
|
|
constructor() {
|
|
super(Directive.$componentName, 'app/window-list/list/window-list.tpl.html');
|
|
}
|
|
}
|
|
|
|
describe('Window list view Tests', () => {
|
|
let instance: WindowListTest,
|
|
core: CoreModule,
|
|
windowList: WindowListMod,
|
|
ctrl: Controller;
|
|
|
|
beforeEach(() => {
|
|
if (!instance) {
|
|
angular.mock.module('ui.router');
|
|
angular.mock.module('ionic');
|
|
angular.mock.module('chroma.configuration');
|
|
angular.mock.module(CoreModule.$componentName);
|
|
angular.mock.module(WindowListMod.$componentName);
|
|
core = new CoreModule(angular);
|
|
windowList = new WindowListMod(angular);
|
|
angular.mock.inject((api, $state) => {
|
|
instance = new WindowListTest();
|
|
instance.api = api;
|
|
instance.$state = $state;
|
|
});
|
|
}
|
|
});
|
|
|
|
it('Directive is compiled', () => {
|
|
instance.$httpBackend.expectGET(instance.api.getWindows).respond(200, []);
|
|
ctrl = instance.compile<Controller>();
|
|
expect(ctrl).toBeDefined();
|
|
expect(ctrl.windows).toBeDefined();
|
|
expect(ctrl.windows.length).toBe(0);
|
|
});
|
|
|
|
it('2 Windows are displayed and reversed', () => {
|
|
|
|
let windows: Array<IFlightWindow> = [{ Name: '1' }, { Name: '2' }];
|
|
|
|
instance.$httpBackend.expectGET(instance.api.getWindows).respond(200, windows);
|
|
|
|
ctrl = instance.compile<Controller>();
|
|
|
|
expect(ctrl.windows.length).toBe(2)
|
|
|
|
expect(ctrl.windows[0].Name).toBe('2');
|
|
})
|
|
|
|
it('2 Windows are displayed and reversed', () => {
|
|
|
|
let windows: Array<IFlightWindow> = [{ Name: '1' }, { Name: '2' }];
|
|
|
|
instance.$httpBackend.expectGET(instance.api.getWindows).respond(200, windows);
|
|
|
|
ctrl = instance.compile<Controller>();
|
|
|
|
expect(ctrl.windows.length).toBe(2)
|
|
|
|
expect(ctrl.windows[0].Name).toBe('2');
|
|
})
|
|
|
|
it('Flight list state is called on goToWindow', () => {
|
|
|
|
spyOn(instance.$state, 'go').and.returnValue(false);
|
|
|
|
instance.$httpBackend.expectGET(instance.api.getWindows).respond(200, []);
|
|
|
|
ctrl = instance.compile<Controller>();
|
|
|
|
ctrl.goToWindow({Name : 'test-123'});
|
|
|
|
expect(instance.$state.go).toHaveBeenCalledWith('chroma.flight-list', {filter : 'test-123'});
|
|
})
|
|
});
|