Skip to content

Commit

Permalink
fix($compiler): Migrated to Angular 2.0.0-rc.1
Browse files Browse the repository at this point in the history
  • Loading branch information
akserg committed May 13, 2016
1 parent dd8c37d commit 23ee112
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 63 deletions.
15 changes: 13 additions & 2 deletions karma-test-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,23 @@ System.config({
baseURL: '/base/',
defaultJSExtensions: true,
map: {
'angular2': 'node_modules/angular2',
'@angular/core/testing': 'node_modules/@angular/core/testing.js',
'@angular/core': 'node_modules/@angular/core/index.js',
'@angular/compiler/testing': 'node_modules/@angular/compiler/testing.js',
'@angular/compiler': 'node_modules/@angular/compiler/index.js',
'@angular/common/testing': 'node_modules/@angular/common/testing.js',
'@angular/common': 'node_modules/@angular/common/index.js',
'@angular/common/src/facade/lang': 'node_modules/@angular/common/src/facade/lang.js',
'@angular/platform-browser-dynamic/testing': 'node_modules/@angular/platform-browser-dynamic/testing.js',
'@angular/platform-browser/testing': 'node_modules/@angular/platform-browser/testing.js',
'@angular/platform-browser': 'node_modules/@angular/platform-browser/index.js',
'@angular': 'node_modules/@angular',
'browser_adapter': 'node_modules/@angular/platform-browser/src/browser/browser_adapter',
'rxjs': 'node_modules/rxjs'
}
});

