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
'static/js/**/*.js',
'static/js/**/*.ts',
// Tests
'static/test/**/*.js',
'static/js/**/*spec.ts',
],
exclude: [
'static/js/build/bundle.js',

View file

@ -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();

View file

@ -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);
}
};
}

View file

@ -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;

View file

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