typescript tests working

This commit is contained in:
alecmerdler 2017-01-18 22:10:43 -08:00
parent b24d3b952b
commit d5a74af024
5 changed files with 20 additions and 14 deletions

View file

@ -29,10 +29,10 @@ module.exports = function(config) {
// Application resources // Application resources
'static/js/**/*.js', 'static/js/**/*.js',
'static/js/**/*.ts',
// Tests // Tests
'static/test/**/*.js', 'static/test/**/*.js',
'static/js/**/*spec.ts',
], ],
exclude: [ exclude: [
'static/js/build/bundle.js', 'static/js/build/bundle.js',

View file

@ -1,26 +1,29 @@
import IInjectorService = angular.auto.IInjectorService; import { angularViewArrayFactory } from './angular-view-array';
// import { ViewArrayImpl } from './view-array.impl'; import { ViewArrayImpl } from './view-array.impl';
import * as angular from 'angular';
describe("Service: AngularViewArray", () => { describe("Service: AngularViewArray", () => {
var angularViewArray: any; var angularViewArray: any;
var $interval: ng.IIntervalService;
beforeEach(angular.mock.module('quay')); beforeEach(angular.mock.module('quay'));
beforeEach(inject(($injector: IInjectorService) => { beforeEach(inject(($injector: ng.auto.IInjectorService) => {
angularViewArray = $injector.get('AngularViewArray'); $interval = $injector.get('$interval');
angularViewArray = angularViewArrayFactory($interval);
})); }));
describe("create", () => { describe("create", () => {
it("returns a ViewArray object", () => { it("returns a ViewArray object", () => {
var viewArray: any = angularViewArray.create(); var viewArray: ViewArrayImpl = angularViewArray.create();
expect(viewArray).toBeDefined(); expect(viewArray).toBeDefined();
}); });
describe("returned ViewArray object", () => { describe("returned ViewArray object", () => {
var viewArray: any; var viewArray: ViewArrayImpl;
beforeEach(() => { beforeEach(() => {
viewArray = angularViewArray.create(); viewArray = angularViewArray.create();

View file

@ -10,16 +10,18 @@ import { ViewArrayImpl } from './view-array.impl';
*/ */
angular angular
.module('quay') .module('quay')
.factory('AngularViewArray', AngularViewArrayFactory); .factory('AngularViewArray', angularViewArrayFactory);
AngularViewArrayFactory.$inject = [ angularViewArrayFactory.$inject = [
'$interval' '$interval'
]; ];
export default function AngularViewArrayFactory($interval): any { export function angularViewArrayFactory($interval): any {
const ADDITIONAL_ENTRIES: number = 20;
return { return {
create: function(): ViewArray { create: function(): ViewArray {
return new ViewArrayImpl($interval, 20); return new ViewArrayImpl($interval, ADDITIONAL_ENTRIES);
} }
}; };
} }

View file

@ -57,7 +57,7 @@ export class ViewArrayImpl implements ViewArray {
} }
} }
private showAdditionalEntries_(): void { public showAdditionalEntries_(): void {
var i: number = 0; var i: number = 0;
for (i = this.currentIndex_; i < (this.currentIndex_ + this.additionalCount) && i < this.entries.length; ++i) { for (i = this.currentIndex_; i < (this.currentIndex_ + this.additionalCount) && i < this.entries.length; ++i) {
this.visibleEntries.push(this.entries[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_) { if (this.timerRef_) {
return; return;
} }
@ -81,7 +81,7 @@ export class ViewArrayImpl implements ViewArray {
}, 10); }, 10);
} }
private stopTimer_(): void { public stopTimer_(): void {
if (this.timerRef_) { if (this.timerRef_) {
this.interval.cancel(this.timerRef_); this.interval.cancel(this.timerRef_);
this.timerRef_ = null; this.timerRef_ = null;

View file

@ -3,6 +3,7 @@
"baseUrl": ".", "baseUrl": ".",
"jsx": "react", "jsx": "react",
"module": "commonjs", "module": "commonjs",
"moduleResolution": "node",
"outDir": "./build/", "outDir": "./build/",
"target": "es5", "target": "es5",
"sourceMap": true, "sourceMap": true,