System.import('angular2/src/platform/browser/browser_adapter').then(function(browser_adapter) {
System.import('browser_adapter').then(function(browser_adapter) {
browser_adapter.BrowserDomAdapter.makeCurrent();
}).then(function() {
return Promise.all(
Expand Down
4 changes: 2 additions & 2 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = function(config) {
'node_modules/systemjs/dist/system.src.js',
'node_modules/reflect-metadata/Reflect.js',

{ pattern: 'node_modules/angular2/**/*.js', included: false, watched: false, served: true },
{ pattern: 'node_modules/@angular/**/*.js', included: false, watched: false, served: true },
{ pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false, served: true },
{ pattern: 'node_modules/systemjs/dist/system-polyfills.js', included: false, watched: false, served: true }, // PhantomJS2 (and possibly others) might require it

Expand All @@ -34,7 +34,7 @@ module.exports = function(config) {

// list of files to exclude
exclude: [
'node_modules/angular2/**/*_spec.js'
'node_modules/@angular/**/*_spec.js'
],

preprocessors: {
Expand Down
16 changes: 10 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,31 @@
"typings": "./ng2-slim-loading-bar.d.ts",
"homepage": "https://github.com/akserg/ng2-slim-loading-bar",
"devDependencies": {
"angular2": "~2.0.0-beta.17",
"commitizen": "^2.7.6",
"cz-conventional-changelog": "^1.1.5",
"@angular/common": "^2.0.0-rc.1",
"@angular/compiler": "^2.0.0-rc.1",
"@angular/core": "^2.0.0-rc.1",
"@angular/platform-browser": "^2.0.0-rc.1",
"@angular/platform-browser-dynamic": "^2.0.0-rc.1",
"es6-promise": "~3.1.2",
"es6-shim": "~0.35.0",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.6",
"zone.js": "~0.6.12",
"jasmine-core": "~2.3.4",
"karma": "~0.13.15",
"karma-chrome-launcher": "~0.2.2",
"karma-firefox-launcher": "~0.1.7",
"karma-jasmine": "~0.3.6",
"karma-typescript-preprocessor": "0.0.21",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.6",
"semantic-release": "^4.3.5",
"systemjs": "~0.19.6",
"systemjs-builder": "^0.15.6",
"tsd": "^0.6.5",
"typescript": "~1.7.3",
"typings": "^0.6.8",
"uglify-js": "^2.6.2",
"zone.js": "~0.6.12"
"commitizen": "^2.7.6",
"cz-conventional-changelog": "^1.1.5"
},
"config": {
"commitizen": {
Expand Down
6 changes: 3 additions & 3 deletions src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// This project is licensed under the terms of the MIT license.
// https://github.com/akserg/ng2-slim-loading-bar

import {Component, Input, OnInit} from 'angular2/core';
import {isPresent} from 'angular2/src/facade/lang';
import {CORE_DIRECTIVES} from 'angular2/common';
import {Component, Input, OnInit} from '@angular/core';
import {isPresent} from '@angular/common/src/facade/lang';
import {CORE_DIRECTIVES} from '@angular/common';

import {SlimLoadingBarService, SlimLoadingBarEvent, SlimLoadingBarEventType} from './service';

Expand Down
4 changes: 2 additions & 2 deletions src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// This project is licensed under the terms of the MIT license.
// https://github.com/akserg/ng2-slim-loading-bar

import {Injectable} from 'angular2/core';
import {isPresent} from 'angular2/src/facade/lang';
import {Injectable} from '@angular/core';
import {isPresent} from '@angular/common/src/facade/lang';

import {Observable} from 'rxjs/Observable';
import {Subscriber} from 'rxjs/Subscriber';
Expand Down
53 changes: 28 additions & 25 deletions tests/component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import {
describe,
expect,
beforeEach,
it,
inject,
// injectAsync,
beforeEachProviders,
describe,
expect,
beforeEach,
it,
inject,
//injectAsync,
beforeEachProviders,
fakeAsync,
tick
} from '@angular/core/testing';

import {
TestComponentBuilder,
ComponentFixture,
fakeAsync,
tick
} from 'angular2/testing';
ComponentFixture
} from '@angular/compiler/testing';

import {TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS}
from 'angular2/platform/testing/browser';
import {TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS}
from '@angular/platform-browser-dynamic/testing';

import {Observable} from 'rxjs/Observable';

Expand All @@ -23,18 +26,18 @@ import {SlimLoadingBar} from '../src/component';
export function main() {
describe('SlimLoadingBar', () => {

let componentFixture:ComponentFixture;
let componentFixture:ComponentFixture<any>;
let component:SlimLoadingBar;
let containerDiv:HTMLDivElement;
let progressDiv:HTMLDivElement;

beforeEachProviders(() => {
return [TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS, TestComponentBuilder, SlimLoadingBarService];
return [TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS, TestComponentBuilder, SlimLoadingBarService];
});

// beforeEach(injectAsync([TestComponentBuilder], (tcb:TestComponentBuilder) => {
beforeEach(inject([TestComponentBuilder], (tcb:TestComponentBuilder) => {
return tcb.createAsync(SlimLoadingBar).then((cf:ComponentFixture) => {
return tcb.createAsync(SlimLoadingBar).then((cf:ComponentFixture<any>) => {
componentFixture = cf;
let element = componentFixture.elementRef.nativeElement;
containerDiv = element.querySelector('.slim-loading-bar');
Expand All @@ -49,43 +52,43 @@ export function main() {
expect(progressDiv).toBeDefined();
expect(component).toBeDefined();
});

it ('should change width of progress when calling set progress', () => {
expect(progressDiv.style.width).toBe('0%');

// Set progress
component.progress = '30';
componentFixture.detectChanges();
expect(progressDiv.style.width).toBe('30%');
});

it ('should change colors of progress when calling set color', () => {
expect(progressDiv.style.color).toBe('firebrick');

// Set color
component.color = 'green';
componentFixture.detectChanges();
expect(progressDiv.style.color).toBe('green');
expect(progressDiv.style.backgroundColor).toBe('green');
});

it ('should change height of progress when calling set height', () => {
expect(progressDiv.style.height).toBe('2px');

// Set height
component.height = '3px';
componentFixture.detectChanges();
expect(progressDiv.style.height).toBe('3px');
});

it ('should change visibility of progress when calling show', () => {
expect(progressDiv.style.opacity).toBe('1');

// Hide
component.show = false;
componentFixture.detectChanges();
expect(progressDiv.style.opacity).toBe('0');

// Show
component.show = true;
componentFixture.detectChanges();
Expand Down
46 changes: 23 additions & 23 deletions tests/service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import {
describe,
expect,
beforeEach,
it,
inject,
injectAsync,
beforeEachProviders,
fakeAsync,
tick
} from 'angular2/testing';
describe,
expect,
beforeEach,
it,
inject,
//injectAsync,
beforeEachProviders,
fakeAsync,
tick
} from '@angular/core/testing';

import {Observable} from 'rxjs/Observable';

import {SlimLoadingBarService, SlimLoadingBarEvent, SlimLoadingBarEventType} from '../src/service';

export function main() {
describe('SlimLoadingBarService', () => {

let service:SlimLoadingBarService;

beforeEachProviders(() => {
return [ SlimLoadingBarService ];
});

beforeEach(inject([SlimLoadingBarService], (slbs:SlimLoadingBarService) => {
service = slbs;
}));
Expand All @@ -31,60 +31,60 @@ export function main() {
expect(SlimLoadingBarService).toBeDefined();
expect(service instanceof SlimLoadingBarService).toBeTruthy();
});

it('starts at zero when just being injected', () => {
expect(service.progress).toBe(0);
});

it('can change the progress to 30 if you call set progress', () => {
service.progress = 30;
expect(service.progress).toBe(30);
});

it('increaments over time after calling start()', <any>fakeAsync(():void => {
// var value, flag;
expect(service.progress).toBe(0);
service.start();

tick(500);
expect(service.progress).toBe(1);
service.stop();
}));

it('have 100 returned from progress after complete()', () => {
service.start();
service.complete();
expect(service.progress).toBe(100);
});

it('resets to zero when calling reset() after start() or set()', () => {
service.progress = 30;
service.reset();
expect(service.progress).toBe(0);
});

it('will return 100 after calling complete', () => {
service.progress = 30;
service.complete();
expect(service.progress).toBe(100);
});

it('return current height when calling height() without parameters', () => {
expect(service.height).toBe('2px');
});

it('set the height when calling height() with parameter', () => {
service.height = '5px';
expect(service.height).toBe('5px');
});

it('return current color ', () => {
expect(service.color).toBe('firebrick');
});
it('set the color', () => {
service.color = 'green';
expect(service.color).toBe('green');
});

});
}

0 comments on commit 23ee112

Please sign in to comment.