From d5a74af024002cbb3b445c12fc4df97c0645d530 Mon Sep 17 00:00:00 2001 From: alecmerdler Date: Wed, 18 Jan 2017 22:10:43 -0800 Subject: [PATCH] typescript tests working --- karma.conf.js | 2 +- .../angular-view-array/angular-view-array.spec.ts | 15 +++++++++------ .../angular-view-array/angular-view-array.ts | 10 ++++++---- .../angular-view-array/view-array.impl.ts | 6 +++--- tsconfig.json | 1 + 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index ed75118d7..3889075c9 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -29,10 +29,10 @@ module.exports = function(config) { // Application resources 'static/js/**/*.js', - 'static/js/**/*.ts', // Tests 'static/test/**/*.js', + 'static/js/**/*spec.ts', ], exclude: [ 'static/js/build/bundle.js', diff --git a/static/js/services/angular-view-array/angular-view-array.spec.ts b/static/js/services/angular-view-array/angular-view-array.spec.ts index 2ec39ea7a..4afc88184 100644 --- a/static/js/services/angular-view-array/angular-view-array.spec.ts +++ b/static/js/services/angular-view-array/angular-view-array.spec.ts @@ -1,26 +1,29 @@ -import IInjectorService = angular.auto.IInjectorService; -// import { ViewArrayImpl } from './view-array.impl'; +import { angularViewArrayFactory } from './angular-view-array'; +import { ViewArrayImpl } from './view-array.impl'; +import * as angular from 'angular'; describe("Service: AngularViewArray", () => { var angularViewArray: any; + var $interval: ng.IIntervalService; beforeEach(angular.mock.module('quay')); - beforeEach(inject(($injector: IInjectorService) => { - angularViewArray = $injector.get('AngularViewArray'); + beforeEach(inject(($injector: ng.auto.IInjectorService) => { + $interval = $injector.get('$interval'); + angularViewArray = angularViewArrayFactory($interval); })); describe("create", () => { it("returns a ViewArray object", () => { - var viewArray: any = angularViewArray.create(); + var viewArray: ViewArrayImpl = angularViewArray.create(); expect(viewArray).toBeDefined(); }); describe("returned ViewArray object", () => { - var viewArray: any; + var viewArray: ViewArrayImpl; beforeEach(() => { viewArray = angularViewArray.create(); diff --git a/static/js/services/angular-view-array/angular-view-array.ts b/static/js/services/angular-view-array/angular-view-array.ts index 795fb7e77..56c1c6b6f 100644 --- a/static/js/services/angular-view-array/angular-view-array.ts +++ b/static/js/services/angular-view-array/angular-view-array.ts @@ -10,16 +10,18 @@ import { ViewArrayImpl } from './view-array.impl'; */ angular .module('quay') - .factory('AngularViewArray', AngularViewArrayFactory); + .factory('AngularViewArray', angularViewArrayFactory); -AngularViewArrayFactory.$inject = [ +angularViewArrayFactory.$inject = [ '$interval' ]; -export default function AngularViewArrayFactory($interval): any { +export function angularViewArrayFactory($interval): any { + const ADDITIONAL_ENTRIES: number = 20; + return { create: function(): ViewArray { - return new ViewArrayImpl($interval, 20); + return new ViewArrayImpl($interval, ADDITIONAL_ENTRIES); } }; } diff --git a/static/js/services/angular-view-array/view-array.impl.ts b/static/js/services/angular-view-array/view-array.impl.ts index a0050bc6a..b45ce185a 100644 --- a/static/js/services/angular-view-array/view-array.impl.ts +++ b/static/js/services/angular-view-array/view-array.impl.ts @@ -57,7 +57,7 @@ export class ViewArrayImpl implements ViewArray { } } - private showAdditionalEntries_(): void { + public showAdditionalEntries_(): void { var i: number = 0; for (i = this.currentIndex_; i < (this.currentIndex_ + this.additionalCount) && i < this.entries.length; ++i) { this.visibleEntries.push(this.entries[i]); @@ -70,7 +70,7 @@ export class ViewArrayImpl implements ViewArray { } } - private startTimer_(): void { + public startTimer_(): void { if (this.timerRef_) { return; } @@ -81,7 +81,7 @@ export class ViewArrayImpl implements ViewArray { }, 10); } - private stopTimer_(): void { + public stopTimer_(): void { if (this.timerRef_) { this.interval.cancel(this.timerRef_); this.timerRef_ = null; diff --git a/tsconfig.json b/tsconfig.json index 39b63f61b..d8acb9b2a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,6 +3,7 @@ "baseUrl": ".", "jsx": "react", "module": "commonjs", + "moduleResolution": "node", "outDir": "./build/", "target": "es5", "sourceMap": true,