From f1c106998563c50b506cbbf6d28f0de9dcf33f20 Mon Sep 17 00:00:00 2001 From: Tero Parviainen Date: Wed, 11 May 2016 16:28:58 +0300 Subject: [PATCH 1/2] docs(upgrade): bring phonecat up to speed with rc.1. Use router-deprecated. --- .../ts/ng2_components/app/js/app.module.ts | 2 +- .../ts/ng2_components/app/systemjs.config.js | 1 + .../ts/ng2_components/package.1.json | 17 +++++++++-------- .../ts/ng2_components/test/karma_test_shim.js | 5 +++-- .../ts/ng2_final/app/js/app.component.ts | 2 +- .../ts/ng2_final/app/js/main.ts | 2 +- .../js/phone_detail/phone_detail.component.ts | 2 +- .../app/js/phone_list/phone_list.component.ts | 2 +- .../ts/ng2_final/app/systemjs.config.js | 1 + .../ts/ng2_final/package.1.json | 17 +++++++++-------- .../ts/ng2_final/test/karma_test_shim.js | 5 +++-- .../test/unit/phone_detail.component.spec.ts | 2 +- .../test/unit/phone_list.component.spec.ts | 2 +- .../ts/ng2_initial/app/systemjs.config.js | 1 + .../ts/ng2_initial/package.1.json | 17 +++++++++-------- .../ts/ng2_initial/test/karma_test_shim.js | 5 +++-- 16 files changed, 46 insertions(+), 37 deletions(-) diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/app.module.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/app.module.ts index 7ec8dd42f2..3718b9250f 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/app.module.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/app.module.ts @@ -24,7 +24,7 @@ angular.module('phonecatApp', [ configure.$inject = ['$routeProvider']; -function configure($routeProvider) { } +function configure($routeProvider) { // #docregion list-route $routeProvider. when('/phones', { diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/systemjs.config.js b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/systemjs.config.js index b7b216914c..d7510ce7c6 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/systemjs.config.js +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/systemjs.config.js @@ -17,6 +17,7 @@ System.config({ '@angular/platform-browser': { main: 'index.js', defaultExtension: 'js' }, '@angular/platform-browser-dynamic': { main: 'index.js', defaultExtension: 'js' }, '@angular/router': { main: 'index.js', defaultExtension: 'js' }, + '@angular/router-deprecated': { main: 'index.js', defaultExtension: 'js' }, '@angular/upgrade': { main: 'index.js', defaultExtension: 'js' }, 'rxjs': { defaultExtension: 'js' } diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/package.1.json b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/package.1.json index 425ad7b82f..501da397e3 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/package.1.json +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/package.1.json @@ -6,14 +6,15 @@ "repository": "https://github.com/angular/angular-phonecat", "license": "MIT", "dependencies": { - "@angular/common": "0.0.0-3", - "@angular/compiler": "0.0.0-3", - "@angular/core": "0.0.0-3", - "@angular/http": "0.0.0-3", - "@angular/platform-browser": "0.0.0-3", - "@angular/platform-browser-dynamic": "0.0.0-3", - "@angular/router": "0.0.0-3", - "@angular/upgrade": "0.0.0-3", + "@angular/common": "2.0.0-rc.1", + "@angular/compiler": "2.0.0-rc.1", + "@angular/core": "2.0.0-rc.1", + "@angular/http": "2.0.0-rc.1", + "@angular/platform-browser": "2.0.0-rc.1", + "@angular/platform-browser-dynamic": "2.0.0-rc.1", + "@angular/router": "2.0.0-rc.1", + "@angular/router-deprecated": "2.0.0-rc.1", + "@angular/upgrade": "2.0.0-rc.1", "es6-shim": "^0.35.0", "reflect-metadata": "0.1.3", diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/karma_test_shim.js b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/karma_test_shim.js index 7aa6c9ec90..26075e973d 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/karma_test_shim.js +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/karma_test_shim.js @@ -29,6 +29,7 @@ System.config({ '@angular/platform-browser': { main: 'index.js', defaultExtension: 'js' }, '@angular/platform-browser-dynamic': { main: 'index.js', defaultExtension: 'js' }, '@angular/router': { main: 'index.js', defaultExtension: 'js' }, + '@angular/router-deprecated': { main: 'index.js', defaultExtension: 'js' }, '@angular/upgrade': { main: 'index.js', defaultExtension: 'js' }, 'rxjs': { defaultExtension: 'js' } } @@ -37,8 +38,8 @@ System.config({ // #docregion ng2 System.import('@angular/core/testing').then(function(testing) { return System.import('@angular/platform-browser-dynamic/testing').then(function(browserTesting) { - testing.setBaseTestProviders(browserTesting.TEST_BROWSER_PLATFORM_PROVIDERS, - browserTesting.TEST_BROWSER_APPLICATION_PROVIDERS); + testing.setBaseTestProviders(browserTesting.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, + browserTesting.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS); }); }).then(function() { return Promise.all( diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/app.component.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/app.component.ts index a959a641a2..f572854fc0 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/app.component.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/app.component.ts @@ -1,6 +1,6 @@ // #docregion import { Component } from '@angular/core'; -import { RouteConfig, ROUTER_DIRECTIVES } from '@angular/router'; +import { RouteConfig, ROUTER_DIRECTIVES } from '@angular/router-deprecated'; import PhoneList from './phone_list/phone_list.component'; import PhoneDetail from './phone_detail/phone_detail.component'; diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/main.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/main.ts index fa854b1946..40ccfa0aac 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/main.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/main.ts @@ -3,7 +3,7 @@ import { provide } from '@angular/core'; import { LocationStrategy, HashLocationStrategy } from '@angular/common'; import { bootstrap } from '@angular/platform-browser-dynamic'; -import { ROUTER_PROVIDERS } from '@angular/router'; +import { ROUTER_PROVIDERS } from '@angular/router-deprecated'; import { Phones } from './core/phones.service'; import AppComponent from './app.component'; diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/phone_detail/phone_detail.component.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/phone_detail/phone_detail.component.ts index a6bfb4cb13..a6d07f3773 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/phone_detail/phone_detail.component.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/phone_detail/phone_detail.component.ts @@ -1,7 +1,7 @@ // #docregion // #docregion top import { Component, Inject } from '@angular/core'; -import { RouteParams } from '@angular/router'; +import { RouteParams } from '@angular/router-deprecated'; import { Phones, Phone } from '../core/phones.service'; import { CheckmarkPipe } from '../core/checkmark.pipe'; diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/phone_list/phone_list.component.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/phone_list/phone_list.component.ts index 2899bfbbb0..f87aa62efc 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/phone_list/phone_list.component.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/phone_list/phone_list.component.ts @@ -1,7 +1,7 @@ // #docregion full // #docregion top import { Component } from '@angular/core'; -import { RouterLink } from '@angular/router'; +import { RouterLink } from '@angular/router-deprecated'; import { Observable } from 'rxjs'; import { Phones, Phone } from '../core/phones.service'; diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/systemjs.config.js b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/systemjs.config.js index b7b216914c..d7510ce7c6 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/systemjs.config.js +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/systemjs.config.js @@ -17,6 +17,7 @@ System.config({ '@angular/platform-browser': { main: 'index.js', defaultExtension: 'js' }, '@angular/platform-browser-dynamic': { main: 'index.js', defaultExtension: 'js' }, '@angular/router': { main: 'index.js', defaultExtension: 'js' }, + '@angular/router-deprecated': { main: 'index.js', defaultExtension: 'js' }, '@angular/upgrade': { main: 'index.js', defaultExtension: 'js' }, 'rxjs': { defaultExtension: 'js' } diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/package.1.json b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/package.1.json index e8f21a01ce..0f07a065d2 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/package.1.json +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/package.1.json @@ -6,14 +6,15 @@ "repository": "https://github.com/angular/angular-phonecat", "license": "MIT", "dependencies": { - "@angular/common": "0.0.0-3", - "@angular/compiler": "0.0.0-3", - "@angular/core": "0.0.0-3", - "@angular/http": "0.0.0-3", - "@angular/platform-browser": "0.0.0-3", - "@angular/platform-browser-dynamic": "0.0.0-3", - "@angular/router": "0.0.0-3", - "@angular/upgrade": "0.0.0-3", + "@angular/common": "2.0.0-rc.1", + "@angular/compiler": "2.0.0-rc.1", + "@angular/core": "2.0.0-rc.1", + "@angular/http": "2.0.0-rc.1", + "@angular/platform-browser": "2.0.0-rc.1", + "@angular/platform-browser-dynamic": "2.0.0-rc.1", + "@angular/router": "2.0.0-rc.1", + "@angular/router-deprecated": "2.0.0-rc.1", + "@angular/upgrade": "2.0.0-rc.1", "es6-shim": "^0.35.0", "reflect-metadata": "0.1.3", diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/karma_test_shim.js b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/karma_test_shim.js index 7aa6c9ec90..26075e973d 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/karma_test_shim.js +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/karma_test_shim.js @@ -29,6 +29,7 @@ System.config({ '@angular/platform-browser': { main: 'index.js', defaultExtension: 'js' }, '@angular/platform-browser-dynamic': { main: 'index.js', defaultExtension: 'js' }, '@angular/router': { main: 'index.js', defaultExtension: 'js' }, + '@angular/router-deprecated': { main: 'index.js', defaultExtension: 'js' }, '@angular/upgrade': { main: 'index.js', defaultExtension: 'js' }, 'rxjs': { defaultExtension: 'js' } } @@ -37,8 +38,8 @@ System.config({ // #docregion ng2 System.import('@angular/core/testing').then(function(testing) { return System.import('@angular/platform-browser-dynamic/testing').then(function(browserTesting) { - testing.setBaseTestProviders(browserTesting.TEST_BROWSER_PLATFORM_PROVIDERS, - browserTesting.TEST_BROWSER_APPLICATION_PROVIDERS); + testing.setBaseTestProviders(browserTesting.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, + browserTesting.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS); }); }).then(function() { return Promise.all( diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/unit/phone_detail.component.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/unit/phone_detail.component.spec.ts index 380eb62470..c8751add62 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/unit/phone_detail.component.spec.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/unit/phone_detail.component.spec.ts @@ -1,6 +1,6 @@ import { provide } from '@angular/core'; // #docregion routeparams -import { RouteParams } from '@angular/router'; +import { RouteParams } from '@angular/router-deprecated'; // #enddocregion routeparams import { HTTP_PROVIDERS } from '@angular/http'; import { Observable } from 'rxjs/Rx'; diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/unit/phone_list.component.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/unit/phone_list.component.spec.ts index 85a6f7335f..f2a294e0e0 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/unit/phone_list.component.spec.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/unit/phone_list.component.spec.ts @@ -2,7 +2,7 @@ import { provide, ApplicationRef } from '@angular/core'; import { LocationStrategy, HashLocationStrategy } from '@angular/common'; import { HTTP_PROVIDERS } from '@angular/http'; -import { ROUTER_PROVIDERS, ROUTER_PRIMARY_COMPONENT } from '@angular/router'; +import { ROUTER_PROVIDERS, ROUTER_PRIMARY_COMPONENT } from '@angular/router-deprecated'; import { Observable } from 'rxjs/Rx'; import { describe, diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/systemjs.config.js b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/systemjs.config.js index 6eb2cccc14..2b0b854f6a 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/systemjs.config.js +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/systemjs.config.js @@ -18,6 +18,7 @@ System.config({ '@angular/platform-browser': { main: 'index.js', defaultExtension: 'js' }, '@angular/platform-browser-dynamic': { main: 'index.js', defaultExtension: 'js' }, '@angular/router': { main: 'index.js', defaultExtension: 'js' }, + '@angular/router-deprecated': { main: 'index.js', defaultExtension: 'js' }, '@angular/upgrade': { main: 'index.js', defaultExtension: 'js' }, 'rxjs': { defaultExtension: 'js' } diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/package.1.json b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/package.1.json index 425ad7b82f..501da397e3 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/package.1.json +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/package.1.json @@ -6,14 +6,15 @@ "repository": "https://github.com/angular/angular-phonecat", "license": "MIT", "dependencies": { - "@angular/common": "0.0.0-3", - "@angular/compiler": "0.0.0-3", - "@angular/core": "0.0.0-3", - "@angular/http": "0.0.0-3", - "@angular/platform-browser": "0.0.0-3", - "@angular/platform-browser-dynamic": "0.0.0-3", - "@angular/router": "0.0.0-3", - "@angular/upgrade": "0.0.0-3", + "@angular/common": "2.0.0-rc.1", + "@angular/compiler": "2.0.0-rc.1", + "@angular/core": "2.0.0-rc.1", + "@angular/http": "2.0.0-rc.1", + "@angular/platform-browser": "2.0.0-rc.1", + "@angular/platform-browser-dynamic": "2.0.0-rc.1", + "@angular/router": "2.0.0-rc.1", + "@angular/router-deprecated": "2.0.0-rc.1", + "@angular/upgrade": "2.0.0-rc.1", "es6-shim": "^0.35.0", "reflect-metadata": "0.1.3", diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/test/karma_test_shim.js b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/test/karma_test_shim.js index 7aa6c9ec90..26075e973d 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/test/karma_test_shim.js +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/test/karma_test_shim.js @@ -29,6 +29,7 @@ System.config({ '@angular/platform-browser': { main: 'index.js', defaultExtension: 'js' }, '@angular/platform-browser-dynamic': { main: 'index.js', defaultExtension: 'js' }, '@angular/router': { main: 'index.js', defaultExtension: 'js' }, + '@angular/router-deprecated': { main: 'index.js', defaultExtension: 'js' }, '@angular/upgrade': { main: 'index.js', defaultExtension: 'js' }, 'rxjs': { defaultExtension: 'js' } } @@ -37,8 +38,8 @@ System.config({ // #docregion ng2 System.import('@angular/core/testing').then(function(testing) { return System.import('@angular/platform-browser-dynamic/testing').then(function(browserTesting) { - testing.setBaseTestProviders(browserTesting.TEST_BROWSER_PLATFORM_PROVIDERS, - browserTesting.TEST_BROWSER_APPLICATION_PROVIDERS); + testing.setBaseTestProviders(browserTesting.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, + browserTesting.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS); }); }).then(function() { return Promise.all( From 11b8e2e54ee833ebbbde146090668c650c7e1a26 Mon Sep 17 00:00:00 2001 From: Tero Parviainen Date: Sat, 16 Apr 2016 16:41:05 +0300 Subject: [PATCH 2/2] docs(ugprade): bring phonecat upgrade tutorial up to speed with modernized Angular 1.x PhoneCat Relates to angular/angular-phonecat#326 --- .../animations.css => app.animations.css} | 0 .../ts/classes/app/app.config.ts | 12 + .../app/css => classes/app}/app.css | 0 .../ts/classes/app/app.module.ts | 18 + .../core/checkmark}/checkmark.filter.spec.ts | 4 +- .../checkmark}/checkmark.filter.ts | 0 .../ts/classes/app/core/core.module.ts | 6 + .../ts/classes/app/core/phone/phone.module.ts | 5 + .../app/core/phone/phone.service.spec.ts | 47 ++ .../classes/app/core/phone/phone.service.ts | 12 + .../ts/classes/app/css/.gitkeep | 0 .../ts/classes/app/index.html | 6 +- .../ts/classes/app/js/app.module.ts | 35 -- .../ts/classes/app/js/core/core.module.ts | 9 - .../ts/classes/app/js/core/phone.factory.ts | 10 - .../phone_detail/phone_detail.controller.ts | 22 - .../app/js/phone_detail/phone_detail.html | 118 ---- .../js/phone_detail/phone_detail.module.ts | 8 - .../js/phone_list/phone_list.controller.ts | 14 - .../app/js/phone_list/phone_list.module.ts | 5 - .../phone-detail.component.spec.ts | 38 ++ .../phone-detail/phone-detail.component.ts | 26 + .../app/phone-detail/phone-detail.module.ts | 9 + .../phone-detail/phone-detail.template.html | 118 ++++ .../phone-list/phone-list.component.spec.ts | 37 ++ .../app/phone-list/phone-list.component.ts | 18 + .../app/phone-list/phone-list.module.ts | 6 + .../app/phone-list/phone-list.template.html} | 6 +- .../ts/classes/app/systemjs.config.js | 2 +- .../e2e-tests}/protractor-conf.js | 2 +- .../{test/e2e => e2e-tests}/scenarios.js | 14 +- .../ts/classes/karma.conf.1.js | 42 ++ .../ts/classes/{test => }/karma_test_shim.js | 6 +- .../ts/classes/package.1.json | 19 +- .../ts/classes/test/jasmine_matchers.d.ts | 6 - .../ts/classes/test/karma.conf.1.js | 38 -- .../classes/test/unit/phone.factory.spec.ts | 15 - .../test/unit/phone_detail.controller.spec.ts | 44 -- .../test/unit/phone_list.controller.spec.ts | 44 -- .../animations.css => app.animations.css} | 0 .../ts/ng2_components/app/app.config.ts | 12 + .../app/css => ng2_components/app}/app.css | 0 .../js => ng2_components/app}/app.module.ts | 42 +- .../core/checkmark}/checkmark.pipe.spec.ts | 2 +- .../core => core/checkmark}/checkmark.pipe.ts | 4 +- .../ts/ng2_components/app/core/core.module.ts | 4 + .../app/core/phone/phone.module.ts | 8 + .../app/core/phone/phone.service.spec.ts | 43 ++ .../phone/phone.service.ts} | 30 +- .../app/core/upgrade-adapter.ts} | 5 +- .../ts/ng2_components/app/css/.gitkeep | 0 .../ts/ng2_components/app/index.html | 8 +- .../ts/ng2_components/app/js/app.module.ts | 46 -- .../ng2_components/app/js/core/core.module.ts | 8 - .../app/js/core/upgrade_adapter.ts | 9 - .../js/phone_detail/phone_detail.module.ts | 10 - .../app/js/phone_list/phone_list.component.ts | 26 - .../app/js/phone_list/phone_list.module.ts | 9 - .../phone_list_without_pipes.component.ts | 22 - .../phone-detail-without-pipes.component.ts} | 19 +- .../phone-detail.component.spec.ts} | 14 +- .../phone-detail.component.ts} | 21 +- .../app/phone-detail/phone-detail.module.ts | 11 + .../phone-detail.template.html} | 0 .../phone-list/order-by.pipe.spec.ts} | 2 +- .../app/phone-list/order-by.pipe.ts} | 6 +- .../app/phone-list/phone-filter.pipe.spec.ts} | 9 +- .../app/phone-list/phone-filter.pipe.ts} | 13 +- .../phone-list-without-async.template.html} | 2 - .../phone-list-without-pipes.component.ts | 21 + .../phone-list-without-pipes.template.html} | 2 - .../phone-list/phone-list.component.spec.ts} | 20 +- .../app/phone-list/phone-list.component.ts | 25 + .../app/phone-list/phone-list.module.ts | 8 + .../phone-list.template.html} | 2 - .../ts/ng2_components/app/systemjs.config.js | 2 +- .../{test => e2e-tests}/protractor-conf.js | 4 +- .../{test/e2e => e2e-tests}/scenarios.js | 22 +- .../ts/ng2_components/karma.conf.1.js | 59 ++ .../{test => }/karma_test_shim.js | 24 +- .../ts/ng2_components/package.1.json | 12 +- .../test/unit/phones.service.spec.ts | 16 - .../ng2_final/app/{js => }/app.component.ts | 6 +- .../core/checkmark}/checkmark.pipe.spec.ts | 4 +- .../core => core/checkmark}/checkmark.pipe.ts | 4 +- .../app/core/phone/phone.service.spec.ts | 43 ++ .../app/core/phone/phone.service.ts} | 18 +- .../ts/ng2_final/app/css/.gitkeep | 0 .../ts/ng2_final/app/index.html | 4 +- .../js/phone_detail/phone_detail.component.ts | 31 - .../app/js/phone_list/phone_list.component.ts | 29 - .../ts/ng2_final/app/{js => }/main.ts | 4 +- .../phone-detail.component.spec.ts} | 19 +- .../phone-detail/phone-detail.component.ts | 31 + .../phone-detail.template.html} | 0 .../phone-list/order-by.pipe.spec.ts} | 5 +- .../app/phone-list/order-by.pipe.ts} | 6 +- .../app/phone-list/phone-filter.pipe.spec.ts} | 7 +- .../app/phone-list/phone-filter.pipe.ts} | 12 +- .../phone-list/phone-list.component.spec.ts} | 24 +- .../app/phone-list/phone-list.component.ts | 27 + .../phone-list.template.html} | 2 - .../ts/ng2_final/app/systemjs.config.js | 2 +- .../{test => e2e-tests}/protractor-conf.js | 12 +- .../{test/e2e => e2e-tests}/scenarios.js | 22 +- .../ts/ng2_final/karma.conf.1.js | 51 ++ .../ng2_final/{test => }/karma_test_shim.js | 24 +- .../ts/ng2_final/package.1.json | 11 +- .../test/unit/phones.service.spec.ts | 16 - .../animations.css => app.animations.css} | 0 .../ts/ng2_initial/app/app.config.ts | 12 + .../app/css => ng2_initial/app}/app.css | 2 +- .../ts/ng2_initial/app/app.module.ts | 29 + .../core/checkmark}/checkmark.filter.spec.ts | 4 +- .../checkmark}/checkmark.filter.ts | 2 +- .../ts/ng2_initial/app/core/core.module.ts | 6 + .../app/core/phone/phone.module.ts | 8 + .../app/core/phone/phone.service.spec.ts | 43 ++ .../app/core/phone/phone.service.ts} | 30 +- .../upgrade-adapter.ts} | 5 +- .../ts/ng2_initial/app/css/.gitkeep | 0 .../ts/ng2_initial/app/index.html | 8 +- .../ts/ng2_initial/app/js/core/core.module.ts | 10 - .../phone_detail/phone_detail.controller.ts | 25 - .../app/js/phone_detail/phone_detail.html | 118 ---- .../js/phone_detail/phone_detail.module.ts | 8 - .../js/phone_list/phone_list.controller.ts | 17 - .../app/js/phone_list/phone_list.module.ts | 5 - .../phone-detail.component.spec.ts | 42 ++ .../phone-detail/phone-detail.component.ts | 29 + .../app/phone-detail/phone-detail.module.ts | 9 + .../phone-detail/phone-detail.template.html | 118 ++++ .../phone-list/phone-list.component.spec.ts | 37 ++ .../app/phone-list/phone-list.component.ts | 22 + .../app/phone-list/phone-list.module.ts | 6 + .../phone-list.template.html} | 6 +- .../ts/ng2_initial/app/systemjs.config.js | 2 +- .../e2e-tests}/protractor-conf.js | 6 +- .../{test/e2e => e2e-tests}/scenarios.js | 19 +- .../ts/ng2_initial/karma.conf.1.js | 50 ++ .../ng2_initial/{test => }/karma_test_shim.js | 24 +- .../ts/ng2_initial/package.1.json | 13 +- .../test/unit/phone_detail.controller.spec.ts | 41 -- .../test/unit/phone_list.controller.spec.ts | 36 -- .../test/unit/phones.service.spec.ts | 16 - .../animations.css => app.animations.css} | 0 .../typescript-conversion/app/app.config.ts | 12 + .../css => typescript-conversion/app}/app.css | 2 +- .../typescript-conversion/app/app.module.ts | 18 + .../core/checkmark}/checkmark.filter.spec.ts | 4 +- .../checkmark}/checkmark.filter.ts | 0 .../app/core/core.module.ts | 6 + .../app/core/phone/phone.module.ts | 5 + .../app/core/phone/phone.service.spec.ts | 47 ++ .../app/core/phone/phone.service.ts | 12 + .../ts/typescript-conversion/app/css/.gitkeep | 0 .../ts/typescript-conversion/app/index.html | 25 +- .../app/js/app.module.ts | 35 -- .../app/js/core/core.module.ts | 9 - .../app/js/core/phone.factory.ts | 10 - .../phone_detail/phone_detail.controller.ts | 14 - .../app/js/phone_detail/phone_detail.html | 118 ---- .../js/phone_detail/phone_detail.module.ts | 8 - .../js/phone_list/phone_list.controller.ts | 10 - .../app/js/phone_list/phone_list.module.ts | 5 - .../phone-detail.component.spec.ts | 38 ++ .../phone-detail/phone-detail.component.ts | 16 + .../app/phone-detail/phone-detail.module.ts | 9 + .../phone-detail/phone-detail.template.html | 118 ++++ .../phone-list/phone-list.component.spec.ts | 37 ++ .../app/phone-list/phone-list.component.ts | 10 + .../app/phone-list/phone-list.module.ts | 6 + .../app/phone-list/phone-list.template.html} | 6 +- .../app/systemjs.config.js | 2 +- .../e2e-tests}/protractor-conf.js | 2 +- .../{test/e2e => e2e-tests}/scenarios.js | 14 +- .../ts/typescript-conversion/karma.conf.1.js | 42 ++ .../{test => }/karma_test_shim.js | 6 +- .../ts/typescript-conversion/package.1.json | 6 +- .../test/jasmine_matchers.d.ts | 6 - .../test/karma.conf.1.js | 38 -- .../test/unit/phone.factory.spec.ts | 15 - .../test/unit/phone_detail.controller.spec.ts | 44 -- .../test/unit/phone_list.controller.spec.ts | 44 -- public/docs/ts/latest/guide/upgrade.jade | 588 ++++++++---------- 185 files changed, 2105 insertions(+), 1927 deletions(-) rename public/docs/_examples/upgrade-phonecat/ts/classes/app/{css/animations.css => app.animations.css} (100%) create mode 100644 public/docs/_examples/upgrade-phonecat/ts/classes/app/app.config.ts rename public/docs/_examples/upgrade-phonecat/ts/{ng2_components/app/css => classes/app}/app.css (100%) create mode 100644 public/docs/_examples/upgrade-phonecat/ts/classes/app/app.module.ts rename public/docs/_examples/upgrade-phonecat/ts/classes/{test/unit => app/core/checkmark}/checkmark.filter.spec.ts (76%) rename public/docs/_examples/upgrade-phonecat/ts/classes/app/{js/core => core/checkmark}/checkmark.filter.ts (100%) create mode 100644 public/docs/_examples/upgrade-phonecat/ts/classes/app/core/core.module.ts create mode 100644 public/docs/_examples/upgrade-phonecat/ts/classes/app/core/phone/phone.module.ts create mode 100644 public/docs/_examples/upgrade-phonecat/ts/classes/app/core/phone/phone.service.spec.ts create mode 100644 public/docs/_examples/upgrade-phonecat/ts/classes/app/core/phone/phone.service.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/classes/app/css/.gitkeep delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/classes/app/js/app.module.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/classes/app/js/core/core.module.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/classes/app/js/core/phone.factory.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_detail/phone_detail.controller.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_detail/phone_detail.html delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_detail/phone_detail.module.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_list/phone_list.controller.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_list/phone_list.module.ts create mode 100644 public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-detail/phone-detail.component.spec.ts create mode 100644 public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-detail/phone-detail.component.ts create mode 100644 public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-detail/phone-detail.module.ts create mode 100644 public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-detail/phone-detail.template.html create mode 100644 public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-list/phone-list.component.spec.ts create mode 100644 public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-list/phone-list.component.ts create mode 100644 public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-list/phone-list.module.ts rename public/docs/_examples/upgrade-phonecat/ts/{typescript-conversion/app/js/phone_list/phone_list.html => classes/app/phone-list/phone-list.template.html} (77%) rename public/docs/_examples/upgrade-phonecat/ts/{typescript-conversion/test => classes/e2e-tests}/protractor-conf.js (94%) rename public/docs/_examples/upgrade-phonecat/ts/classes/{test/e2e => e2e-tests}/scenarios.js (83%) create mode 100644 public/docs/_examples/upgrade-phonecat/ts/classes/karma.conf.1.js rename public/docs/_examples/upgrade-phonecat/ts/classes/{test => }/karma_test_shim.js (87%) delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/classes/test/jasmine_matchers.d.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/classes/test/karma.conf.1.js delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/classes/test/unit/phone.factory.spec.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/classes/test/unit/phone_detail.controller.spec.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/classes/test/unit/phone_list.controller.spec.ts rename public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/{css/animations.css => app.animations.css} (100%) create mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/app.config.ts rename public/docs/_examples/upgrade-phonecat/ts/{typescript-conversion/app/css => ng2_components/app}/app.css (100%) rename public/docs/_examples/upgrade-phonecat/ts/{ng2_initial/app/js => ng2_components/app}/app.module.ts (50%) rename public/docs/_examples/upgrade-phonecat/ts/ng2_components/{test/unit => app/core/checkmark}/checkmark.pipe.spec.ts (87%) rename public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/{js/core => core/checkmark}/checkmark.pipe.ts (54%) create mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/core/core.module.ts create mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/core/phone/phone.module.ts create mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/core/phone/phone.service.spec.ts rename public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/{js/core/phones.service.ts => core/phone/phone.service.ts} (52%) rename public/docs/_examples/upgrade-phonecat/ts/{ng2_final/app/js/core/upgrade_adapter.ts => ng2_components/app/core/upgrade-adapter.ts} (59%) delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/css/.gitkeep delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/app.module.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/core/core.module.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/core/upgrade_adapter.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_detail/phone_detail.module.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/phone_list.component.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/phone_list.module.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/phone_list_without_pipes.component.ts rename public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/{js/phone_detail/phone_detail_without_pipes.component.ts => phone-detail/phone-detail-without-pipes.component.ts} (52%) rename public/docs/_examples/upgrade-phonecat/ts/ng2_components/{test/unit/phone_detail.component.spec.ts => app/phone-detail/phone-detail.component.spec.ts} (76%) rename public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/{js/phone_detail/phone_detail.component.ts => phone-detail/phone-detail.component.ts} (52%) create mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-detail/phone-detail.module.ts rename public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/{js/phone_detail/phone_detail.html => phone-detail/phone-detail.template.html} (100%) rename public/docs/_examples/upgrade-phonecat/ts/ng2_components/{test/unit/order_by.pipe.spec.ts => app/phone-list/order-by.pipe.spec.ts} (89%) rename public/docs/_examples/upgrade-phonecat/ts/{ng2_final/app/js/phone_list/order_by.pipe.ts => ng2_components/app/phone-list/order-by.pipe.ts} (74%) rename public/docs/_examples/upgrade-phonecat/ts/{ng2_final/test/unit/phone_filter.pipe.spec.ts => ng2_components/app/phone-list/phone-filter.pipe.spec.ts} (80%) rename public/docs/_examples/upgrade-phonecat/ts/{ng2_final/app/js/phone_list/phone_filter.pipe.ts => ng2_components/app/phone-list/phone-filter.pipe.ts} (55%) rename public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/{js/phone_list/phone_list_without_async.html => phone-list/phone-list-without-async.template.html} (99%) create mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list-without-pipes.component.ts rename public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/{js/phone_list/phone_list_without_pipes.html => phone-list/phone-list-without-pipes.template.html} (99%) rename public/docs/_examples/upgrade-phonecat/ts/ng2_components/{test/unit/phone_list.component.spec.ts => app/phone-list/phone-list.component.spec.ts} (79%) create mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list.component.ts create mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list.module.ts rename public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/{js/phone_list/phone_list.html => phone-list/phone-list.template.html} (99%) rename public/docs/_examples/upgrade-phonecat/ts/ng2_components/{test => e2e-tests}/protractor-conf.js (94%) rename public/docs/_examples/upgrade-phonecat/ts/ng2_components/{test/e2e => e2e-tests}/scenarios.js (81%) create mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_components/karma.conf.1.js rename public/docs/_examples/upgrade-phonecat/ts/ng2_components/{test => }/karma_test_shim.js (85%) delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/unit/phones.service.spec.ts rename public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/{js => }/app.component.ts (75%) rename public/docs/_examples/upgrade-phonecat/ts/ng2_final/{test/unit => app/core/checkmark}/checkmark.pipe.spec.ts (80%) rename public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/{js/core => core/checkmark}/checkmark.pipe.ts (53%) create mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/core/phone/phone.service.spec.ts rename public/docs/_examples/upgrade-phonecat/ts/{ng2_initial/app/js/core/phones.service.ts => ng2_final/app/core/phone/phone.service.ts} (75%) delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/css/.gitkeep delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/phone_detail/phone_detail.component.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/phone_list/phone_list.component.ts rename public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/{js => }/main.ts (91%) rename public/docs/_examples/upgrade-phonecat/ts/ng2_final/{test/unit/phone_detail.component.spec.ts => app/phone-detail/phone-detail.component.spec.ts} (77%) create mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-detail/phone-detail.component.ts rename public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/{js/phone_detail/phone_detail.html => phone-detail/phone-detail.template.html} (100%) rename public/docs/_examples/upgrade-phonecat/ts/ng2_final/{test/unit/order_by.pipe.spec.ts => app/phone-list/order-by.pipe.spec.ts} (83%) rename public/docs/_examples/upgrade-phonecat/ts/{ng2_components/app/js/phone_list/order_by.pipe.ts => ng2_final/app/phone-list/order-by.pipe.ts} (74%) rename public/docs/_examples/upgrade-phonecat/ts/{ng2_components/test/unit/phone_filter.pipe.spec.ts => ng2_final/app/phone-list/phone-filter.pipe.spec.ts} (84%) rename public/docs/_examples/upgrade-phonecat/ts/{ng2_components/app/js/phone_list/phone_filter.pipe.ts => ng2_final/app/phone-list/phone-filter.pipe.ts} (56%) rename public/docs/_examples/upgrade-phonecat/ts/ng2_final/{test/unit/phone_list.component.spec.ts => app/phone-list/phone-list.component.spec.ts} (81%) create mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-list/phone-list.component.ts rename public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/{js/phone_list/phone_list.html => phone-list/phone-list.template.html} (99%) rename public/docs/_examples/upgrade-phonecat/ts/ng2_final/{test => e2e-tests}/protractor-conf.js (85%) rename public/docs/_examples/upgrade-phonecat/ts/ng2_final/{test/e2e => e2e-tests}/scenarios.js (86%) create mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_final/karma.conf.1.js rename public/docs/_examples/upgrade-phonecat/ts/ng2_final/{test => }/karma_test_shim.js (85%) delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/unit/phones.service.spec.ts rename public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/{css/animations.css => app.animations.css} (100%) create mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/app.config.ts rename public/docs/_examples/upgrade-phonecat/ts/{classes/app/css => ng2_initial/app}/app.css (97%) create mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/app.module.ts rename public/docs/_examples/upgrade-phonecat/ts/{typescript-conversion/test/unit => ng2_initial/app/core/checkmark}/checkmark.filter.spec.ts (76%) rename public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/{js/core => core/checkmark}/checkmark.filter.ts (71%) create mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/core/core.module.ts create mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/core/phone/phone.module.ts create mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/core/phone/phone.service.spec.ts rename public/docs/_examples/upgrade-phonecat/ts/{ng2_final/app/js/core/phones.service.ts => ng2_initial/app/core/phone/phone.service.ts} (52%) rename public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/{js/core/upgrade_adapter.ts => core/upgrade-adapter.ts} (59%) delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/css/.gitkeep delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/core/core.module.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/phone_detail/phone_detail.controller.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/phone_detail/phone_detail.html delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/phone_detail/phone_detail.module.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/phone_list/phone_list.controller.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/phone_list/phone_list.module.ts create mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-detail/phone-detail.component.spec.ts create mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-detail/phone-detail.component.ts create mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-detail/phone-detail.module.ts create mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-detail/phone-detail.template.html create mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-list/phone-list.component.spec.ts create mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-list/phone-list.component.ts create mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-list/phone-list.module.ts rename public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/{js/phone_list/phone_list.html => phone-list/phone-list.template.html} (77%) rename public/docs/_examples/upgrade-phonecat/ts/{classes/test => ng2_initial/e2e-tests}/protractor-conf.js (86%) rename public/docs/_examples/upgrade-phonecat/ts/ng2_initial/{test/e2e => e2e-tests}/scenarios.js (79%) create mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_initial/karma.conf.1.js rename public/docs/_examples/upgrade-phonecat/ts/ng2_initial/{test => }/karma_test_shim.js (85%) delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_initial/test/unit/phone_detail.controller.spec.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_initial/test/unit/phone_list.controller.spec.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/ng2_initial/test/unit/phones.service.spec.ts rename public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/{css/animations.css => app.animations.css} (100%) create mode 100644 public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/app.config.ts rename public/docs/_examples/upgrade-phonecat/ts/{ng2_initial/app/css => typescript-conversion/app}/app.css (97%) create mode 100644 public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/app.module.ts rename public/docs/_examples/upgrade-phonecat/ts/{ng2_initial/test/unit => typescript-conversion/app/core/checkmark}/checkmark.filter.spec.ts (76%) rename public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/{js/core => core/checkmark}/checkmark.filter.ts (100%) create mode 100644 public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/core/core.module.ts create mode 100644 public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/core/phone/phone.module.ts create mode 100644 public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/core/phone/phone.service.spec.ts create mode 100644 public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/core/phone/phone.service.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/css/.gitkeep delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/app.module.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/core/core.module.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/core/phone.factory.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/phone_detail/phone_detail.controller.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/phone_detail/phone_detail.html delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/phone_detail/phone_detail.module.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/phone_list/phone_list.controller.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/phone_list/phone_list.module.ts create mode 100644 public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-detail/phone-detail.component.spec.ts create mode 100644 public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-detail/phone-detail.component.ts create mode 100644 public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-detail/phone-detail.module.ts create mode 100644 public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-detail/phone-detail.template.html create mode 100644 public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-list/phone-list.component.spec.ts create mode 100644 public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-list/phone-list.component.ts create mode 100644 public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-list/phone-list.module.ts rename public/docs/_examples/upgrade-phonecat/ts/{classes/app/js/phone_list/phone_list.html => typescript-conversion/app/phone-list/phone-list.template.html} (77%) rename public/docs/_examples/upgrade-phonecat/ts/{ng2_initial/test => typescript-conversion/e2e-tests}/protractor-conf.js (94%) rename public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/{test/e2e => e2e-tests}/scenarios.js (83%) create mode 100644 public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/karma.conf.1.js rename public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/{test => }/karma_test_shim.js (87%) delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/jasmine_matchers.d.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/karma.conf.1.js delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/unit/phone.factory.spec.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/unit/phone_detail.controller.spec.ts delete mode 100644 public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/unit/phone_list.controller.spec.ts diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/css/animations.css b/public/docs/_examples/upgrade-phonecat/ts/classes/app/app.animations.css similarity index 100% rename from public/docs/_examples/upgrade-phonecat/ts/classes/app/css/animations.css rename to public/docs/_examples/upgrade-phonecat/ts/classes/app/app.animations.css diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/app.config.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/app.config.ts new file mode 100644 index 0000000000..9b99261074 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/app.config.ts @@ -0,0 +1,12 @@ +// #docregion +export default ['$routeProvider', + function config($routeProvider) { + $routeProvider. + when('/phones', { + template: '' + }). + when('/phones/:phoneId', { + template: '' + }). + otherwise('/phones'); +}]; diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/css/app.css b/public/docs/_examples/upgrade-phonecat/ts/classes/app/app.css similarity index 100% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/css/app.css rename to public/docs/_examples/upgrade-phonecat/ts/classes/app/app.css diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/app.module.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/app.module.ts new file mode 100644 index 0000000000..d4e0e8b25c --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/app.module.ts @@ -0,0 +1,18 @@ +// #docregion pre-bootstrap +import core from './core/core.module'; +import phoneList from './phone-list/phone-list.module'; +import phoneDetail from './phone-detail/phone-detail.module'; +import appConfig from './app.config'; + +angular.module('phonecatApp', [ + 'ngAnimate', + 'ngRoute', + core.name, + phoneList.name, + phoneDetail.name +]).config(appConfig); + +// #enddocregion pre-bootstrap +// #docregion bootstrap +angular.bootstrap(document.documentElement, ['phonecatApp']); +// #enddocregion bootstrap diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/test/unit/checkmark.filter.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/core/checkmark/checkmark.filter.spec.ts similarity index 76% rename from public/docs/_examples/upgrade-phonecat/ts/classes/test/unit/checkmark.filter.spec.ts rename to public/docs/_examples/upgrade-phonecat/ts/classes/app/core/checkmark/checkmark.filter.spec.ts index bae35e6875..6704c74999 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/classes/test/unit/checkmark.filter.spec.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/core/checkmark/checkmark.filter.spec.ts @@ -1,10 +1,10 @@ // #docregion top -import '../../app/js/core/core.module'; +import '../core.module'; // #enddocregion top describe('checkmarkFilter', function() { - beforeEach(angular.mock.module('phonecat.core')); + beforeEach(angular.mock.module('core')); it('should convert boolean values to unicode checkmark or cross', inject(function(checkmarkFilter) { diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/core/checkmark.filter.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/core/checkmark/checkmark.filter.ts similarity index 100% rename from public/docs/_examples/upgrade-phonecat/ts/classes/app/js/core/checkmark.filter.ts rename to public/docs/_examples/upgrade-phonecat/ts/classes/app/core/checkmark/checkmark.filter.ts diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/core/core.module.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/core/core.module.ts new file mode 100644 index 0000000000..041f56ea79 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/core/core.module.ts @@ -0,0 +1,6 @@ +// #docregion +import checkmarkFilter from './checkmark/checkmark.filter'; +import phone from './phone/phone.module'; + +export default angular.module('core', [phone.name]) + .filter('checkmark', checkmarkFilter); diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/core/phone/phone.module.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/core/phone/phone.module.ts new file mode 100644 index 0000000000..d60c3c9a07 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/core/phone/phone.module.ts @@ -0,0 +1,5 @@ +// #docregion +import Phone from './phone.service'; + +export default angular.module('core.phone', ['ngResource']) + .factory('Phone', Phone); diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/core/phone/phone.service.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/core/phone/phone.service.spec.ts new file mode 100644 index 0000000000..269ce500e9 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/core/phone/phone.service.spec.ts @@ -0,0 +1,47 @@ +// #docregion top +import './phone.module'; +// #enddocregion top + +'use strict'; + +describe('Phone', function() { + var $httpBackend; + var Phone; + var phonesData = [ + {name: 'Phone X'}, + {name: 'Phone Y'}, + {name: 'Phone Z'} + ]; + + // Add a custom equality tester before each test + beforeEach(function() { + jasmine.addCustomEqualityTester(angular.equals); + }); + + // Load the module that contains the `Phone` service before each test + beforeEach(angular.mock.module('core.phone')); + + // Instantiate the service and "train" `$httpBackend` before each test + beforeEach(inject(function(_$httpBackend_, _Phone_) { + $httpBackend = _$httpBackend_; + $httpBackend.expectGET('phones/phones.json').respond(phonesData); + + Phone = _Phone_; + })); + + // Verify that there are no outstanding expectations or requests after each test + afterEach(function () { + $httpBackend.verifyNoOutstandingExpectation(); + $httpBackend.verifyNoOutstandingRequest(); + }); + + it('should fetch the phones data from `/phones/phones.json`', function() { + var phones = Phone.query(); + + expect(phones).toEqual([]); + + $httpBackend.flush(); + expect(phones).toEqual(phonesData); + }); + +}); diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/core/phone/phone.service.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/core/phone/phone.service.ts new file mode 100644 index 0000000000..861ff78832 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/core/phone/phone.service.ts @@ -0,0 +1,12 @@ +// #docregion +export default ['$resource', + function Phone($resource) { + return $resource('phones/:phoneId.json', {}, { + query: { + method: 'GET', + params: {phoneId: 'phones'}, + isArray: true + } + }); + } +]; diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/css/.gitkeep b/public/docs/_examples/upgrade-phonecat/ts/classes/app/css/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/index.html b/public/docs/_examples/upgrade-phonecat/ts/classes/app/index.html index db01afac1c..096a0ef1bd 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/classes/app/index.html +++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/index.html @@ -4,8 +4,8 @@ Google Phone Gallery - - + + @@ -15,7 +15,7 @@ diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/app.module.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/app.module.ts deleted file mode 100644 index 01e3328c1e..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/app.module.ts +++ /dev/null @@ -1,35 +0,0 @@ -// #docregion pre-bootstrap - -import core from './core/core.module'; -import phoneList from './phone_list/phone_list.module'; -import phoneDetail from './phone_detail/phone_detail.module'; - -angular.module('phonecatApp', [ - 'ngRoute', - core.name, - phoneList.name, - phoneDetail.name -]).config(configure); - -configure.$inject = ['$routeProvider']; - -function configure($routeProvider) { - $routeProvider. - when('/phones', { - templateUrl: 'js/phone_list/phone_list.html', - controller: 'PhoneListCtrl', - controllerAs: 'vm' - }). - when('/phones/:phoneId', { - templateUrl: 'js/phone_detail/phone_detail.html', - controller: 'PhoneDetailCtrl', - controllerAs: 'vm' - }). - otherwise({ - redirectTo: '/phones' - }); -} -// #enddocregion pre-bootstrap -// #docregion bootstrap -angular.bootstrap(document.documentElement, ['phonecatApp']); -// #enddocregion bootstrap diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/core/core.module.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/core/core.module.ts deleted file mode 100644 index c20ce33683..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/core/core.module.ts +++ /dev/null @@ -1,9 +0,0 @@ -// #docregion -import Phone from './phone.factory'; -import checkmarkFilter from './checkmark.filter'; - -export default angular.module('phonecat.core', [ - 'ngResource' - ]) - .factory('Phone', Phone) - .filter('checkmark', checkmarkFilter); diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/core/phone.factory.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/core/phone.factory.ts deleted file mode 100644 index a8492b29fc..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/core/phone.factory.ts +++ /dev/null @@ -1,10 +0,0 @@ -// #docregion -Phone.$inject = ['$resource']; - -function Phone($resource) { - return $resource('phones/:phoneId.json', {}, { - query: {method:'GET', params:{phoneId:'phones'}, isArray:true} - }); -} - -export default Phone; diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_detail/phone_detail.controller.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_detail/phone_detail.controller.ts deleted file mode 100644 index c5b96b6f08..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_detail/phone_detail.controller.ts +++ /dev/null @@ -1,22 +0,0 @@ -// #docregion -interface PhoneRouteParams { - phoneId: string -} - -class PhoneDetailCtrl { - phone:any; - mainImageUrl:string; - constructor($routeParams:PhoneRouteParams, Phone) { - this.phone = Phone.get({phoneId: $routeParams.phoneId}, (phone) => - this.mainImageUrl = phone.images[0] - ); - } - - setImage(url:string) { - this.mainImageUrl = url; - } -} - -PhoneDetailCtrl.$inject = ['$routeParams', 'Phone']; - -export default PhoneDetailCtrl; diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_detail/phone_detail.html b/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_detail/phone_detail.html deleted file mode 100644 index 954c65c2cd..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_detail/phone_detail.html +++ /dev/null @@ -1,118 +0,0 @@ -
- -
- -

{{vm.phone.name}}

- -

{{vm.phone.description}}

- - - - diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_detail/phone_detail.module.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_detail/phone_detail.module.ts deleted file mode 100644 index 16e7ac0baf..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_detail/phone_detail.module.ts +++ /dev/null @@ -1,8 +0,0 @@ -// #docregion -import PhoneDetailCtrl from './phone_detail.controller'; - -export default angular.module('phonecat.detail', [ - 'ngRoute', - 'phonecat.core' - ]) - .controller('PhoneDetailCtrl', PhoneDetailCtrl); diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_list/phone_list.controller.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_list/phone_list.controller.ts deleted file mode 100644 index f1a5beb808..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_list/phone_list.controller.ts +++ /dev/null @@ -1,14 +0,0 @@ -// #docregion -class PhoneListCtrl { - phones:any[]; - orderProp:string; - query:string; - constructor(Phone) { - this.phones = Phone.query(); - this.orderProp = 'age'; - } -} - -PhoneListCtrl.$inject = ['Phone']; - -export default PhoneListCtrl; diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_list/phone_list.module.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_list/phone_list.module.ts deleted file mode 100644 index 758b937927..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_list/phone_list.module.ts +++ /dev/null @@ -1,5 +0,0 @@ -// #docregion -import PhoneListCtrl from './phone_list.controller'; - -export default angular.module('phonecat.list', ['phonecat.core']) - .controller('PhoneListCtrl', PhoneListCtrl); diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-detail/phone-detail.component.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-detail/phone-detail.component.spec.ts new file mode 100644 index 0000000000..4d0b3c0cb7 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-detail/phone-detail.component.spec.ts @@ -0,0 +1,38 @@ +// #docregion top +import './phone-detail.module'; +// #enddocregion top + +describe('phoneDetail', function(){ + + // Load the module that contains the `phoneDetail` component before each test + beforeEach(angular.mock.module('phoneDetail')); + + // Test the controller + describe('PhoneDetailController', function() { + var $httpBackend, ctrl; + var xyzPhoneData = { + name: 'phone xyz', + images: ['image/url1.png', 'image/url2.png'] + }; + + beforeEach(inject(function($componentController, _$httpBackend_, $routeParams) { + $httpBackend = _$httpBackend_; + $httpBackend.expectGET('phones/xyz.json').respond(xyzPhoneData); + + $routeParams.phoneId = 'xyz'; + + ctrl = $componentController('phoneDetail', {$scope: {}}); + })); + + it('should fetch the phone details', function() { + jasmine.addCustomEqualityTester(angular.equals); + + expect(ctrl.phone).toEqual({}); + + $httpBackend.flush(); + expect(ctrl.phone).toEqual(xyzPhoneData); + }); + + }); + +}); diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-detail/phone-detail.component.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-detail/phone-detail.component.ts new file mode 100644 index 0000000000..5e3a35a3d4 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-detail/phone-detail.component.ts @@ -0,0 +1,26 @@ +// #docregion +interface PhoneRouteParams { + phoneId: string +} + +class PhoneDetailController { + phone:any; + mainImageUrl:string; + + static $inject = ['$routeParams', 'Phone']; + constructor($routeParams:PhoneRouteParams, Phone) { + this.phone = Phone.get({phoneId: $routeParams.phoneId}, phone => { + this.setImage(phone.images[0]); + }); + } + + setImage(imageUrl) { + this.mainImageUrl = imageUrl; + } + +} + +export default { + templateUrl: 'phone-detail/phone-detail.template.html', + controller: PhoneDetailController +}; diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-detail/phone-detail.module.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-detail/phone-detail.module.ts new file mode 100644 index 0000000000..d9e95c0761 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-detail/phone-detail.module.ts @@ -0,0 +1,9 @@ +// #docregion +import phoneDetail from './phone-detail.component'; +import phone from '../core/phone/phone.module'; + +export default angular.module('phoneDetail', [ + 'ngRoute', + phone.name + ]) + .component('phoneDetail', phoneDetail); diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-detail/phone-detail.template.html b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-detail/phone-detail.template.html new file mode 100644 index 0000000000..019ccf45c7 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-detail/phone-detail.template.html @@ -0,0 +1,118 @@ +
+ +
+ +

{{$ctrl.phone.name}}

+ +

{{$ctrl.phone.description}}

+ + + + diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-list/phone-list.component.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-list/phone-list.component.spec.ts new file mode 100644 index 0000000000..f0cf9987f9 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-list/phone-list.component.spec.ts @@ -0,0 +1,37 @@ +// #docregion top +import './phone-list.module'; +// #enddocregion top + +describe('phoneList', function() { + + // Load the module that contains the `phoneList` component before each test + beforeEach(angular.mock.module('phoneList')); + + // Test the controller + describe('PhoneListController', function() { + var $httpBackend, ctrl; + + beforeEach(inject(function($componentController, _$httpBackend_) { + $httpBackend = _$httpBackend_; + $httpBackend.expectGET('phones/phones.json') + .respond([{name: 'Nexus S'}, {name: 'Motorola DROID'}]); + + ctrl = $componentController('phoneList', {$scope: {}}); + })); + + it('should create a `phones` model with 2 phones fetched with `$http`', function() { + jasmine.addCustomEqualityTester(angular.equals); + + expect(ctrl.phones).toEqual([]); + + $httpBackend.flush(); + expect(ctrl.phones).toEqual([{name: 'Nexus S'}, {name: 'Motorola DROID'}]); + }); + + it('should set a default value for the `orderProp` model', function() { + expect(ctrl.orderProp).toBe('age'); + }); + + }); + +}); diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-list/phone-list.component.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-list/phone-list.component.ts new file mode 100644 index 0000000000..1d3f28e23a --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-list/phone-list.component.ts @@ -0,0 +1,18 @@ +// #docregion +class PhoneListController { + phones:any[]; + orderProp:string; + query:string; + + static $inject = ['Phone']; + constructor(Phone) { + this.phones = Phone.query(); + this.orderProp = 'age'; + } + +} + +export default { + templateUrl: 'phone-list/phone-list.template.html', + controller: PhoneListController +}; diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-list/phone-list.module.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-list/phone-list.module.ts new file mode 100644 index 0000000000..feae92f9af --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-list/phone-list.module.ts @@ -0,0 +1,6 @@ +// #docregion +import phoneList from './phone-list.component'; +import phone from '../core/phone/phone.module'; + +export default angular.module('phoneList', [phone.name]) + .component('phoneList', phoneList); diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/phone_list/phone_list.html b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-list/phone-list.template.html similarity index 77% rename from public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/phone_list/phone_list.html rename to public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-list/phone-list.template.html index 471f474e89..95283ee032 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/phone_list/phone_list.html +++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-list/phone-list.template.html @@ -3,9 +3,9 @@
- Search: + Search: Sort by: - @@ -15,7 +15,7 @@
    -
  • {{phone.name}} diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/systemjs.config.js b/public/docs/_examples/upgrade-phonecat/ts/classes/app/systemjs.config.js index 9a46070388..089b9c0d8a 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/classes/app/systemjs.config.js +++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/systemjs.config.js @@ -5,7 +5,7 @@ var pkgPath = global.packagePath || '../node_modules/'; // path to packages System.config({ packages: { - 'js': { defaultExtension: 'js' }, + './': { defaultExtension: 'js' }, } }); diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/protractor-conf.js b/public/docs/_examples/upgrade-phonecat/ts/classes/e2e-tests/protractor-conf.js similarity index 94% rename from public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/protractor-conf.js rename to public/docs/_examples/upgrade-phonecat/ts/classes/e2e-tests/protractor-conf.js index 118c7b9ec2..a4099af352 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/protractor-conf.js +++ b/public/docs/_examples/upgrade-phonecat/ts/classes/e2e-tests/protractor-conf.js @@ -2,7 +2,7 @@ exports.config = { allScriptsTimeout: 11000, specs: [ - 'e2e/*.js' + '*.js' ], capabilities: { diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/test/e2e/scenarios.js b/public/docs/_examples/upgrade-phonecat/ts/classes/e2e-tests/scenarios.js similarity index 83% rename from public/docs/_examples/upgrade-phonecat/ts/classes/test/e2e/scenarios.js rename to public/docs/_examples/upgrade-phonecat/ts/classes/e2e-tests/scenarios.js index 5a505b5dae..f5774c189a 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/classes/test/e2e/scenarios.js +++ b/public/docs/_examples/upgrade-phonecat/ts/classes/e2e-tests/scenarios.js @@ -20,8 +20,8 @@ describe('PhoneCat App', function() { it('should filter the phone list as a user types into the search box', function() { - var phoneList = element.all(by.repeater('phone in vm.phones')); - var query = element(by.model('vm.query')); + var phoneList = element.all(by.repeater('phone in $ctrl.phones')); + var query = element(by.model('$ctrl.query')); expect(phoneList.count()).toBe(20); @@ -36,8 +36,8 @@ describe('PhoneCat App', function() { it('should be possible to control phone order via the drop down select box', function() { - var phoneNameColumn = element.all(by.repeater('phone in vm.phones').column('phone.name')); - var query = element(by.model('vm.query')); + var phoneNameColumn = element.all(by.repeater('phone in $ctrl.phones').column('phone.name')); + var query = element(by.model('$ctrl.query')); function getNames() { return phoneNameColumn.map(function(elm) { @@ -52,7 +52,7 @@ describe('PhoneCat App', function() { "MOTOROLA XOOM\u2122" ]); - element(by.model('vm.orderProp')).element(by.css('option[value="name"]')).click(); + element(by.model('$ctrl.orderProp')).element(by.css('option[value="name"]')).click(); expect(getNames()).toEqual([ "MOTOROLA XOOM\u2122", @@ -62,7 +62,7 @@ describe('PhoneCat App', function() { it('should render phone specific links', function() { - var query = element(by.model('vm.query')); + var query = element(by.model('$ctrl.query')); query.sendKeys('nexus'); element.all(by.css('.phones li a')).first().click(); browser.getLocationAbsUrl().then(function(url) { @@ -80,7 +80,7 @@ describe('PhoneCat App', function() { it('should display nexus-s page', function() { - expect(element(by.binding('vm.phone.name')).getText()).toBe('Nexus S'); + expect(element(by.binding('$ctrl.phone.name')).getText()).toBe('Nexus S'); }); diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/karma.conf.1.js b/public/docs/_examples/upgrade-phonecat/ts/classes/karma.conf.1.js new file mode 100644 index 0000000000..5124a02418 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/classes/karma.conf.1.js @@ -0,0 +1,42 @@ +module.exports = function(config){ + config.set({ + + basePath: './app', + + // #docregion files + files : [ + 'bower_components/angular/angular.js', + 'bower_components/angular-route/angular-route.js', + 'bower_components/angular-resource/angular-resource.js', + 'bower_components/angular-animate/angular-animate.js', + 'bower_components/angular-mocks/angular-mocks.js', + '../node_modules/systemjs/dist/system.src.js', + '../karma_test_shim.js', + {pattern: '**/*.module.js', included: false, watched: true}, + {pattern: '*!(.module|.spec).js', included: false, watched: true}, + {pattern: '!(bower_components)/**/*!(.module|.spec).js', included: false, watched: true}, + {pattern: '**/*.spec.js', included: false, watched: true} + ], + // #enddocregion files + + autoWatch : true, + + frameworks: ['jasmine'], + + browsers : ['Chrome', 'Firefox'], + + plugins : [ + 'karma-chrome-launcher', + 'karma-firefox-launcher', + 'karma-jasmine' + ], + + junitReporter : { + outputFile: 'test_out/unit.xml', + suite: 'unit' + }, + + logLevel: config.LOG_DEBUG + + }); +}; diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/test/karma_test_shim.js b/public/docs/_examples/upgrade-phonecat/ts/classes/karma_test_shim.js similarity index 87% rename from public/docs/_examples/upgrade-phonecat/ts/classes/test/karma_test_shim.js rename to public/docs/_examples/upgrade-phonecat/ts/classes/karma_test_shim.js index 15cbee5d7d..d03229f0f5 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/classes/test/karma_test_shim.js +++ b/public/docs/_examples/upgrade-phonecat/ts/classes/karma_test_shim.js @@ -5,7 +5,7 @@ __karma__.loaded = function() {}; System.config({ packages: { - 'base/app/js': { + 'base': { defaultExtension: false, format: 'register', map: Object.keys(window.__karma__.files). @@ -13,7 +13,7 @@ System.config({ reduce(function createPathRecords(pathsMapping, appPath) { // creates local module name mapping to global path with karma's fingerprint in path, e.g.: // './hero.service': '/base/src/app/hero.service.js?f4523daf879cfb7310ef6242682ccf10b2041b3e' - var moduleName = appPath.replace(/^\/base\/app\/js\//, './').replace(/\.js$/, ''); + var moduleName = appPath.replace(/^\/base\//, './').replace(/\.js$/, ''); pathsMapping[moduleName] = appPath + '?' + window.__karma__.files[appPath] return pathsMapping; }, {}) @@ -36,7 +36,7 @@ Promise.all( }); function onlyAppFiles(filePath) { - return /^\/base\/app\/js\/.*\.js$/.test(filePath) + return /^\/base\/.*\.(?!\.spec\.)js$/.test(filePath) } function onlySpecFiles(path) { diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/package.1.json b/public/docs/_examples/upgrade-phonecat/ts/classes/package.1.json index 0b7b72bf3e..6c8c0c8a0a 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/classes/package.1.json +++ b/public/docs/_examples/upgrade-phonecat/ts/classes/package.1.json @@ -9,34 +9,29 @@ "systemjs": "0.19.25" }, "devDependencies": { + "bower": "^1.3.1", + "http-server": "^0.6.1", "karma": "^0.12.16", "karma-chrome-launcher": "^0.1.4", "karma-firefox-launcher": "^0.1.3", "karma-jasmine": "~0.3.7", "protractor": "^3.0.0", - "http-server": "^0.6.1", - "tmp": "0.0.23", - "bower": "^1.3.1", "shelljs": "^0.2.6", - "typescript": "1.8.9", + "tmp": "0.0.23", + "typescript": "^1.8.9", "typings": "^0.7.12" }, "scripts": { "postinstall": "bower install", - "prestart": "npm install", "start": "http-server -a 0.0.0.0 -p 8000", - "pretest": "npm install", - "test": "node node_modules/karma/bin/karma start test/karma.conf.js", - "test-single-run": "node node_modules/karma/bin/karma start test/karma.conf.js --single-run", - + "test": "node node_modules/karma/bin/karma start karma.conf.js", + "test-single-run": "node node_modules/karma/bin/karma start karma.conf.js --single-run", "preupdate-webdriver": "npm install", "update-webdriver": "webdriver-manager update", - "preprotractor": "npm run update-webdriver", - "protractor": "protractor test/protractor-conf.js", - + "protractor": "protractor e2e-tests/protractor-conf.js", "typings": "typings", "tsc": "tsc -p . -w" } diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/test/jasmine_matchers.d.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/test/jasmine_matchers.d.ts deleted file mode 100644 index 6d24879775..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/classes/test/jasmine_matchers.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// #docregion -declare module jasmine { - interface Matchers { - toEqualData(expected: any):boolean; - } -} diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/test/karma.conf.1.js b/public/docs/_examples/upgrade-phonecat/ts/classes/test/karma.conf.1.js deleted file mode 100644 index 8f2e7d178f..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/classes/test/karma.conf.1.js +++ /dev/null @@ -1,38 +0,0 @@ -module.exports = function(config){ - config.set({ - - basePath : '..', - - // #docregion files - files : [ - 'app/bower_components/angular/angular.js', - 'app/bower_components/angular-route/angular-route.js', - 'app/bower_components/angular-resource/angular-resource.js', - 'app/bower_components/angular-animate/angular-animate.js', - 'app/bower_components/angular-mocks/angular-mocks.js', - 'node_modules/systemjs/dist/system.src.js', - 'test/karma_test_shim.js', - {pattern: 'app/js/**/*.js', included: false, watched: true}, - {pattern: 'test/unit/**/*.js', included: false, watched: true} - ], - // #enddocregion files - - autoWatch : true, - - frameworks: ['jasmine'], - - browsers : ['Chrome', 'Firefox'], - - plugins : [ - 'karma-chrome-launcher', - 'karma-firefox-launcher', - 'karma-jasmine' - ], - - junitReporter : { - outputFile: 'test_out/unit.xml', - suite: 'unit' - } - - }); -}; diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/test/unit/phone.factory.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/test/unit/phone.factory.spec.ts deleted file mode 100644 index d7c95d347e..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/classes/test/unit/phone.factory.spec.ts +++ /dev/null @@ -1,15 +0,0 @@ -// #docregion top -import '../../app/js/core/core.module'; -// #enddocregion top - -describe('phoneFactory', function() { - - // load modules - beforeEach(angular.mock.module('phonecat.core')); - - // Test service availability - it('check the existence of Phone factory', inject(function(Phone) { - expect(Phone).toBeDefined(); - })); - -}); diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/test/unit/phone_detail.controller.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/test/unit/phone_detail.controller.spec.ts deleted file mode 100644 index 02a3e20240..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/classes/test/unit/phone_detail.controller.spec.ts +++ /dev/null @@ -1,44 +0,0 @@ -// #docregion top -import '../../app/js/phone_detail/phone_detail.module'; -// #enddocregion top - -describe('PhoneDetailCtrl', function(){ - var scope, $httpBackend, ctrl, - xyzPhoneData = function() { - return { - name: 'phone xyz', - images: ['image/url1.png', 'image/url2.png'] - } - }; - - beforeEach(angular.mock.module('phonecat.detail')); - - beforeEach(function(){ - jasmine.addMatchers({ - toEqualData: function(util, customEqualityTesters) { - return { - compare: function(actual, expected) { - return {pass: angular.equals(actual, expected)}; - } - }; - } - }); - }); - - beforeEach(inject(function(_$httpBackend_, $rootScope, $routeParams, $controller) { - $httpBackend = _$httpBackend_; - $httpBackend.expectGET('phones/xyz.json').respond(xyzPhoneData()); - - $routeParams.phoneId = 'xyz'; - scope = $rootScope.$new(); - ctrl = $controller('PhoneDetailCtrl', {$scope: scope}); - })); - - - it('should fetch phone detail', function() { - expect(ctrl.phone).toEqualData({}); - $httpBackend.flush(); - - expect(ctrl.phone).toEqualData(xyzPhoneData()); - }); -}); diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/test/unit/phone_list.controller.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/test/unit/phone_list.controller.spec.ts deleted file mode 100644 index efec5d5f08..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/classes/test/unit/phone_list.controller.spec.ts +++ /dev/null @@ -1,44 +0,0 @@ -// #docregion top -import '../../app/js/phone_list/phone_list.module'; -// #enddocregion top - -describe('PhoneListCtrl', function(){ - var scope, ctrl, $httpBackend; - - beforeEach(angular.mock.module('phonecat.list')); - - beforeEach(function(){ - jasmine.addMatchers({ - toEqualData: function(util, customEqualityTesters) { - return { - compare: function(actual, expected) { - return {pass: angular.equals(actual, expected)}; - } - }; - } - }); - }); - - beforeEach(inject(function(_$httpBackend_, $rootScope, $controller) { - $httpBackend = _$httpBackend_; - $httpBackend.expectGET('phones/phones.json'). - respond([{name: 'Nexus S'}, {name: 'Motorola DROID'}]); - - scope = $rootScope.$new(); - ctrl = $controller('PhoneListCtrl', {$scope: scope}); - })); - - - it('should create "phones" model with 2 phones fetched from xhr', function() { - expect(ctrl.phones).toEqualData([]); - $httpBackend.flush(); - - expect(ctrl.phones).toEqualData( - [{name: 'Nexus S'}, {name: 'Motorola DROID'}]); - }); - - - it('should set the default value of orderProp model', function() { - expect(ctrl.orderProp).toBe('age'); - }); -}); diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/css/animations.css b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/app.animations.css similarity index 100% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/css/animations.css rename to public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/app.animations.css diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/app.config.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/app.config.ts new file mode 100644 index 0000000000..9b99261074 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/app.config.ts @@ -0,0 +1,12 @@ +// #docregion +export default ['$routeProvider', + function config($routeProvider) { + $routeProvider. + when('/phones', { + template: '' + }). + when('/phones/:phoneId', { + template: '' + }). + otherwise('/phones'); +}]; diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/css/app.css b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/app.css similarity index 100% rename from public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/css/app.css rename to public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/app.css diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/app.module.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/app.module.ts similarity index 50% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/app.module.ts rename to public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/app.module.ts index 974836e396..10cec2d666 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/app.module.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/app.module.ts @@ -1,45 +1,33 @@ // #docregion adapter-import import { UpgradeAdapter } from '@angular/upgrade'; // #enddocregion adapter-import -// #docregion adapter-state-import -import upgradeAdapter from './core/upgrade_adapter'; -// #enddocregion adapter-state-import // #docregion http-import import { HTTP_PROVIDERS } from '@angular/http'; // #enddocregion http-import -import core from './core/core.module'; -import phoneList from './phone_list/phone_list.module'; -import phoneDetail from './phone_detail/phone_detail.module'; +// #docregion adapter-state-import +import upgradeAdapter from './core/upgrade-adapter'; +// #enddocregion adapter-state-import -// #docregion add-http-providers -upgradeAdapter.addProvider(HTTP_PROVIDERS); -// #enddocregion add-http-providers +import core from './core/core.module'; +import phoneList from './phone-list/phone-list.module'; +import phoneDetail from './phone-detail/phone-detail.module'; +import appConfig from './app.config'; angular.module('phonecatApp', [ + 'ngAnimate', 'ngRoute', core.name, phoneList.name, phoneDetail.name -]).config(configure); +]).config(appConfig); -configure.$inject = ['$routeProvider']; +// #docregion add-http-providers +upgradeAdapter.addProvider(HTTP_PROVIDERS); +// #enddocregion add-http-providers -function configure($routeProvider) { - $routeProvider. - when('/phones', { - templateUrl: 'js/phone_list/phone_list.html', - controller: 'PhoneListCtrl', - controllerAs: 'vm' - }). - when('/phones/:phoneId', { - templateUrl: 'js/phone_detail/phone_detail.html', - controller: 'PhoneDetailCtrl', - controllerAs: 'vm' - }). - otherwise({ - redirectTo: '/phones' - }); -} +// #docregion upgrade-route-params +upgradeAdapter.upgradeNg1Provider('$routeParams'); +// #enddocregion upgrade-route-params // #docregion bootstrap upgradeAdapter.bootstrap(document.documentElement, ['phonecatApp']); diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/unit/checkmark.pipe.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/core/checkmark/checkmark.pipe.spec.ts similarity index 87% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/unit/checkmark.pipe.spec.ts rename to public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/core/checkmark/checkmark.pipe.spec.ts index c1794fd7c0..6ba43be772 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/unit/checkmark.pipe.spec.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/core/checkmark/checkmark.pipe.spec.ts @@ -1,6 +1,6 @@ // #docregion import {describe, beforeEachProviders, it, inject, expect} from '@angular/core/testing'; -import {CheckmarkPipe} from '../../app/js/core/checkmark.pipe'; +import {CheckmarkPipe} from './checkmark.pipe'; describe('CheckmarkPipe', function() { diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/core/checkmark.pipe.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/core/checkmark/checkmark.pipe.ts similarity index 54% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/core/checkmark.pipe.ts rename to public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/core/checkmark/checkmark.pipe.ts index d129a44e50..c3c3c73f72 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/core/checkmark.pipe.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/core/checkmark/checkmark.pipe.ts @@ -1,8 +1,8 @@ // #docregion -import { Pipe } from '@angular/core'; +import {Pipe, PipeTransform} from '@angular/core'; @Pipe({name: 'checkmark'}) -export class CheckmarkPipe { +export class CheckmarkPipe implements PipeTransform { transform(input:string): string { return input ? '\u2713' : '\u2718'; } diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/core/core.module.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/core/core.module.ts new file mode 100644 index 0000000000..6c464b8ddd --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/core/core.module.ts @@ -0,0 +1,4 @@ +// #docregion +import phone from './phone/phone.module'; + +export default angular.module('core', [phone.name]); diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/core/phone/phone.module.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/core/phone/phone.module.ts new file mode 100644 index 0000000000..7b8d127731 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/core/phone/phone.module.ts @@ -0,0 +1,8 @@ +// #docregion +import {Phone} from './phone.service'; +import upgradeAdapter from '../upgrade-adapter'; + +upgradeAdapter.addProvider(Phone); + +export default angular.module('core.phone', []) + .factory('phone', upgradeAdapter.downgradeNg2Provider(Phone)); diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/core/phone/phone.service.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/core/phone/phone.service.spec.ts new file mode 100644 index 0000000000..e0dceedfa3 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/core/phone/phone.service.spec.ts @@ -0,0 +1,43 @@ +// #docregion +import {provide} from '@angular/core'; +import {describe, beforeEach, beforeEachProviders, it, inject} from '@angular/core/testing'; +import {Http, BaseRequestOptions, ResponseOptions, Response} from '@angular/http'; +import {MockBackend} from '@angular/http/testing'; +import {Phone, PhoneData} from './phone.service'; + +describe('Phone', function() { + var phone; + var phonesData:PhoneData[] = [ + {name: 'Phone X', snippet: '', images: []}, + {name: 'Phone Y', snippet: '', images: []}, + {name: 'Phone Z', snippet: '', images: []} + ]; + var mockBackend; + + // load providers + beforeEachProviders(() => [ + Phone, + MockBackend, + BaseRequestOptions, + provide(Http, { + useFactory: (backend, options) => new Http(backend, options), + deps: [MockBackend, BaseRequestOptions] + }) + ]); + + beforeEach(inject([MockBackend, Phone], (_mockBackend_, _phone_) => { + mockBackend = _mockBackend_; + phone = _phone_; + })); + + it('should fetch the phones data from `/phones/phones.json`', (done) => { + mockBackend.connections.subscribe(connection => { + connection.mockRespond(new Response(new ResponseOptions({body: JSON.stringify(phonesData)}))); + }); + phone.query().subscribe(result => { + expect(result).toEqual(phonesData); + done(); + }); + }); + +}); diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/core/phones.service.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/core/phone/phone.service.ts similarity index 52% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/core/phones.service.ts rename to public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/core/phone/phone.service.ts index d292bc54ee..e47358c75e 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/core/phones.service.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/core/phone/phone.service.ts @@ -1,37 +1,35 @@ -// #docregion full -import { Injectable } from '@angular/core'; -import { Http, Response } from '@angular/http'; -import { Observable } from 'rxjs/Rx'; +// #docregion +import {Injectable} from '@angular/core'; +import {Http, Response} from '@angular/http'; +import {Observable} from 'rxjs/Rx'; import 'rxjs/add/operator/map'; -// #docregion phone-interface -export interface Phone { +// #docregion phonedata-interface +export interface PhoneData { name: string; - snippet?: string; - images?: string[]; + snippet: string; + images: string[]; } -// #enddocregion phone-interface +// #enddocregion phonedata-interface -// #docregion fullclass // #docregion class +// #docregion fullclass @Injectable() -export class Phones { +export class Phone { // #enddocregion class constructor(private http: Http) { } - query():Observable { + query():Observable { return this.http.get(`phones/phones.json`) .map((res:Response) => res.json()); } - get(id: string):Observable { + get(id: string):Observable { return this.http.get(`phones/${id}.json`) .map((res:Response) => res.json()); } - // #docregion class } -// #enddocregion class // #enddocregion fullclass -// #docregion full +// #enddocregion class diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/core/upgrade_adapter.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/core/upgrade-adapter.ts similarity index 59% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/core/upgrade_adapter.ts rename to public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/core/upgrade-adapter.ts index f1ad63012a..f5659ad5b4 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/core/upgrade_adapter.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/core/upgrade-adapter.ts @@ -1,9 +1,8 @@ -// #docregion full -import { UpgradeAdapter } from '@angular/upgrade'; +// #docregion +import {UpgradeAdapter} from '@angular/upgrade'; // #docregion adapter-init const upgradeAdapter = new UpgradeAdapter(); // #enddocregion adapter-init export default upgradeAdapter; -// #enddocregion full diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/css/.gitkeep b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/css/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/index.html b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/index.html index 310d1ab348..75aed6c6e6 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/index.html +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/index.html @@ -4,8 +4,9 @@ Google Phone Gallery - - + + + @@ -18,8 +19,9 @@ + diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/app.module.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/app.module.ts deleted file mode 100644 index 3718b9250f..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/app.module.ts +++ /dev/null @@ -1,46 +0,0 @@ -// #docregion adapter-import -import { UpgradeAdapter } from '@angular/upgrade'; -// #enddocregion adapter-import -// #docregion adapter-state-import -import upgradeAdapter from './core/upgrade_adapter'; -// #enddocregion adapter-state-import -// #docregion http-import -import { HTTP_PROVIDERS } from '@angular/http'; -// #enddocregion http-import -import core from './core/core.module'; -import phoneList from './phone_list/phone_list.module'; -import phoneDetail from './phone_detail/phone_detail.module'; - -upgradeAdapter.addProvider(HTTP_PROVIDERS); -// #docregion upgrade-route-params -upgradeAdapter.upgradeNg1Provider('$routeParams'); -// #enddocregion -angular.module('phonecatApp', [ - 'ngRoute', - core.name, - phoneList.name, - phoneDetail.name -]).config(configure); - -configure.$inject = ['$routeProvider']; - -function configure($routeProvider) { - // #docregion list-route - $routeProvider. - when('/phones', { - template: '' - }). - // #enddocregion list-route - // #docregion detail-route - when('/phones/:phoneId', { - template: '' - }). - // #enddocregion detail-route - otherwise({ - redirectTo: '/phones' - }); -} - -// #docregion app-bootstrap -upgradeAdapter.bootstrap(document.documentElement, ['phonecatApp']); -// #enddocregion app-bootstrap diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/core/core.module.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/core/core.module.ts deleted file mode 100644 index c3e1ba514b..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/core/core.module.ts +++ /dev/null @@ -1,8 +0,0 @@ -// #docregion -import { Phones } from './phones.service'; -import upgradeAdapter from './upgrade_adapter'; - -upgradeAdapter.addProvider(Phones); - -export default angular.module('phonecat.core', []) - .factory('phones', upgradeAdapter.downgradeNg2Provider(Phones)); diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/core/upgrade_adapter.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/core/upgrade_adapter.ts deleted file mode 100644 index f1ad63012a..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/core/upgrade_adapter.ts +++ /dev/null @@ -1,9 +0,0 @@ -// #docregion full -import { UpgradeAdapter } from '@angular/upgrade'; - -// #docregion adapter-init -const upgradeAdapter = new UpgradeAdapter(); -// #enddocregion adapter-init - -export default upgradeAdapter; -// #enddocregion full diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_detail/phone_detail.module.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_detail/phone_detail.module.ts deleted file mode 100644 index 2a31fb503d..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_detail/phone_detail.module.ts +++ /dev/null @@ -1,10 +0,0 @@ -// #docregion -import PhoneDetail from './phone_detail.component'; -import upgradeAdapter from '../core/upgrade_adapter'; - -export default angular.module('phonecat.detail', [ - 'ngRoute', - 'phonecat.core' - ]) - .directive('pcPhoneDetail', - upgradeAdapter.downgradeNg2Component(PhoneDetail)) diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/phone_list.component.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/phone_list.component.ts deleted file mode 100644 index d876e28861..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/phone_list.component.ts +++ /dev/null @@ -1,26 +0,0 @@ -// #docregion full -// #docregion top -import { Component } from '@angular/core'; -import { Observable } from 'rxjs'; -import { Phones, Phone } from '../core/phones.service'; -import PhoneFilterPipe from './phone_filter.pipe'; -import OrderByPipe from './order_by.pipe'; - -@Component({ - selector: 'pc-phone-list', - templateUrl: 'js/phone_list/phone_list.html', - pipes: [PhoneFilterPipe, OrderByPipe], -}) -class PhoneList { -// #enddocregion top - - phones:Observable; - orderProp:string; - query:string; - constructor(phones:Phones) { - this.phones = phones.query(); - this.orderProp = 'age'; - } -} - -export default PhoneList; diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/phone_list.module.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/phone_list.module.ts deleted file mode 100644 index 4632cc90f5..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/phone_list.module.ts +++ /dev/null @@ -1,9 +0,0 @@ -// #docregion -import PhoneList from './phone_list.component'; -import upgradeAdapter from '../core/upgrade_adapter'; - -export default angular.module('phonecat.list', [ - 'phonecat.core' - ]) - .directive('pcPhoneList', - upgradeAdapter.downgradeNg2Component(PhoneList)); diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/phone_list_without_pipes.component.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/phone_list_without_pipes.component.ts deleted file mode 100644 index d967ce464e..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/phone_list_without_pipes.component.ts +++ /dev/null @@ -1,22 +0,0 @@ -// #docregion top -import { Component } from '@angular/core'; -import { Observable } from 'rxjs'; -import { Phone, Phones } from '../core/phones.service'; - -@Component({ - selector: 'pc-phone-list', - templateUrl: 'js/phone_list/phone_list.html' -}) -class PhoneList { -// #enddocregion top - - phones:Observable; - orderProp:string; - query:string; - constructor(phones:Phones) { - this.phones = phones.query(); - this.orderProp = 'age'; - } -} - -export default PhoneList; diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_detail/phone_detail_without_pipes.component.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-detail/phone-detail-without-pipes.component.ts similarity index 52% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_detail/phone_detail_without_pipes.component.ts rename to public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-detail/phone-detail-without-pipes.component.ts index 0926ffeb84..19d61f82a6 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_detail/phone_detail_without_pipes.component.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-detail/phone-detail-without-pipes.component.ts @@ -1,29 +1,30 @@ // #docregion import { Component, Inject } from '@angular/core'; -import { Phone, Phones } from '../core/phones.service'; +import {Phone, PhoneData} from '../core/phone/phone.service'; interface PhoneRouteParams { phoneId: string } @Component({ - selector: 'pc-phone-detail', - templateUrl: 'js/phone_detail/phone_detail.html' + selector: 'phone-detail', + templateUrl: 'phone-detail/phone-detail.html' }) -class PhoneDetail { - phone:Phone = undefined; +export default class PhoneDetail { + phone:PhoneData; mainImageUrl:string; + constructor(@Inject('$routeParams') $routeParams:PhoneRouteParams, - phones:Phones) { - phones.get($routeParams.phoneId) + phone:Phone) { + phone.get($routeParams.phoneId) .subscribe(phone => { this.phone = phone; - this.mainImageUrl = phone.images[0]; + this.setImage(phone.images[0]); }); } setImage(url:string) { this.mainImageUrl = url; } + } -export default PhoneDetail; diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/unit/phone_detail.component.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-detail/phone-detail.component.spec.ts similarity index 76% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/unit/phone_detail.component.spec.ts rename to public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-detail/phone-detail.component.spec.ts index a94a28f055..aa02d6f1d6 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/unit/phone_detail.component.spec.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-detail/phone-detail.component.spec.ts @@ -2,6 +2,7 @@ import {provide} from '@angular/core'; import {HTTP_PROVIDERS} from '@angular/http'; import {Observable} from 'rxjs/Rx'; + import { describe, beforeEachProviders, @@ -11,10 +12,10 @@ import { } from '@angular/core/testing'; import {TestComponentBuilder} from '@angular/compiler/testing'; -import PhoneDetail from '../../app/js/phone_detail/phone_detail.component'; -import {Phones, Phone} from '../../app/js/core/phones.service'; +import PhoneDetail from './phone-detail.component'; +import {Phone, PhoneData} from '../core/phone/phone.service'; -function xyzPhoneData():Phone { +function xyzPhoneData():PhoneData { return { name: 'phone xyz', snippet: '', @@ -22,8 +23,8 @@ function xyzPhoneData():Phone { } } -class MockPhones extends Phones { - get(id):Observable { +class MockPhone extends Phone { + get(id: string):Observable { return Observable.of(xyzPhoneData()); } } @@ -31,7 +32,7 @@ class MockPhones extends Phones { describe('PhoneDetail', () => { beforeEachProviders(() => [ - provide(Phones, {useClass: MockPhones}), + provide(Phone, {useClass: MockPhone}), provide('$routeParams', {useValue: {phoneId: 'xyz'}}), HTTP_PROVIDERS ]); @@ -40,7 +41,6 @@ describe('PhoneDetail', () => { return tcb.createAsync(PhoneDetail).then((fixture) => { fixture.detectChanges(); let compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1')).toHaveText(xyzPhoneData().name); }); })); diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_detail/phone_detail.component.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-detail/phone-detail.component.ts similarity index 52% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_detail/phone_detail.component.ts rename to public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-detail/phone-detail.component.ts index dc6c1ff4fd..aa68f7ebcf 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_detail/phone_detail.component.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-detail/phone-detail.component.ts @@ -1,33 +1,34 @@ // #docregion // #docregion top import { Component, Inject } from '@angular/core'; -import { Phones, Phone } from '../core/phones.service'; -import { CheckmarkPipe } from '../core/checkmark.pipe'; +import { Phone, PhoneData } from '../core/phone/phone.service'; +import { CheckmarkPipe } from '../core/checkmark/checkmark.pipe'; interface PhoneRouteParams { phoneId: string } @Component({ - selector: 'pc-phone-detail', - templateUrl: 'js/phone_detail/phone_detail.html', + selector: 'phone-detail', + templateUrl: 'phone-detail/phone-detail.template.html', pipes: [CheckmarkPipe] }) -class PhoneDetail { // #enddocregion top - phone:Phone = undefined; +export default class PhoneDetail { + phone:PhoneData; mainImageUrl:string; + constructor(@Inject('$routeParams') $routeParams:PhoneRouteParams, - phones:Phones) { - phones.get($routeParams.phoneId) + phone:Phone) { + phone.get($routeParams.phoneId) .subscribe(phone => { this.phone = phone; - this.mainImageUrl = phone.images[0]; + this.setImage(phone.images[0]); }); } setImage(url:string) { this.mainImageUrl = url; } + } -export default PhoneDetail; diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-detail/phone-detail.module.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-detail/phone-detail.module.ts new file mode 100644 index 0000000000..251cf8223d --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-detail/phone-detail.module.ts @@ -0,0 +1,11 @@ +// #docregion +import PhoneDetail from './phone-detail.component'; +import phone from '../core/phone/phone.module'; +import upgradeAdapter from '../core/upgrade-adapter'; + +export default angular.module('phoneDetail', [ + 'ngRoute', + phone.name + ]) + .directive('phoneDetail', + upgradeAdapter.downgradeNg2Component(PhoneDetail)); diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_detail/phone_detail.html b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-detail/phone-detail.template.html similarity index 100% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_detail/phone_detail.html rename to public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-detail/phone-detail.template.html diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/unit/order_by.pipe.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/order-by.pipe.spec.ts similarity index 89% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/unit/order_by.pipe.spec.ts rename to public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/order-by.pipe.spec.ts index f8a8401b7f..f19f5d3534 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/unit/order_by.pipe.spec.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/order-by.pipe.spec.ts @@ -1,7 +1,7 @@ // #docregion import {describe, beforeEachProviders, it, inject} from '@angular/core/testing'; -import OrderByPipe from '../../app/js/phone_list/order_by.pipe'; +import OrderByPipe from './order-by.pipe'; describe('OrderByPipe', function() { diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/phone_list/order_by.pipe.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/order-by.pipe.ts similarity index 74% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/phone_list/order_by.pipe.ts rename to public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/order-by.pipe.ts index 162b91cf60..3366ceae7a 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/phone_list/order_by.pipe.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/order-by.pipe.ts @@ -1,8 +1,8 @@ // #docregion -import { Pipe } from '@angular/core'; +import { Pipe, PipeTransform } from '@angular/core'; @Pipe({name: 'orderBy'}) -export default class OrderByPipe { +export default class OrderByPipe implements PipeTransform { transform(input:T[], property:string): T[] { if (input) { @@ -15,7 +15,7 @@ export default class OrderByPipe { return 0; } }); - } else { + } else { return input; } } diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/unit/phone_filter.pipe.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-filter.pipe.spec.ts similarity index 80% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/unit/phone_filter.pipe.spec.ts rename to public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-filter.pipe.spec.ts index 6de1e5722d..a891438e0b 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/unit/phone_filter.pipe.spec.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-filter.pipe.spec.ts @@ -1,12 +1,11 @@ // #docregion import { describe, beforeEachProviders, it, inject } from '@angular/core/testing'; -import PhoneFilterPipe from '../../app/js/phone_list/phone_filter.pipe'; -import { Phone } from '../../app/js/core/phones.service'; +import PhoneFilterPipe from './phone-filter.pipe'; +import {PhoneData} from '../core/phone/phone.service'; -describe('PhoneFilterPipe', () => { - - let phones:Phone[] = [ +describe('PhoneFilterPipe', function() { + let phones:PhoneData[] = [ {name: 'Nexus S', snippet: 'The Nexus S Phone', images: []}, {name: 'Motorola DROID', snippet: 'an Android-for-business smartphone', images: []} ]; diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/phone_list/phone_filter.pipe.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-filter.pipe.ts similarity index 55% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/phone_list/phone_filter.pipe.ts rename to public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-filter.pipe.ts index 9f38608e8f..7c6e0630e0 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/phone_list/phone_filter.pipe.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-filter.pipe.ts @@ -1,19 +1,20 @@ // #docregion -import { Pipe } from '@angular/core'; -import { Phone } from '../core/phones.service'; +import { Pipe, PipeTransform } from '@angular/core'; +import {PhoneData} from '../core/phone/phone.service'; + @Pipe({name: 'phoneFilter'}) -export default class PhoneFilterPipe { +export default class PhoneFilterPipe implements PipeTransform { - transform(input:Phone[], query:string = ''): Phone[] { - if (input) { + transform(input:PhoneData[], query:string): PhoneData[] { + if (query) { query = query.toLowerCase(); return input.filter((phone) => { const name = phone.name.toLowerCase(); const snippet = phone.snippet.toLowerCase(); return name.indexOf(query) >= 0 || snippet.indexOf(query) >= 0; }); - } else { + } else { return input; } } diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/phone_list_without_async.html b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list-without-async.template.html similarity index 99% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/phone_list_without_async.html rename to public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list-without-async.template.html index c77090c96c..1f6cc09906 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/phone_list_without_async.html +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list-without-async.template.html @@ -15,7 +15,6 @@
-
-
diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list-without-pipes.component.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list-without-pipes.component.ts new file mode 100644 index 0000000000..f7e568d9f0 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list-without-pipes.component.ts @@ -0,0 +1,21 @@ +// #docregion +import {Component} from '@angular/core'; +import {Phone, PhoneData} from '../core/phone/phone.service'; + +@Component({ + selector: 'phone-list', + templateUrl: 'phone-list/phone-list.template.html' +}) +export class PhoneList { + phones:PhoneData[]; + orderProp:string; + query:string; + + constructor(phone:Phone) { + phone.query().subscribe(phones => { + this.phones = phones; + }); + this.orderProp = 'age'; + } + +} diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/phone_list_without_pipes.html b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list-without-pipes.template.html similarity index 99% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/phone_list_without_pipes.html rename to public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list-without-pipes.template.html index 1a9d3fefb3..25618e578a 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/phone_list_without_pipes.html +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list-without-pipes.template.html @@ -15,7 +15,6 @@
-
-
diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/unit/phone_list.component.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list.component.spec.ts similarity index 79% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/unit/phone_list.component.spec.ts rename to public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list.component.spec.ts index d3d87f2a6f..4ef46ab338 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/unit/phone_list.component.spec.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list.component.spec.ts @@ -2,6 +2,7 @@ import {provide} from '@angular/core'; import {HTTP_PROVIDERS} from '@angular/http'; import {Observable} from 'rxjs/Rx'; + import { describe, beforeEachProviders, @@ -11,13 +12,16 @@ import { } from '@angular/core/testing'; import {TestComponentBuilder} from '@angular/compiler/testing'; -import PhoneList from '../../app/js/phone_list/phone_list.component'; -import {Phones, Phone} from '../../app/js/core/phones.service'; +import PhoneList from './phone-list.component'; +import {Phone, PhoneData} from '../core/phone/phone.service'; -class MockPhones extends Phones { - query():Observable { +class MockPhone extends Phone { + query():Observable { return Observable.of( - [{name: 'Nexus S', snippet: ''}, {name: 'Motorola DROID', snippet: ''}] + [ + {name: 'Nexus S', snippet: '', images: []}, + {name: 'Motorola DROID', snippet: '', images: []} + ] ) } } @@ -25,25 +29,21 @@ class MockPhones extends Phones { describe('PhoneList', () => { beforeEachProviders(() => [ - provide(Phones, {useClass: MockPhones}), + provide(Phone, {useClass: MockPhone}), HTTP_PROVIDERS ]); - it('should create "phones" model with 2 phones fetched from xhr', inject([TestComponentBuilder], (tcb) => { return tcb.createAsync(PhoneList).then((fixture) => { fixture.detectChanges(); - let compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelectorAll('.phone-listing').length).toBe(2); expect(compiled.querySelector('.phone-listing:nth-child(1)').textContent).toContain('Nexus S'); expect(compiled.querySelector('.phone-listing:nth-child(2)').textContent).toContain('Motorola DROID'); }); })); - it('should set the default value of orderProp model', inject([TestComponentBuilder], (tcb) => { return tcb.createAsync(PhoneList).then((fixture) => { diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list.component.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list.component.ts new file mode 100644 index 0000000000..94b4491dba --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list.component.ts @@ -0,0 +1,25 @@ +// #docregion +// #docregion top +import {Component} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {Phone, PhoneData} from '../core/phone/phone.service'; +import PhoneFilterPipe from './phone-filter.pipe'; +import OrderByPipe from './order-by.pipe'; + +@Component({ + selector: 'phone-list', + templateUrl: 'phone-list/phone-list.template.html', + pipes: [PhoneFilterPipe, OrderByPipe] +}) +// #enddocregion top +export default class PhoneList { + phones:Observable; + orderProp:string; + query:string; + + constructor(phone:Phone) { + this.phones = phone.query(); + this.orderProp = 'age'; + } + +} diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list.module.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list.module.ts new file mode 100644 index 0000000000..6842d5a7fc --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list.module.ts @@ -0,0 +1,8 @@ +// #docregion +import PhoneList from './phone-list.component'; +import phone from '../core/phone/phone.module'; +import upgradeAdapter from '../core/upgrade-adapter'; + +export default angular.module('phoneList', [phone.name]) + .directive('phoneList', + upgradeAdapter.downgradeNg2Component(PhoneList)); diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/phone_list.html b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list.template.html similarity index 99% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/phone_list.html rename to public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list.template.html index 7934a38283..29dcf85365 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/phone_list.html +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list.template.html @@ -15,7 +15,6 @@
-
-
diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/systemjs.config.js b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/systemjs.config.js index d7510ce7c6..5765cb282b 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/systemjs.config.js +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/systemjs.config.js @@ -8,7 +8,7 @@ System.config({ '@angular': pkgPath + '@angular' }, packages: { - 'js': { defaultExtension: 'js' }, + './': { defaultExtension: 'js' }, '@angular/common': { main: 'index.js', defaultExtension: 'js' }, '@angular/compiler': { main: 'index.js', defaultExtension: 'js' }, diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/protractor-conf.js b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/e2e-tests/protractor-conf.js similarity index 94% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/protractor-conf.js rename to public/docs/_examples/upgrade-phonecat/ts/ng2_components/e2e-tests/protractor-conf.js index 490e9bd078..6252ae848e 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/protractor-conf.js +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/e2e-tests/protractor-conf.js @@ -2,7 +2,7 @@ exports.config = { allScriptsTimeout: 11000, specs: [ - 'e2e/*.js' + '*.js' ], capabilities: { @@ -10,7 +10,7 @@ exports.config = { }, directConnect: true, - + baseUrl: 'http://localhost:8000/', framework: 'jasmine', diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/e2e/scenarios.js b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/e2e-tests/scenarios.js similarity index 81% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/e2e/scenarios.js rename to public/docs/_examples/upgrade-phonecat/ts/ng2_components/e2e-tests/scenarios.js index 1da0896c0d..81f2d9f7fc 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/e2e/scenarios.js +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/e2e-tests/scenarios.js @@ -18,6 +18,7 @@ describe('PhoneCat App', function() { browser.get('app/index.html#/phones'); }); + it('should filter the phone list as a user types into the search box', function() { var phoneList = element.all(by.css('.phones li')); var query = element(by.css('input')); @@ -28,17 +29,13 @@ describe('PhoneCat App', function() { expect(phoneList.count()).toBe(1); query.clear(); - // https://github.com/angular/protractor/issues/2019 - var str = 'motorola'; - for (var i = 0; i < str.length; i++) { - query.sendKeys(str.charAt(i)); - } - + query.sendKeys('motorola'); expect(phoneList.count()).toBe(8); }); it('should be possible to control phone order via the drop down select box', function() { + var phoneNameColumn = element.all(by.css('.phones .name')); var query = element(by.css('input')); @@ -48,12 +45,7 @@ describe('PhoneCat App', function() { }); } - //let's narrow the dataset to make the test assertions shorter - // https://github.com/angular/protractor/issues/2019 - var str = 'tablet'; - for (var i = 0; i < str.length; i++) { - query.sendKeys(str.charAt(i)); - } + query.sendKeys('tablet'); //let's narrow the dataset to make the test assertions shorter expect(getNames()).toEqual([ "Motorola XOOM\u2122 with Wi-Fi", @@ -71,11 +63,7 @@ describe('PhoneCat App', function() { it('should render phone specific links', function() { var query = element(by.css('input')); - // https://github.com/angular/protractor/issues/2019 - var str = 'nexus'; - for (var i = 0; i < str.length; i++) { - query.sendKeys(str.charAt(i)); - } + query.sendKeys('nexus'); element.all(by.css('.phones li a')).first().click(); browser.getLocationAbsUrl().then(function(url) { expect(url).toEqual('/phones/nexus-s'); diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/karma.conf.1.js b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/karma.conf.1.js new file mode 100644 index 0000000000..2c6ae448a0 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/karma.conf.1.js @@ -0,0 +1,59 @@ +module.exports = function(config){ + config.set({ + + baseDir: '.', + + // #docregion ng2 + // #docregion html + files : [ + // #enddocregion html + // #enddocregion ng2 + 'app/bower_components/angular/angular.js', + 'app/bower_components/angular-route/angular-route.js', + 'app/bower_components/angular-resource/angular-resource.js', + 'app/bower_components/angular-animate/angular-animate.js', + 'app/bower_components/angular-mocks/angular-mocks.js', + 'node_modules/systemjs/dist/system-polyfills.js', + 'node_modules/systemjs/dist/system.src.js', + // #docregion ng2 + 'node_modules/es6-shim/es6-shim.js', + 'node_modules/zone.js/dist/zone.js', + 'node_modules/reflect-metadata/Reflect.js', + {pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false}, + {pattern: 'node_modules/@angular/**/*.js', included: false, watched: false}, + // #enddocregion ng2 + 'karma_test_shim.js', + {pattern: 'app/**/*.module.js', included: false, watched: true}, + {pattern: 'app/*!(.module|.spec).js', included: false, watched: true}, + {pattern: 'app/!(bower_components)/**/*!(.module|.spec).js', included: false, watched: true}, + {pattern: 'app/**/*.spec.js', included: false, watched: true}, + // #docregion html + {pattern: 'app/**/*.html', included: false, watched: true} + // #docregion ng2 + ], + // #enddocregion ng2 + + proxies: { + // required for component assets fetched by Angular's compiler + "/": "/base/app/" + }, + // #enddocregion html + + autoWatch : true, + + frameworks: ['jasmine'], + + browsers : ['Chrome', 'Firefox'], + + plugins : [ + 'karma-chrome-launcher', + 'karma-firefox-launcher', + 'karma-jasmine' + ], + + junitReporter : { + outputFile: 'test_out/unit.xml', + suite: 'unit' + } + }); +}; diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/karma_test_shim.js b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/karma_test_shim.js similarity index 85% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/karma_test_shim.js rename to public/docs/_examples/upgrade-phonecat/ts/ng2_components/karma_test_shim.js index 26075e973d..edb4033652 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/karma_test_shim.js +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/karma_test_shim.js @@ -5,11 +5,11 @@ __karma__.loaded = function() {}; System.config({ map: { - 'rxjs': 'base/node_modules/rxjs', - '@angular': 'base/node_modules/@angular' + 'rxjs': 'base/node_modules/rxjs', + '@angular': 'base/node_modules/@angular' }, packages: { - 'base/app/js': { + 'base': { defaultExtension: false, format: 'register', map: Object.keys(window.__karma__.files). @@ -17,7 +17,7 @@ System.config({ reduce(function createPathRecords(pathsMapping, appPath) { // creates local module name mapping to global path with karma's fingerprint in path, e.g.: // './hero.service': '/base/src/app/hero.service.js?f4523daf879cfb7310ef6242682ccf10b2041b3e' - var moduleName = appPath.replace(/^\/base\/app\/js\//, './').replace(/\.js$/, ''); + var moduleName = appPath.replace(/^\/base\//, './').replace(/\.js$/, ''); pathsMapping[moduleName] = appPath + '?' + window.__karma__.files[appPath] return pathsMapping; }, {}) @@ -42,22 +42,22 @@ System.import('@angular/core/testing').then(function(testing) { browserTesting.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS); }); }).then(function() { - return Promise.all( + Promise.all( Object.keys(window.__karma__.files) // All files served by Karma. .filter(onlySpecFiles) .map(function(moduleName) { // loads all spec files via their global module names return System.import(moduleName); - })); -}).then(function() { - __karma__.start(); -}, function(error) { - __karma__.error(error.stack || error); + })) + .then(function() { + __karma__.start(); + }, function(error) { + __karma__.error(error.stack || error); + }); }); -// #enddocregion ng2 function onlyAppFiles(filePath) { - return /^\/base\/app\/js\/.*\.js$/.test(filePath) + return /^\/base\/.*\.(?!\.spec\.)js$/.test(filePath) } function onlySpecFiles(path) { diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/package.1.json b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/package.1.json index 501da397e3..15902577d7 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/package.1.json +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/package.1.json @@ -28,28 +28,22 @@ "karma-firefox-launcher": "^0.1.3", "karma-jasmine": "~0.3.7", "protractor": "^3.0.0", - "http-server": "^0.6.1", - "tmp": "0.0.23", - "bower": "^1.3.1", "shelljs": "^0.2.6", "typescript": "1.8.10", "typings": "^0.7.12" }, "scripts": { "postinstall": "bower install", - "prestart": "npm install", "start": "http-server -a 0.0.0.0 -p 8000", - "test": "node node_modules/karma/bin/karma start test/karma.conf.js", - "test-single-run": "node node_modules/karma/bin/karma start test/karma.conf.js --single-run", + "test": "node node_modules/karma/bin/karma start karma.conf.js", + "test-single-run": "node node_modules/karma/bin/karma start karma.conf.js --single-run", "preupdate-webdriver": "npm install", "update-webdriver": "webdriver-manager update", - "preprotractor": "npm run update-webdriver", - "protractor": "protractor test/protractor-conf.js", - + "protractor": "protractor e2e-tests/protractor-conf.js", "typings": "typings", "tsc": "tsc -p . -w" } diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/unit/phones.service.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/unit/phones.service.spec.ts deleted file mode 100644 index c70f25c5ca..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/unit/phones.service.spec.ts +++ /dev/null @@ -1,16 +0,0 @@ -// #docregion -import {describe, beforeEachProviders, it, inject} from '@angular/core/testing'; -import {HTTP_PROVIDERS} from '@angular/http'; -import {Phones} from '../../app/js/core/phones.service'; - -describe('Phones', function() { - - // load providers - beforeEachProviders(() => [Phones, HTTP_PROVIDERS]); - - // Test service availability - it('check the existence of Phones', inject([Phones], (phones) => { - expect(phones).toBeDefined(); - })); - -}); diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/app.component.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/app.component.ts similarity index 75% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/app.component.ts rename to public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/app.component.ts index f572854fc0..bfcc6e391a 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/app.component.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/app.component.ts @@ -2,8 +2,8 @@ import { Component } from '@angular/core'; import { RouteConfig, ROUTER_DIRECTIVES } from '@angular/router-deprecated'; -import PhoneList from './phone_list/phone_list.component'; -import PhoneDetail from './phone_detail/phone_detail.component'; +import PhoneList from './phone-list/phone-list.component'; +import PhoneDetail from './phone-detail/phone-detail.component'; @RouteConfig([ {path:'/phones', name: 'Phones', component: PhoneList}, @@ -11,7 +11,7 @@ import PhoneDetail from './phone_detail/phone_detail.component'; {path:'/', redirectTo: ['Phones']} ]) @Component({ - selector: 'pc-app', + selector: 'phonecat-app', template: '', directives: [ROUTER_DIRECTIVES] }) diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/unit/checkmark.pipe.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/core/checkmark/checkmark.pipe.spec.ts similarity index 80% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/unit/checkmark.pipe.spec.ts rename to public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/core/checkmark/checkmark.pipe.spec.ts index c9a1def071..aedfbd011b 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/unit/checkmark.pipe.spec.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/core/checkmark/checkmark.pipe.spec.ts @@ -1,9 +1,9 @@ // #docregion import { describe, beforeEachProviders, it, inject, expect } from '@angular/core/testing'; -import { CheckmarkPipe } from '../../app/js/core/checkmark.pipe'; +import {CheckmarkPipe} from './checkmark.pipe'; -describe('CheckmarkPipe', () => { +describe('CheckmarkPipe', function() { beforeEachProviders(() => [CheckmarkPipe]); diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/core/checkmark.pipe.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/core/checkmark/checkmark.pipe.ts similarity index 53% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/core/checkmark.pipe.ts rename to public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/core/checkmark/checkmark.pipe.ts index d129a44e50..68a40c8b00 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/core/checkmark.pipe.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/core/checkmark/checkmark.pipe.ts @@ -1,8 +1,8 @@ // #docregion -import { Pipe } from '@angular/core'; +import { Pipe, PipeTransform } from '@angular/core'; @Pipe({name: 'checkmark'}) -export class CheckmarkPipe { +export class CheckmarkPipe implements PipeTransform { transform(input:string): string { return input ? '\u2713' : '\u2718'; } diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/core/phone/phone.service.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/core/phone/phone.service.spec.ts new file mode 100644 index 0000000000..e0dceedfa3 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/core/phone/phone.service.spec.ts @@ -0,0 +1,43 @@ +// #docregion +import {provide} from '@angular/core'; +import {describe, beforeEach, beforeEachProviders, it, inject} from '@angular/core/testing'; +import {Http, BaseRequestOptions, ResponseOptions, Response} from '@angular/http'; +import {MockBackend} from '@angular/http/testing'; +import {Phone, PhoneData} from './phone.service'; + +describe('Phone', function() { + var phone; + var phonesData:PhoneData[] = [ + {name: 'Phone X', snippet: '', images: []}, + {name: 'Phone Y', snippet: '', images: []}, + {name: 'Phone Z', snippet: '', images: []} + ]; + var mockBackend; + + // load providers + beforeEachProviders(() => [ + Phone, + MockBackend, + BaseRequestOptions, + provide(Http, { + useFactory: (backend, options) => new Http(backend, options), + deps: [MockBackend, BaseRequestOptions] + }) + ]); + + beforeEach(inject([MockBackend, Phone], (_mockBackend_, _phone_) => { + mockBackend = _mockBackend_; + phone = _phone_; + })); + + it('should fetch the phones data from `/phones/phones.json`', (done) => { + mockBackend.connections.subscribe(connection => { + connection.mockRespond(new Response(new ResponseOptions({body: JSON.stringify(phonesData)}))); + }); + phone.query().subscribe(result => { + expect(result).toEqual(phonesData); + done(); + }); + }); + +}); diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/core/phones.service.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/core/phone/phone.service.ts similarity index 75% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/core/phones.service.ts rename to public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/core/phone/phone.service.ts index 96cce48520..aabc995b3c 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/core/phones.service.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/core/phone/phone.service.ts @@ -5,34 +5,32 @@ import { Observable } from 'rxjs/Rx'; import 'rxjs/add/operator/map'; -// #docregion phone-interface -export interface Phone { +// #docregion phonedata-interface +export interface PhoneData { name: string; snippet: string; images: string[]; } -// #enddocregion phone-interface +// #enddocregion phonedata-interface -// #docregion fullclass // #docregion class +// #docregion fullclass @Injectable() -export class Phones { +export class Phone { // #enddocregion class constructor(private http: Http) { } - query():Observable { + query():Observable { return this.http.get(`phones/phones.json`) .map((res:Response) => res.json()); } - get(id: string):Observable { + get(id: string):Observable { return this.http.get(`phones/${id}.json`) .map((res:Response) => res.json()); } - // #docregion class } -// #enddocregion class // #enddocregion fullclass -// #docregion full +// #enddocregion class diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/css/.gitkeep b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/css/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/index.html b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/index.html index a1dfd126cf..d255279e0c 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/index.html +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/index.html @@ -14,13 +14,13 @@ - + diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/phone_detail/phone_detail.component.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/phone_detail/phone_detail.component.ts deleted file mode 100644 index a6d07f3773..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/phone_detail/phone_detail.component.ts +++ /dev/null @@ -1,31 +0,0 @@ -// #docregion -// #docregion top -import { Component, Inject } from '@angular/core'; -import { RouteParams } from '@angular/router-deprecated'; - -import { Phones, Phone } from '../core/phones.service'; -import { CheckmarkPipe } from '../core/checkmark.pipe'; - -@Component({ - selector: 'pc-phone-detail', - templateUrl: 'js/phone_detail/phone_detail.html', - pipes: [CheckmarkPipe] -}) -class PhoneDetail { -// #enddocregion top - phone:Phone = undefined; - mainImageUrl:string; - constructor(params:RouteParams, - phones:Phones) { - phones.get(params.get('phoneId')) - .subscribe(phone => { - this.phone = phone; - this.mainImageUrl = phone.images[0]; - }); - } - - setImage(url:string) { - this.mainImageUrl = url; - } -} -export default PhoneDetail; diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/phone_list/phone_list.component.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/phone_list/phone_list.component.ts deleted file mode 100644 index f87aa62efc..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/phone_list/phone_list.component.ts +++ /dev/null @@ -1,29 +0,0 @@ -// #docregion full -// #docregion top -import { Component } from '@angular/core'; -import { RouterLink } from '@angular/router-deprecated'; -import { Observable } from 'rxjs'; - -import { Phones, Phone } from '../core/phones.service'; -import PhoneFilterPipe from './phone_filter.pipe'; -import OrderByPipe from './order_by.pipe'; - -@Component({ - selector: 'pc-phone-list', - templateUrl: 'js/phone_list/phone_list.html', - pipes: [PhoneFilterPipe, OrderByPipe], - directives: [RouterLink] -}) -class PhoneList { -// #enddocregion top - - phones:Observable; - orderProp:string; - query:string; - constructor(phones:Phones) { - this.phones = phones.query(); - this.orderProp = 'age'; - } -} - -export default PhoneList; diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/main.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/main.ts similarity index 91% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/main.ts rename to public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/main.ts index 40ccfa0aac..fcda5350b8 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/main.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/main.ts @@ -5,7 +5,7 @@ import { LocationStrategy, HashLocationStrategy } from '@angular/common'; import { bootstrap } from '@angular/platform-browser-dynamic'; import { ROUTER_PROVIDERS } from '@angular/router-deprecated'; -import { Phones } from './core/phones.service'; +import {Phone} from './core/phone/phone.service'; import AppComponent from './app.component'; // #enddocregion importbootstrap @@ -18,6 +18,6 @@ bootstrap(AppComponent, [ HTTP_PROVIDERS, ROUTER_PROVIDERS, provide(LocationStrategy, {useClass: HashLocationStrategy}), - Phones + Phone ]); // #enddocregion bootstrap diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/unit/phone_detail.component.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-detail/phone-detail.component.spec.ts similarity index 77% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/unit/phone_detail.component.spec.ts rename to public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-detail/phone-detail.component.spec.ts index c8751add62..a08fb622fb 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/unit/phone_detail.component.spec.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-detail/phone-detail.component.spec.ts @@ -1,9 +1,13 @@ +// #docregion + import { provide } from '@angular/core'; + // #docregion routeparams import { RouteParams } from '@angular/router-deprecated'; // #enddocregion routeparams import { HTTP_PROVIDERS } from '@angular/http'; import { Observable } from 'rxjs/Rx'; + import { describe, beforeEachProviders, @@ -13,10 +17,10 @@ import { } from '@angular/core/testing'; import { TestComponentBuilder } from '@angular/compiler/testing'; -import PhoneDetail from '../../app/js/phone_detail/phone_detail.component'; -import { Phones, Phone } from '../../app/js/core/phones.service'; +import PhoneDetail from './phone-detail.component'; +import {Phone, PhoneData} from '../core/phone/phone.service'; -function xyzPhoneData():Phone { +function xyzPhoneData():PhoneData { return { name: 'phone xyz', snippet: '', @@ -24,17 +28,17 @@ function xyzPhoneData():Phone { } } -class MockPhones extends Phones { - get(id):Observable { +class MockPhone extends Phone { + get(id):Observable { return Observable.of(xyzPhoneData()); } } -// #docregion routeparams describe('PhoneDetail', () => { + // #docregion routeparams beforeEachProviders(() => [ - provide(Phones, {useClass: MockPhones}), + provide(Phone, {useClass: MockPhone}), provide(RouteParams, {useValue: new RouteParams({phoneId: 'xyz'})}), HTTP_PROVIDERS ]); @@ -44,7 +48,6 @@ describe('PhoneDetail', () => { return tcb.createAsync(PhoneDetail).then((fixture) => { fixture.detectChanges(); let compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1')).toHaveText(xyzPhoneData().name); }); })); diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-detail/phone-detail.component.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-detail/phone-detail.component.ts new file mode 100644 index 0000000000..b45ce08d6a --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-detail/phone-detail.component.ts @@ -0,0 +1,31 @@ +// #docregion +// #docregion top +import {Component, Inject} from '@angular/core'; +import {RouteParams} from '@angular/router-deprecated'; +import {Phone, PhoneData} from '../core/phone/phone.service'; +import {CheckmarkPipe} from '../core/checkmark/checkmark.pipe'; + +@Component({ + selector: 'phone-detail', + templateUrl: 'phone-detail/phone-detail.template.html', + pipes: [CheckmarkPipe] +}) +// #enddocregion top +export default class PhoneDetail { + phone:PhoneData = undefined; + mainImageUrl:string; + + constructor(routeParams:RouteParams, + phone:Phone) { + phone.get(routeParams.get('phoneId')) + .subscribe(phone => { + this.phone = phone; + this.setImage(phone.images[0]); + }); + } + + setImage(url:string) { + this.mainImageUrl = url; + } + +} diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/phone_detail/phone_detail.html b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-detail/phone-detail.template.html similarity index 100% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/phone_detail/phone_detail.html rename to public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-detail/phone-detail.template.html diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/unit/order_by.pipe.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-list/order-by.pipe.spec.ts similarity index 83% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/unit/order_by.pipe.spec.ts rename to public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-list/order-by.pipe.spec.ts index 416ca0797b..5a64f34c17 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/unit/order_by.pipe.spec.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-list/order-by.pipe.spec.ts @@ -1,9 +1,8 @@ // #docregion import { describe, beforeEachProviders, it, inject } from '@angular/core/testing'; +import OrderByPipe from './order-by.pipe'; -import OrderByPipe from '../../app/js/phone_list/order_by.pipe'; - -describe('OrderByPipe', () => { +describe('OrderByPipe', function() { let input:any[] = [ {name: 'Nexus S', snippet: 'The Nexus S Phone', images: []}, diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/order_by.pipe.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-list/order-by.pipe.ts similarity index 74% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/order_by.pipe.ts rename to public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-list/order-by.pipe.ts index 162b91cf60..3366ceae7a 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/order_by.pipe.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-list/order-by.pipe.ts @@ -1,8 +1,8 @@ // #docregion -import { Pipe } from '@angular/core'; +import { Pipe, PipeTransform } from '@angular/core'; @Pipe({name: 'orderBy'}) -export default class OrderByPipe { +export default class OrderByPipe implements PipeTransform { transform(input:T[], property:string): T[] { if (input) { @@ -15,7 +15,7 @@ export default class OrderByPipe { return 0; } }); - } else { + } else { return input; } } diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/unit/phone_filter.pipe.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-list/phone-filter.pipe.spec.ts similarity index 84% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/unit/phone_filter.pipe.spec.ts rename to public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-list/phone-filter.pipe.spec.ts index 78747b0aa0..e23dd30e3d 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/unit/phone_filter.pipe.spec.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-list/phone-filter.pipe.spec.ts @@ -1,12 +1,11 @@ // #docregion import {describe, beforeEachProviders, it, inject} from '@angular/core/testing'; -import PhoneFilterPipe from '../../app/js/phone_list/phone_filter.pipe'; -import {Phone} from '../../app/js/core/phones.service'; +import PhoneFilterPipe from './phone-filter.pipe'; +import {PhoneData} from '../core/phone/phone.service'; describe('PhoneFilterPipe', function() { - - let phones:Phone[] = [ + let phones:PhoneData[] = [ {name: 'Nexus S', snippet: 'The Nexus S Phone', images: []}, {name: 'Motorola DROID', snippet: 'an Android-for-business smartphone', images: []} ]; diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/phone_filter.pipe.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-list/phone-filter.pipe.ts similarity index 56% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/phone_filter.pipe.ts rename to public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-list/phone-filter.pipe.ts index 9f38608e8f..42b4c1b9c7 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/phone_filter.pipe.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-list/phone-filter.pipe.ts @@ -1,19 +1,19 @@ // #docregion -import { Pipe } from '@angular/core'; -import { Phone } from '../core/phones.service'; +import { Pipe, PipeTransform } from '@angular/core'; +import {PhoneData} from '../core/phone/phone.service'; @Pipe({name: 'phoneFilter'}) -export default class PhoneFilterPipe { +export default class PhoneFilterPipe implements PipeTransform { - transform(input:Phone[], query:string = ''): Phone[] { - if (input) { + transform(input:PhoneData[], query:string): PhoneData[] { + if (query) { query = query.toLowerCase(); return input.filter((phone) => { const name = phone.name.toLowerCase(); const snippet = phone.snippet.toLowerCase(); return name.indexOf(query) >= 0 || snippet.indexOf(query) >= 0; }); - } else { + } else { return input; } } diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/unit/phone_list.component.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-list/phone-list.component.spec.ts similarity index 81% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/unit/phone_list.component.spec.ts rename to public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-list/phone-list.component.spec.ts index f2a294e0e0..15882bc167 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/unit/phone_list.component.spec.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-list/phone-list.component.spec.ts @@ -15,44 +15,42 @@ import { import { MockLocationStrategy } from '@angular/common/testing'; import { TestComponentBuilder } from '@angular/compiler/testing'; -import AppComponent from '../../app/js/app.component'; -import PhoneList from '../../app/js/phone_list/phone_list.component'; -import { Phones, Phone } from '../../app/js/core/phones.service'; +import AppComponent from '../app.component'; +import PhoneList from './phone-list.component'; +import {Phone, PhoneData} from '../core/phone/phone.service'; -class MockPhones extends Phones { - query():Observable { - return Observable.of( - [{name: 'Nexus S', snippet: ''}, {name: 'Motorola DROID', snippet: ''}] - ) + +class MockPhone extends Phone { + query():Observable { + return Observable.of([ + {name: 'Nexus S', snippet: '', images: []}, + {name: 'Motorola DROID', snippet: '', images: []} + ]) } } describe('PhoneList', () => { beforeEachProviders(() => [ + provide(Phone, {useClass: MockPhone}), HTTP_PROVIDERS, ROUTER_PROVIDERS, provide(ApplicationRef, {useClass: MockApplicationRef}), provide(ROUTER_PRIMARY_COMPONENT, {useValue: AppComponent}), provide(LocationStrategy, {useClass: MockLocationStrategy}), - provide(Phones, {useClass: MockPhones}) ]); - it('should create "phones" model with 2 phones fetched from xhr', inject([TestComponentBuilder], (tcb) => { return tcb.createAsync(PhoneList).then((fixture) => { fixture.detectChanges(); - let compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelectorAll('.phone-listing').length).toBe(2); expect(compiled.querySelector('.phone-listing:nth-child(1)').textContent).toContain('Nexus S'); expect(compiled.querySelector('.phone-listing:nth-child(2)').textContent).toContain('Motorola DROID'); }); })); - it('should set the default value of orderProp model', inject([TestComponentBuilder], (tcb) => { return tcb.createAsync(PhoneList).then((fixture) => { diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-list/phone-list.component.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-list/phone-list.component.ts new file mode 100644 index 0000000000..ae77bf4e3e --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-list/phone-list.component.ts @@ -0,0 +1,27 @@ +// #docregion +// #docregion top +import {Component} from '@angular/core'; +import {RouterLink} from '@angular/router-deprecated'; +import {Observable} from 'rxjs/Observable'; +import {Phone, PhoneData} from '../core/phone/phone.service'; +import PhoneFilterPipe from './phone-filter.pipe'; +import OrderByPipe from './order-by.pipe'; + +@Component({ + selector: 'phone-list', + templateUrl: 'phone-list/phone-list.template.html', + pipes: [PhoneFilterPipe, OrderByPipe], + directives: [RouterLink] +}) +// #enddocregion top +export default class PhoneList { + phones:Observable; + orderProp:string; + query:string; + + constructor(phone:Phone) { + this.phones = phone.query(); + this.orderProp = 'age'; + } + +} diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/phone_list/phone_list.html b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-list/phone-list.template.html similarity index 99% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/phone_list/phone_list.html rename to public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-list/phone-list.template.html index e88b4662aa..14b5b39289 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/phone_list/phone_list.html +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/phone-list/phone-list.template.html @@ -15,7 +15,6 @@
-
-
diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/systemjs.config.js b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/systemjs.config.js index d7510ce7c6..5765cb282b 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/systemjs.config.js +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/systemjs.config.js @@ -8,7 +8,7 @@ System.config({ '@angular': pkgPath + '@angular' }, packages: { - 'js': { defaultExtension: 'js' }, + './': { defaultExtension: 'js' }, '@angular/common': { main: 'index.js', defaultExtension: 'js' }, '@angular/compiler': { main: 'index.js', defaultExtension: 'js' }, diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/protractor-conf.js b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/e2e-tests/protractor-conf.js similarity index 85% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/protractor-conf.js rename to public/docs/_examples/upgrade-phonecat/ts/ng2_final/e2e-tests/protractor-conf.js index a1ea324632..35873b4abb 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/protractor-conf.js +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/e2e-tests/protractor-conf.js @@ -2,7 +2,7 @@ exports.config = { allScriptsTimeout: 11000, specs: [ - 'e2e/*.js' + '*.js' ], capabilities: { @@ -15,11 +15,11 @@ exports.config = { framework: 'jasmine', - jasmineNodeOpts: { - defaultTimeoutInterval: 30000 - }, - // #docregion ng2 - useAllAngular2AppRoots: true + useAllAngular2AppRoots: true, // #enddocregion ng2 + + jasmineNodeOpts: { + defaultTimeoutInterval: 30000 + } }; diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/e2e/scenarios.js b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/e2e-tests/scenarios.js similarity index 86% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/e2e/scenarios.js rename to public/docs/_examples/upgrade-phonecat/ts/ng2_final/e2e-tests/scenarios.js index 2e4b884563..624b8ce70a 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/e2e/scenarios.js +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/e2e-tests/scenarios.js @@ -20,6 +20,7 @@ describe('PhoneCat App', function() { browser.get('app/index.html#/phones'); }); + it('should filter the phone list as a user types into the search box', function() { var phoneList = element.all(by.css('.phones li')); var query = element(by.css('input')); @@ -30,17 +31,13 @@ describe('PhoneCat App', function() { expect(phoneList.count()).toBe(1); query.clear(); - // https://github.com/angular/protractor/issues/2019 - var str = 'motorola'; - for (var i = 0; i < str.length; i++) { - query.sendKeys(str.charAt(i)); - } - + query.sendKeys('motorola'); expect(phoneList.count()).toBe(8); }); it('should be possible to control phone order via the drop down select box', function() { + var phoneNameColumn = element.all(by.css('.phones .name')); var query = element(by.css('input')); @@ -50,12 +47,7 @@ describe('PhoneCat App', function() { }); } - //let's narrow the dataset to make the test assertions shorter - // https://github.com/angular/protractor/issues/2019 - var str = 'tablet'; - for (var i = 0; i < str.length; i++) { - query.sendKeys(str.charAt(i)); - } + query.sendKeys('tablet'); //let's narrow the dataset to make the test assertions shorter expect(getNames()).toEqual([ "Motorola XOOM\u2122 with Wi-Fi", @@ -63,13 +55,13 @@ describe('PhoneCat App', function() { ]); element(by.css('select')).element(by.css('option[value="name"]')).click(); + expect(getNames()).toEqual([ "MOTOROLA XOOM\u2122", "Motorola XOOM\u2122 with Wi-Fi" ]); }); - // #docregion links it('should render phone specific links', function() { var query = element(by.css('input')); @@ -83,8 +75,10 @@ describe('PhoneCat App', function() { expect(url.endsWith('/phones/nexus-s')).toBe(true); }); }); + // #enddocregion links + }); - // #enddocregion links + describe('Phone detail view', function() { diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/karma.conf.1.js b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/karma.conf.1.js new file mode 100644 index 0000000000..101d96c8b3 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/karma.conf.1.js @@ -0,0 +1,51 @@ +// #docregion +module.exports = function(config){ + config.set({ + + baseDir: '.', + + // #docregion ng2 + files : [ + // #enddocregion ng2 + 'node_modules/systemjs/dist/system-polyfills.js', + 'node_modules/systemjs/dist/system.src.js', + // #docregion ng2 + 'node_modules/es6-shim/es6-shim.js', + 'node_modules/zone.js/dist/zone.js', + 'node_modules/reflect-metadata/Reflect.js', + {pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false}, + {pattern: 'node_modules/@angular/**/*.js', included: false, watched: false}, + // #enddocregion ng2 + 'karma_test_shim.js', + {pattern: 'app/**/*.module.js', included: false, watched: true}, + {pattern: 'app/*!(.module|.spec).js', included: false, watched: true}, + {pattern: 'app/!(bower_components)/**/*!(.module|.spec).js', included: false, watched: true}, + {pattern: 'app/**/*.spec.js', included: false, watched: true}, + {pattern: 'app/**/*.html', included: false, watched: true} + // #docregion ng2 + ], + // #enddocregion ng2 + + proxies: { + // required for component assets fetched by Angular's compiler + "/": "/base/app/" + }, + + autoWatch : true, + + frameworks: ['jasmine'], + + browsers : ['Chrome', 'Firefox'], + + plugins : [ + 'karma-chrome-launcher', + 'karma-firefox-launcher', + 'karma-jasmine' + ], + + junitReporter : { + outputFile: 'test_out/unit.xml', + suite: 'unit' + } + }); +}; diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/karma_test_shim.js b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/karma_test_shim.js similarity index 85% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/karma_test_shim.js rename to public/docs/_examples/upgrade-phonecat/ts/ng2_final/karma_test_shim.js index 26075e973d..edb4033652 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/karma_test_shim.js +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/karma_test_shim.js @@ -5,11 +5,11 @@ __karma__.loaded = function() {}; System.config({ map: { - 'rxjs': 'base/node_modules/rxjs', - '@angular': 'base/node_modules/@angular' + 'rxjs': 'base/node_modules/rxjs', + '@angular': 'base/node_modules/@angular' }, packages: { - 'base/app/js': { + 'base': { defaultExtension: false, format: 'register', map: Object.keys(window.__karma__.files). @@ -17,7 +17,7 @@ System.config({ reduce(function createPathRecords(pathsMapping, appPath) { // creates local module name mapping to global path with karma's fingerprint in path, e.g.: // './hero.service': '/base/src/app/hero.service.js?f4523daf879cfb7310ef6242682ccf10b2041b3e' - var moduleName = appPath.replace(/^\/base\/app\/js\//, './').replace(/\.js$/, ''); + var moduleName = appPath.replace(/^\/base\//, './').replace(/\.js$/, ''); pathsMapping[moduleName] = appPath + '?' + window.__karma__.files[appPath] return pathsMapping; }, {}) @@ -42,22 +42,22 @@ System.import('@angular/core/testing').then(function(testing) { browserTesting.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS); }); }).then(function() { - return Promise.all( + Promise.all( Object.keys(window.__karma__.files) // All files served by Karma. .filter(onlySpecFiles) .map(function(moduleName) { // loads all spec files via their global module names return System.import(moduleName); - })); -}).then(function() { - __karma__.start(); -}, function(error) { - __karma__.error(error.stack || error); + })) + .then(function() { + __karma__.start(); + }, function(error) { + __karma__.error(error.stack || error); + }); }); -// #enddocregion ng2 function onlyAppFiles(filePath) { - return /^\/base\/app\/js\/.*\.js$/.test(filePath) + return /^\/base\/.*\.(?!\.spec\.)js$/.test(filePath) } function onlySpecFiles(path) { diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/package.1.json b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/package.1.json index 0f07a065d2..7351dff732 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/package.1.json +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/package.1.json @@ -28,9 +28,6 @@ "karma-firefox-launcher": "^0.1.3", "karma-jasmine": "~0.3.7", "protractor": "^3.0.0", - "http-server": "^0.6.1", - "tmp": "0.0.23", - "bower": "^1.3.1", "shelljs": "^0.2.6", "typescript": "1.8.10", "typings": "^0.7.12" @@ -40,15 +37,13 @@ "start": "http-server -a 0.0.0.0 -p 8000", - "test": "node node_modules/karma/bin/karma start test/karma.conf.js", - "test-single-run": "node node_modules/karma/bin/karma start test/karma.conf.js --single-run", + "test": "node node_modules/karma/bin/karma start karma.conf.js", + "test-single-run": "node node_modules/karma/bin/karma start karma.conf.js --single-run", "preupdate-webdriver": "npm install", "update-webdriver": "webdriver-manager update", - "preprotractor": "npm run update-webdriver", - "protractor": "protractor test/protractor-conf.js", - + "protractor": "protractor e2e-tests/protractor-conf.js", "typings": "typings", "tsc": "tsc -p . -w" } diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/unit/phones.service.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/unit/phones.service.spec.ts deleted file mode 100644 index 8d3fc5270f..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/unit/phones.service.spec.ts +++ /dev/null @@ -1,16 +0,0 @@ -// #docregion -import { describe, beforeEachProviders, it, inject } from '@angular/core/testing'; -import { HTTP_PROVIDERS } from '@angular/http'; -import { Phones } from '../../app/js/core/phones.service'; - -describe('Phones', () => { - - // load providers - beforeEachProviders(() => [Phones, HTTP_PROVIDERS]); - - // Test service availability - it('check the existence of Phones', inject([Phones], (phones) => { - expect(phones).toBeDefined(); - })); - -}); diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/css/animations.css b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/app.animations.css similarity index 100% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/css/animations.css rename to public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/app.animations.css diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/app.config.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/app.config.ts new file mode 100644 index 0000000000..9b99261074 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/app.config.ts @@ -0,0 +1,12 @@ +// #docregion +export default ['$routeProvider', + function config($routeProvider) { + $routeProvider. + when('/phones', { + template: '' + }). + when('/phones/:phoneId', { + template: '' + }). + otherwise('/phones'); +}]; diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/css/app.css b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/app.css similarity index 97% rename from public/docs/_examples/upgrade-phonecat/ts/classes/app/css/app.css rename to public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/app.css index 951ea087cc..f41c420776 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/classes/app/css/app.css +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/app.css @@ -44,7 +44,7 @@ img.phone { display: none; } -img.phone:first-child { +img.phone:first-of-type { display: block; } diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/app.module.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/app.module.ts new file mode 100644 index 0000000000..55e4c30b6c --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/app.module.ts @@ -0,0 +1,29 @@ +// #docregion http-import +import {HTTP_PROVIDERS} from '@angular/http'; +// #enddocregion http-import +// #docregion adapter-import +import {UpgradeAdapter} from '@angular/upgrade'; +// #enddocregion adapter-import +// #docregion adapter-state-import +import upgradeAdapter from './core/upgrade-adapter'; +// #enddocregion adapter-state-import +import core from './core/core.module'; +import phoneList from './phone-list/phone-list.module'; +import phoneDetail from './phone-detail/phone-detail.module'; +import appConfig from './app.config'; + +angular.module('phonecatApp', [ + 'ngAnimate', + 'ngRoute', + core.name, + phoneList.name, + phoneDetail.name +]).config(appConfig); + +// #docregion add-http-providers +upgradeAdapter.addProvider(HTTP_PROVIDERS); +// #enddocregion add-http-providers + +// #docregion bootstrap +upgradeAdapter.bootstrap(document.documentElement, ['phonecatApp']); +// #enddocregion bootstrap diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/unit/checkmark.filter.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/core/checkmark/checkmark.filter.spec.ts similarity index 76% rename from public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/unit/checkmark.filter.spec.ts rename to public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/core/checkmark/checkmark.filter.spec.ts index bae35e6875..6704c74999 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/unit/checkmark.filter.spec.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/core/checkmark/checkmark.filter.spec.ts @@ -1,10 +1,10 @@ // #docregion top -import '../../app/js/core/core.module'; +import '../core.module'; // #enddocregion top describe('checkmarkFilter', function() { - beforeEach(angular.mock.module('phonecat.core')); + beforeEach(angular.mock.module('core')); it('should convert boolean values to unicode checkmark or cross', inject(function(checkmarkFilter) { diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/core/checkmark.filter.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/core/checkmark/checkmark.filter.ts similarity index 71% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/core/checkmark.filter.ts rename to public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/core/checkmark/checkmark.filter.ts index 84544b80a1..cd0215064f 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/core/checkmark.filter.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/core/checkmark/checkmark.filter.ts @@ -1,6 +1,6 @@ // #docregion export default function checkmarkFilter() { - return function(input:string):string { + return function(input:boolean):string { return input ? '\u2713' : '\u2718'; }; } diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/core/core.module.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/core/core.module.ts new file mode 100644 index 0000000000..041f56ea79 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/core/core.module.ts @@ -0,0 +1,6 @@ +// #docregion +import checkmarkFilter from './checkmark/checkmark.filter'; +import phone from './phone/phone.module'; + +export default angular.module('core', [phone.name]) + .filter('checkmark', checkmarkFilter); diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/core/phone/phone.module.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/core/phone/phone.module.ts new file mode 100644 index 0000000000..7b8d127731 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/core/phone/phone.module.ts @@ -0,0 +1,8 @@ +// #docregion +import {Phone} from './phone.service'; +import upgradeAdapter from '../upgrade-adapter'; + +upgradeAdapter.addProvider(Phone); + +export default angular.module('core.phone', []) + .factory('phone', upgradeAdapter.downgradeNg2Provider(Phone)); diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/core/phone/phone.service.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/core/phone/phone.service.spec.ts new file mode 100644 index 0000000000..e0dceedfa3 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/core/phone/phone.service.spec.ts @@ -0,0 +1,43 @@ +// #docregion +import {provide} from '@angular/core'; +import {describe, beforeEach, beforeEachProviders, it, inject} from '@angular/core/testing'; +import {Http, BaseRequestOptions, ResponseOptions, Response} from '@angular/http'; +import {MockBackend} from '@angular/http/testing'; +import {Phone, PhoneData} from './phone.service'; + +describe('Phone', function() { + var phone; + var phonesData:PhoneData[] = [ + {name: 'Phone X', snippet: '', images: []}, + {name: 'Phone Y', snippet: '', images: []}, + {name: 'Phone Z', snippet: '', images: []} + ]; + var mockBackend; + + // load providers + beforeEachProviders(() => [ + Phone, + MockBackend, + BaseRequestOptions, + provide(Http, { + useFactory: (backend, options) => new Http(backend, options), + deps: [MockBackend, BaseRequestOptions] + }) + ]); + + beforeEach(inject([MockBackend, Phone], (_mockBackend_, _phone_) => { + mockBackend = _mockBackend_; + phone = _phone_; + })); + + it('should fetch the phones data from `/phones/phones.json`', (done) => { + mockBackend.connections.subscribe(connection => { + connection.mockRespond(new Response(new ResponseOptions({body: JSON.stringify(phonesData)}))); + }); + phone.query().subscribe(result => { + expect(result).toEqual(phonesData); + done(); + }); + }); + +}); diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/core/phones.service.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/core/phone/phone.service.ts similarity index 52% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/core/phones.service.ts rename to public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/core/phone/phone.service.ts index d292bc54ee..e47358c75e 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/core/phones.service.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/core/phone/phone.service.ts @@ -1,37 +1,35 @@ -// #docregion full -import { Injectable } from '@angular/core'; -import { Http, Response } from '@angular/http'; -import { Observable } from 'rxjs/Rx'; +// #docregion +import {Injectable} from '@angular/core'; +import {Http, Response} from '@angular/http'; +import {Observable} from 'rxjs/Rx'; import 'rxjs/add/operator/map'; -// #docregion phone-interface -export interface Phone { +// #docregion phonedata-interface +export interface PhoneData { name: string; - snippet?: string; - images?: string[]; + snippet: string; + images: string[]; } -// #enddocregion phone-interface +// #enddocregion phonedata-interface -// #docregion fullclass // #docregion class +// #docregion fullclass @Injectable() -export class Phones { +export class Phone { // #enddocregion class constructor(private http: Http) { } - query():Observable { + query():Observable { return this.http.get(`phones/phones.json`) .map((res:Response) => res.json()); } - get(id: string):Observable { + get(id: string):Observable { return this.http.get(`phones/${id}.json`) .map((res:Response) => res.json()); } - // #docregion class } -// #enddocregion class // #enddocregion fullclass -// #docregion full +// #enddocregion class diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/core/upgrade_adapter.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/core/upgrade-adapter.ts similarity index 59% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/core/upgrade_adapter.ts rename to public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/core/upgrade-adapter.ts index f1ad63012a..f5659ad5b4 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/core/upgrade_adapter.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/core/upgrade-adapter.ts @@ -1,9 +1,8 @@ -// #docregion full -import { UpgradeAdapter } from '@angular/upgrade'; +// #docregion +import {UpgradeAdapter} from '@angular/upgrade'; // #docregion adapter-init const upgradeAdapter = new UpgradeAdapter(); // #enddocregion adapter-init export default upgradeAdapter; -// #enddocregion full diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/css/.gitkeep b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/css/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/index.html b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/index.html index 5a79c8007f..36cafbac01 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/index.html +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/index.html @@ -4,8 +4,8 @@ Google Phone Gallery - - + + @@ -22,9 +22,9 @@ - + diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/core/core.module.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/core/core.module.ts deleted file mode 100644 index e02e7dcf1a..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/core/core.module.ts +++ /dev/null @@ -1,10 +0,0 @@ -// #docregion -import { Phones } from './phones.service'; -import checkmarkFilter from './checkmark.filter'; -import upgradeAdapter from './upgrade_adapter'; - -upgradeAdapter.addProvider(Phones); - -export default angular.module('phonecat.core', []) - .factory('phones', upgradeAdapter.downgradeNg2Provider(Phones)) - .filter('checkmark', checkmarkFilter); diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/phone_detail/phone_detail.controller.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/phone_detail/phone_detail.controller.ts deleted file mode 100644 index ef24ac5814..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/phone_detail/phone_detail.controller.ts +++ /dev/null @@ -1,25 +0,0 @@ -// #docregion -import { Phones, Phone } from '../core/phones.service'; - -interface PhoneRouteParams { - phoneId: string -} - -class PhoneDetailCtrl { - phone:Phone; - mainImageUrl:string; - constructor($routeParams:PhoneRouteParams, phones:Phones) { - phones.get($routeParams.phoneId) - .subscribe(phone => { - this.phone = phone; - this.mainImageUrl = phone.images[0]; - }); - } - setImage(url:string) { - this.mainImageUrl = url; - } -} - -PhoneDetailCtrl.$inject = ['$routeParams', 'phones']; - -export default PhoneDetailCtrl; diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/phone_detail/phone_detail.html b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/phone_detail/phone_detail.html deleted file mode 100644 index 954c65c2cd..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/phone_detail/phone_detail.html +++ /dev/null @@ -1,118 +0,0 @@ -
- -
- -

{{vm.phone.name}}

- -

{{vm.phone.description}}

- -
    -
  • - -
  • -
- -
    -
  • - Availability and Networks -
    -
    Availability
    -
    {{availability}}
    -
    -
  • -
  • - Battery -
    -
    Type
    -
    {{vm.phone.battery.type}}
    -
    Talk Time
    -
    {{vm.phone.battery.talkTime}}
    -
    Standby time (max)
    -
    {{vm.phone.battery.standbyTime}}
    -
    -
  • -
  • - Storage and Memory -
    -
    RAM
    -
    {{vm.phone.storage.ram}}
    -
    Internal Storage
    -
    {{vm.phone.storage.flash}}
    -
    -
  • -
  • - Connectivity -
    -
    Network Support
    -
    {{vm.phone.connectivity.cell}}
    -
    WiFi
    -
    {{vm.phone.connectivity.wifi}}
    -
    Bluetooth
    -
    {{vm.phone.connectivity.bluetooth}}
    -
    Infrared
    -
    {{vm.phone.connectivity.infrared | checkmark}}
    -
    GPS
    -
    {{vm.phone.connectivity.gps | checkmark}}
    -
    -
  • -
  • - Android -
    -
    OS Version
    -
    {{vm.phone.android.os}}
    -
    UI
    -
    {{vm.phone.android.ui}}
    -
    -
  • -
  • - Size and Weight -
    -
    Dimensions
    -
    {{dim}}
    -
    Weight
    -
    {{vm.phone.sizeAndWeight.weight}}
    -
    -
  • -
  • - Display -
    -
    Screen size
    -
    {{vm.phone.display.screenSize}}
    -
    Screen resolution
    -
    {{vm.phone.display.screenResolution}}
    -
    Touch screen
    -
    {{vm.phone.display.touchScreen | checkmark}}
    -
    -
  • -
  • - Hardware -
    -
    CPU
    -
    {{vm.phone.hardware.cpu}}
    -
    USB
    -
    {{vm.phone.hardware.usb}}
    -
    Audio / headphone jack
    -
    {{vm.phone.hardware.audioJack}}
    -
    FM Radio
    -
    {{vm.phone.hardware.fmRadio | checkmark}}
    -
    Accelerometer
    -
    {{vm.phone.hardware.accelerometer | checkmark}}
    -
    -
  • -
  • - Camera -
    -
    Primary
    -
    {{vm.phone.camera.primary}}
    -
    Features
    -
    {{vm.phone.camera.features.join(', ')}}
    -
    -
  • -
  • - Additional Features -
    {{vm.phone.additionalFeatures}}
    -
  • -
diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/phone_detail/phone_detail.module.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/phone_detail/phone_detail.module.ts deleted file mode 100644 index 16e7ac0baf..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/phone_detail/phone_detail.module.ts +++ /dev/null @@ -1,8 +0,0 @@ -// #docregion -import PhoneDetailCtrl from './phone_detail.controller'; - -export default angular.module('phonecat.detail', [ - 'ngRoute', - 'phonecat.core' - ]) - .controller('PhoneDetailCtrl', PhoneDetailCtrl); diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/phone_list/phone_list.controller.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/phone_list/phone_list.controller.ts deleted file mode 100644 index ae4c39b0c9..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/phone_list/phone_list.controller.ts +++ /dev/null @@ -1,17 +0,0 @@ -// #docregion -import { Phones, Phone } from '../core/phones.service'; - -class PhoneListCtrl { - phones:Phone[]; - orderProp:string; - query:string; - constructor(phones:Phones) { - phones.query() - .subscribe(phones => this.phones = phones); - this.orderProp = 'age'; - } -} - -PhoneListCtrl.$inject = ['phones']; - -export default PhoneListCtrl; diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/phone_list/phone_list.module.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/phone_list/phone_list.module.ts deleted file mode 100644 index d2e7200778..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/phone_list/phone_list.module.ts +++ /dev/null @@ -1,5 +0,0 @@ -// #docregion -import PhoneListCtrl from './phone_list.controller'; - -export default angular.module('phonecat.list', []) - .controller('PhoneListCtrl', PhoneListCtrl); diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-detail/phone-detail.component.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-detail/phone-detail.component.spec.ts new file mode 100644 index 0000000000..0d6cc5f4d1 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-detail/phone-detail.component.spec.ts @@ -0,0 +1,42 @@ +// #docregion +import {Observable} from 'rxjs/Rx' +import './phone-detail.module'; +import {Phone, PhoneData} from '../core/phone/phone.service'; + +describe('phoneDetail', function(){ + + // Load the module that contains the `phoneDetail` component before each test + beforeEach(angular.mock.module('phoneDetail')); + + // Supply a hand-instantianted instance of the Phone service + beforeEach(angular.mock.module(function($provide) { + $provide.value('phone', new Phone(null)); + })); + + // Test the controller + describe('PhoneDetailController', function() { + var $componentController, phone; + var xyzPhoneData:PhoneData = { + name: 'phone xyz', + snippet: '', + images: ['image/url1.png', 'image/url2.png'] + }; + + beforeEach(inject(function(_$componentController_, _phone_, $routeParams) { + $componentController = _$componentController_; + phone = _phone_; + $routeParams.phoneId = 'xyz'; + })); + + it('should fetch the phone details', function() { + spyOn(phone, 'get').and.returnValue(Observable.of(xyzPhoneData)); + + let ctrl = $componentController('phoneDetail', {$scope: {}}); + + expect(phone.get).toHaveBeenCalledWith('xyz'); + expect(ctrl.phone).toEqual(xyzPhoneData); + }); + + }); + +}); diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-detail/phone-detail.component.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-detail/phone-detail.component.ts new file mode 100644 index 0000000000..aaae28ce22 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-detail/phone-detail.component.ts @@ -0,0 +1,29 @@ +// #docregion +import {Phone, PhoneData} from '../core/phone/phone.service'; + +interface PhoneRouteParams { + phoneId: string +} + +class PhoneDetailController { + phone:PhoneData; + mainImageUrl:string; + + static $inject = ['$routeParams', 'phone']; + constructor($routeParams:PhoneRouteParams, phone:Phone) { + phone.get($routeParams.phoneId).subscribe(phone => { + this.phone = phone; + this.setImage(phone.images[0]); + }); + } + + setImage(imageUrl) { + this.mainImageUrl = imageUrl; + } + +} + +export default { + templateUrl: 'phone-detail/phone-detail.template.html', + controller: PhoneDetailController +}; diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-detail/phone-detail.module.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-detail/phone-detail.module.ts new file mode 100644 index 0000000000..d9e95c0761 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-detail/phone-detail.module.ts @@ -0,0 +1,9 @@ +// #docregion +import phoneDetail from './phone-detail.component'; +import phone from '../core/phone/phone.module'; + +export default angular.module('phoneDetail', [ + 'ngRoute', + phone.name + ]) + .component('phoneDetail', phoneDetail); diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-detail/phone-detail.template.html b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-detail/phone-detail.template.html new file mode 100644 index 0000000000..019ccf45c7 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-detail/phone-detail.template.html @@ -0,0 +1,118 @@ +
+ +
+ +

{{$ctrl.phone.name}}

+ +

{{$ctrl.phone.description}}

+ +
    +
  • + +
  • +
+ +
    +
  • + Availability and Networks +
    +
    Availability
    +
    {{availability}}
    +
    +
  • +
  • + Battery +
    +
    Type
    +
    {{$ctrl.phone.battery.type}}
    +
    Talk Time
    +
    {{$ctrl.phone.battery.talkTime}}
    +
    Standby time (max)
    +
    {{$ctrl.phone.battery.standbyTime}}
    +
    +
  • +
  • + Storage and Memory +
    +
    RAM
    +
    {{$ctrl.phone.storage.ram}}
    +
    Internal Storage
    +
    {{$ctrl.phone.storage.flash}}
    +
    +
  • +
  • + Connectivity +
    +
    Network Support
    +
    {{$ctrl.phone.connectivity.cell}}
    +
    WiFi
    +
    {{$ctrl.phone.connectivity.wifi}}
    +
    Bluetooth
    +
    {{$ctrl.phone.connectivity.bluetooth}}
    +
    Infrared
    +
    {{$ctrl.phone.connectivity.infrared | checkmark}}
    +
    GPS
    +
    {{$ctrl.phone.connectivity.gps | checkmark}}
    +
    +
  • +
  • + Android +
    +
    OS Version
    +
    {{$ctrl.phone.android.os}}
    +
    UI
    +
    {{$ctrl.phone.android.ui}}
    +
    +
  • +
  • + Size and Weight +
    +
    Dimensions
    +
    {{dim}}
    +
    Weight
    +
    {{$ctrl.phone.sizeAndWeight.weight}}
    +
    +
  • +
  • + Display +
    +
    Screen size
    +
    {{$ctrl.phone.display.screenSize}}
    +
    Screen resolution
    +
    {{$ctrl.phone.display.screenResolution}}
    +
    Touch screen
    +
    {{$ctrl.phone.display.touchScreen | checkmark}}
    +
    +
  • +
  • + Hardware +
    +
    CPU
    +
    {{$ctrl.phone.hardware.cpu}}
    +
    USB
    +
    {{$ctrl.phone.hardware.usb}}
    +
    Audio / headphone jack
    +
    {{$ctrl.phone.hardware.audioJack}}
    +
    FM Radio
    +
    {{$ctrl.phone.hardware.fmRadio | checkmark}}
    +
    Accelerometer
    +
    {{$ctrl.phone.hardware.accelerometer | checkmark}}
    +
    +
  • +
  • + Camera +
    +
    Primary
    +
    {{$ctrl.phone.camera.primary}}
    +
    Features
    +
    {{$ctrl.phone.camera.features.join(', ')}}
    +
    +
  • +
  • + Additional Features +
    {{$ctrl.phone.additionalFeatures}}
    +
  • +
diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-list/phone-list.component.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-list/phone-list.component.spec.ts new file mode 100644 index 0000000000..a3941d6d93 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-list/phone-list.component.spec.ts @@ -0,0 +1,37 @@ +// #docregion +import {Observable} from 'rxjs/Rx'; +import './phone-list.module'; +import {Phone, PhoneData} from '../core/phone/phone.service'; + +describe('phoneList', function() { + + // Load the module that contains the `phoneList` component before each test + beforeEach(angular.mock.module('phoneList')); + + // Supply a hand-instantianted instance of the Phone service + beforeEach(angular.mock.module(function($provide) { + $provide.value('phone', new Phone(null)); + })); + + // Test the controller + describe('PhoneListController', function() { + var ctrl; + + beforeEach(inject(function($componentController, phone) { + spyOn(phone, 'query').and.returnValue(Observable.of( + [{name: 'Nexus S'}, {name: 'Motorola DROID'}] + )); + ctrl = $componentController('phoneList', {$scope: {}}); + })); + + it('should create a `phones` model with 2 phones fetched with `$http`', function() { + expect(ctrl.phones).toEqual([{name: 'Nexus S'}, {name: 'Motorola DROID'}]); + }); + + it('should set a default value for the `orderProp` model', function() { + expect(ctrl.orderProp).toBe('age'); + }); + + }); + +}); diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-list/phone-list.component.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-list/phone-list.component.ts new file mode 100644 index 0000000000..b9a10cf288 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-list/phone-list.component.ts @@ -0,0 +1,22 @@ +import {Phone, PhoneData} from '../core/phone/phone.service'; + +// #docregion +class PhoneListController { + phones:PhoneData[]; + orderProp:string; + query:string; + + static $inject = ['phone']; + constructor(phone:Phone) { + phone.query().subscribe(phones => { + this.phones = phones; + }); + this.orderProp = 'age'; + } + +} + +export default { + templateUrl: 'phone-list/phone-list.template.html', + controller: PhoneListController +}; diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-list/phone-list.module.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-list/phone-list.module.ts new file mode 100644 index 0000000000..feae92f9af --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-list/phone-list.module.ts @@ -0,0 +1,6 @@ +// #docregion +import phoneList from './phone-list.component'; +import phone from '../core/phone/phone.module'; + +export default angular.module('phoneList', [phone.name]) + .component('phoneList', phoneList); diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/phone_list/phone_list.html b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-list/phone-list.template.html similarity index 77% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/phone_list/phone_list.html rename to public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-list/phone-list.template.html index 471f474e89..95283ee032 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/phone_list/phone_list.html +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/phone-list/phone-list.template.html @@ -3,9 +3,9 @@
- Search: + Search: Sort by: - @@ -15,7 +15,7 @@
    -
  • {{phone.name}} diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/systemjs.config.js b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/systemjs.config.js index 2b0b854f6a..2de98008c9 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/systemjs.config.js +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/systemjs.config.js @@ -9,7 +9,7 @@ System.config({ '@angular': pkgPath + '@angular' }, packages: { - 'js': { defaultExtension: 'js' }, + './': { defaultExtension: 'js' }, '@angular/common': { main: 'index.js', defaultExtension: 'js' }, '@angular/compiler': { main: 'index.js', defaultExtension: 'js' }, diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/test/protractor-conf.js b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/e2e-tests/protractor-conf.js similarity index 86% rename from public/docs/_examples/upgrade-phonecat/ts/classes/test/protractor-conf.js rename to public/docs/_examples/upgrade-phonecat/ts/ng2_initial/e2e-tests/protractor-conf.js index 118c7b9ec2..6252ae848e 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/classes/test/protractor-conf.js +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/e2e-tests/protractor-conf.js @@ -2,15 +2,15 @@ exports.config = { allScriptsTimeout: 11000, specs: [ - 'e2e/*.js' + '*.js' ], capabilities: { 'browserName': 'chrome' }, - chromeOnly: true, - + directConnect: true, + baseUrl: 'http://localhost:8000/', framework: 'jasmine', diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/test/e2e/scenarios.js b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/e2e-tests/scenarios.js similarity index 79% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_initial/test/e2e/scenarios.js rename to public/docs/_examples/upgrade-phonecat/ts/ng2_initial/e2e-tests/scenarios.js index f20d0a294c..81f2d9f7fc 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/test/e2e/scenarios.js +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/e2e-tests/scenarios.js @@ -18,9 +18,10 @@ describe('PhoneCat App', function() { browser.get('app/index.html#/phones'); }); + it('should filter the phone list as a user types into the search box', function() { - var phoneList = element.all(by.repeater('phone in vm.phones')); - var query = element(by.model('vm.query')); + var phoneList = element.all(by.css('.phones li')); + var query = element(by.css('input')); expect(phoneList.count()).toBe(20); @@ -35,8 +36,8 @@ describe('PhoneCat App', function() { it('should be possible to control phone order via the drop down select box', function() { - var phoneNameColumn = element.all(by.repeater('phone in vm.phones').column(0)); - var query = element(by.model('vm.query')); + var phoneNameColumn = element.all(by.css('.phones .name')); + var query = element(by.css('input')); function getNames() { return phoneNameColumn.map(function(elm) { @@ -51,7 +52,7 @@ describe('PhoneCat App', function() { "MOTOROLA XOOM\u2122" ]); - element(by.model('vm.orderProp')).element(by.css('option[value="name"]')).click(); + element(by.css('select')).element(by.css('option[value="name"]')).click(); expect(getNames()).toEqual([ "MOTOROLA XOOM\u2122", @@ -61,7 +62,7 @@ describe('PhoneCat App', function() { it('should render phone specific links', function() { - var query = element(by.model('vm.query')); + var query = element(by.css('input')); query.sendKeys('nexus'); element.all(by.css('.phones li a')).first().click(); browser.getLocationAbsUrl().then(function(url) { @@ -79,7 +80,7 @@ describe('PhoneCat App', function() { it('should display nexus-s page', function() { - expect(element(by.binding('vm.phone.name')).getText()).toBe('Nexus S'); + expect(element(by.css('h1')).getText()).toBe('Nexus S'); }); @@ -89,10 +90,10 @@ describe('PhoneCat App', function() { it('should swap main image if a thumbnail image is clicked on', function() { - element(by.css('.phone-thumbs li:nth-child(3) img')).click(); + element(by.css('.phone-thumbs li:nth-of-type(3) img')).click(); expect(element(by.css('img.phone.active')).getAttribute('src')).toMatch(/img\/phones\/nexus-s.2.jpg/); - element(by.css('.phone-thumbs li:nth-child(1) img')).click(); + element(by.css('.phone-thumbs li:nth-of-type(1) img')).click(); expect(element(by.css('img.phone.active')).getAttribute('src')).toMatch(/img\/phones\/nexus-s.0.jpg/); }); }); diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/karma.conf.1.js b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/karma.conf.1.js new file mode 100644 index 0000000000..5acbe3ce0e --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/karma.conf.1.js @@ -0,0 +1,50 @@ +// #docregion +module.exports = function(config){ + config.set({ + + baseDir: '.', + + // #docregion ng2 + files : [ + // #enddocregion ng2 + 'app/bower_components/angular/angular.js', + 'app/bower_components/angular-route/angular-route.js', + 'app/bower_components/angular-resource/angular-resource.js', + 'app/bower_components/angular-animate/angular-animate.js', + 'app/bower_components/angular-mocks/angular-mocks.js', + 'node_modules/systemjs/dist/system-polyfills.js', + 'node_modules/systemjs/dist/system.src.js', + // #docregion ng2 + 'node_modules/es6-shim/es6-shim.js', + 'node_modules/zone.js/dist/zone.js', + 'node_modules/reflect-metadata/Reflect.js', + {pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false}, + {pattern: 'node_modules/@angular/**/*.js', included: false, watched: false}, + // #enddocregion ng2 + 'karma_test_shim.js', + {pattern: 'app/**/*.module.js', included: false, watched: true}, + {pattern: 'app/*!(.module|.spec).js', included: false, watched: true}, + {pattern: 'app/!(bower_components)/**/*!(.module|.spec).js', included: false, watched: true}, + {pattern: 'app/**/*.spec.js', included: false, watched: true} + // #docregion ng2 + ], + // #enddocregion ng2 + + autoWatch : true, + + frameworks: ['jasmine'], + + browsers : ['Chrome', 'Firefox'], + + plugins : [ + 'karma-chrome-launcher', + 'karma-firefox-launcher', + 'karma-jasmine' + ], + + junitReporter : { + outputFile: 'test_out/unit.xml', + suite: 'unit' + } + }); +}; diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/test/karma_test_shim.js b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/karma_test_shim.js similarity index 85% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_initial/test/karma_test_shim.js rename to public/docs/_examples/upgrade-phonecat/ts/ng2_initial/karma_test_shim.js index 26075e973d..edb4033652 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/test/karma_test_shim.js +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/karma_test_shim.js @@ -5,11 +5,11 @@ __karma__.loaded = function() {}; System.config({ map: { - 'rxjs': 'base/node_modules/rxjs', - '@angular': 'base/node_modules/@angular' + 'rxjs': 'base/node_modules/rxjs', + '@angular': 'base/node_modules/@angular' }, packages: { - 'base/app/js': { + 'base': { defaultExtension: false, format: 'register', map: Object.keys(window.__karma__.files). @@ -17,7 +17,7 @@ System.config({ reduce(function createPathRecords(pathsMapping, appPath) { // creates local module name mapping to global path with karma's fingerprint in path, e.g.: // './hero.service': '/base/src/app/hero.service.js?f4523daf879cfb7310ef6242682ccf10b2041b3e' - var moduleName = appPath.replace(/^\/base\/app\/js\//, './').replace(/\.js$/, ''); + var moduleName = appPath.replace(/^\/base\//, './').replace(/\.js$/, ''); pathsMapping[moduleName] = appPath + '?' + window.__karma__.files[appPath] return pathsMapping; }, {}) @@ -42,22 +42,22 @@ System.import('@angular/core/testing').then(function(testing) { browserTesting.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS); }); }).then(function() { - return Promise.all( + Promise.all( Object.keys(window.__karma__.files) // All files served by Karma. .filter(onlySpecFiles) .map(function(moduleName) { // loads all spec files via their global module names return System.import(moduleName); - })); -}).then(function() { - __karma__.start(); -}, function(error) { - __karma__.error(error.stack || error); + })) + .then(function() { + __karma__.start(); + }, function(error) { + __karma__.error(error.stack || error); + }); }); -// #enddocregion ng2 function onlyAppFiles(filePath) { - return /^\/base\/app\/js\/.*\.js$/.test(filePath) + return /^\/base\/.*\.(?!\.spec\.)js$/.test(filePath) } function onlySpecFiles(path) { diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/package.1.json b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/package.1.json index 501da397e3..fd751b2c2d 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/package.1.json +++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/package.1.json @@ -23,33 +23,28 @@ "systemjs": "0.19.26" }, "devDependencies": { + "bower": "^1.3.1", "karma": "^0.13.22", "karma-chrome-launcher": "^0.1.4", "karma-firefox-launcher": "^0.1.3", "karma-jasmine": "~0.3.7", "protractor": "^3.0.0", - "http-server": "^0.6.1", - "tmp": "0.0.23", - "bower": "^1.3.1", "shelljs": "^0.2.6", "typescript": "1.8.10", "typings": "^0.7.12" }, "scripts": { "postinstall": "bower install", - "prestart": "npm install", "start": "http-server -a 0.0.0.0 -p 8000", - "test": "node node_modules/karma/bin/karma start test/karma.conf.js", - "test-single-run": "node node_modules/karma/bin/karma start test/karma.conf.js --single-run", + "test": "node node_modules/karma/bin/karma start karma.conf.js", + "test-single-run": "node node_modules/karma/bin/karma start karma.conf.js --single-run", "preupdate-webdriver": "npm install", "update-webdriver": "webdriver-manager update", - "preprotractor": "npm run update-webdriver", - "protractor": "protractor test/protractor-conf.js", - + "protractor": "protractor e2e-tests/protractor-conf.js", "typings": "typings", "tsc": "tsc -p . -w" } diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/test/unit/phone_detail.controller.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/test/unit/phone_detail.controller.spec.ts deleted file mode 100644 index b28fc2d8c4..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/test/unit/phone_detail.controller.spec.ts +++ /dev/null @@ -1,41 +0,0 @@ -// #docregion -import { Observable } from 'rxjs/Rx'; -import '../../app/js/phone_detail/phone_detail.module'; -import { Phones } from '../../app/js/core/phones.service'; - -describe('PhoneDetailCtrl', () => { - var scope, phones, $controller, - xyzPhoneData = function() { - return { - name: 'phone xyz', - snippet: '', - images: ['image/url1.png', 'image/url2.png'] - } - }; - - beforeEach(angular.mock.module('phonecat.detail')); - - // Supply a hand-instantianted instance of the Phones service - beforeEach(angular.mock.module(function($provide) { - $provide.factory('phones', function() { - return new Phones(null); - }); - })); - - beforeEach(inject(function(_phones_, _$controller_, $rootScope, $routeParams) { - phones = _phones_; - $controller = _$controller_; - $routeParams.phoneId = 'xyz'; - scope = $rootScope.$new(); - })); - - - it('should fetch phone detail', function() { - spyOn(phones, 'get').and.returnValue(Observable.of(xyzPhoneData())); - - let ctrl = $controller('PhoneDetailCtrl', {$scope: scope}); - - expect(phones.get).toHaveBeenCalledWith('xyz'); - expect(ctrl.phone).toEqual(xyzPhoneData()); - }); -}); diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/test/unit/phone_list.controller.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/test/unit/phone_list.controller.spec.ts deleted file mode 100644 index 3df1418d9a..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/test/unit/phone_list.controller.spec.ts +++ /dev/null @@ -1,36 +0,0 @@ -// #docregion -import { Observable } from 'rxjs/Rx'; -import '../../app/js/phone_list/phone_list.module'; -import { Phones } from '../../app/js/core/phones.service'; - -describe('PhoneListCtrl', () => { - var scope, ctrl, $httpBackend; - - beforeEach(angular.mock.module('phonecat.list')); - - // Supply a hand-instantianted instance of the Phones service - beforeEach(angular.mock.module(function($provide) { - $provide.factory('phones', function() { - return new Phones(null); - }); - })); - - beforeEach(inject(function(phones, $rootScope, $controller) { - spyOn(phones, 'query').and.returnValue(Observable.of( - [{name: 'Nexus S'}, {name: 'Motorola DROID'}] - )); - scope = $rootScope.$new(); - ctrl = $controller('PhoneListCtrl', {$scope: scope}); - })); - - - it('should create "phones" model with 2 phones fetched from xhr', function() { - expect(ctrl.phones).toEqual( - [{name: 'Nexus S'}, {name: 'Motorola DROID'}]); - }); - - - it('should set the default value of orderProp model', function() { - expect(ctrl.orderProp).toBe('age'); - }); -}); diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/test/unit/phones.service.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/test/unit/phones.service.spec.ts deleted file mode 100644 index 8d3fc5270f..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/test/unit/phones.service.spec.ts +++ /dev/null @@ -1,16 +0,0 @@ -// #docregion -import { describe, beforeEachProviders, it, inject } from '@angular/core/testing'; -import { HTTP_PROVIDERS } from '@angular/http'; -import { Phones } from '../../app/js/core/phones.service'; - -describe('Phones', () => { - - // load providers - beforeEachProviders(() => [Phones, HTTP_PROVIDERS]); - - // Test service availability - it('check the existence of Phones', inject([Phones], (phones) => { - expect(phones).toBeDefined(); - })); - -}); diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/css/animations.css b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/app.animations.css similarity index 100% rename from public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/css/animations.css rename to public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/app.animations.css diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/app.config.ts b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/app.config.ts new file mode 100644 index 0000000000..9b99261074 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/app.config.ts @@ -0,0 +1,12 @@ +// #docregion +export default ['$routeProvider', + function config($routeProvider) { + $routeProvider. + when('/phones', { + template: '' + }). + when('/phones/:phoneId', { + template: '' + }). + otherwise('/phones'); +}]; diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/css/app.css b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/app.css similarity index 97% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/css/app.css rename to public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/app.css index 951ea087cc..f41c420776 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/css/app.css +++ b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/app.css @@ -44,7 +44,7 @@ img.phone { display: none; } -img.phone:first-child { +img.phone:first-of-type { display: block; } diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/app.module.ts b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/app.module.ts new file mode 100644 index 0000000000..d4e0e8b25c --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/app.module.ts @@ -0,0 +1,18 @@ +// #docregion pre-bootstrap +import core from './core/core.module'; +import phoneList from './phone-list/phone-list.module'; +import phoneDetail from './phone-detail/phone-detail.module'; +import appConfig from './app.config'; + +angular.module('phonecatApp', [ + 'ngAnimate', + 'ngRoute', + core.name, + phoneList.name, + phoneDetail.name +]).config(appConfig); + +// #enddocregion pre-bootstrap +// #docregion bootstrap +angular.bootstrap(document.documentElement, ['phonecatApp']); +// #enddocregion bootstrap diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/test/unit/checkmark.filter.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/core/checkmark/checkmark.filter.spec.ts similarity index 76% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_initial/test/unit/checkmark.filter.spec.ts rename to public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/core/checkmark/checkmark.filter.spec.ts index bae35e6875..6704c74999 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/test/unit/checkmark.filter.spec.ts +++ b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/core/checkmark/checkmark.filter.spec.ts @@ -1,10 +1,10 @@ // #docregion top -import '../../app/js/core/core.module'; +import '../core.module'; // #enddocregion top describe('checkmarkFilter', function() { - beforeEach(angular.mock.module('phonecat.core')); + beforeEach(angular.mock.module('core')); it('should convert boolean values to unicode checkmark or cross', inject(function(checkmarkFilter) { diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/core/checkmark.filter.ts b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/core/checkmark/checkmark.filter.ts similarity index 100% rename from public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/core/checkmark.filter.ts rename to public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/core/checkmark/checkmark.filter.ts diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/core/core.module.ts b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/core/core.module.ts new file mode 100644 index 0000000000..041f56ea79 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/core/core.module.ts @@ -0,0 +1,6 @@ +// #docregion +import checkmarkFilter from './checkmark/checkmark.filter'; +import phone from './phone/phone.module'; + +export default angular.module('core', [phone.name]) + .filter('checkmark', checkmarkFilter); diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/core/phone/phone.module.ts b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/core/phone/phone.module.ts new file mode 100644 index 0000000000..d60c3c9a07 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/core/phone/phone.module.ts @@ -0,0 +1,5 @@ +// #docregion +import Phone from './phone.service'; + +export default angular.module('core.phone', ['ngResource']) + .factory('Phone', Phone); diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/core/phone/phone.service.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/core/phone/phone.service.spec.ts new file mode 100644 index 0000000000..269ce500e9 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/core/phone/phone.service.spec.ts @@ -0,0 +1,47 @@ +// #docregion top +import './phone.module'; +// #enddocregion top + +'use strict'; + +describe('Phone', function() { + var $httpBackend; + var Phone; + var phonesData = [ + {name: 'Phone X'}, + {name: 'Phone Y'}, + {name: 'Phone Z'} + ]; + + // Add a custom equality tester before each test + beforeEach(function() { + jasmine.addCustomEqualityTester(angular.equals); + }); + + // Load the module that contains the `Phone` service before each test + beforeEach(angular.mock.module('core.phone')); + + // Instantiate the service and "train" `$httpBackend` before each test + beforeEach(inject(function(_$httpBackend_, _Phone_) { + $httpBackend = _$httpBackend_; + $httpBackend.expectGET('phones/phones.json').respond(phonesData); + + Phone = _Phone_; + })); + + // Verify that there are no outstanding expectations or requests after each test + afterEach(function () { + $httpBackend.verifyNoOutstandingExpectation(); + $httpBackend.verifyNoOutstandingRequest(); + }); + + it('should fetch the phones data from `/phones/phones.json`', function() { + var phones = Phone.query(); + + expect(phones).toEqual([]); + + $httpBackend.flush(); + expect(phones).toEqual(phonesData); + }); + +}); diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/core/phone/phone.service.ts b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/core/phone/phone.service.ts new file mode 100644 index 0000000000..861ff78832 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/core/phone/phone.service.ts @@ -0,0 +1,12 @@ +// #docregion +export default ['$resource', + function Phone($resource) { + return $resource('phones/:phoneId.json', {}, { + query: { + method: 'GET', + params: {phoneId: 'phones'}, + isArray: true + } + }); + } +]; diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/css/.gitkeep b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/css/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/index.html b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/index.html index b0d5e4caf2..babbef49c3 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/index.html +++ b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/index.html @@ -4,8 +4,8 @@ Google Phone Gallery - - + + @@ -13,18 +13,19 @@ - - - - - - - - - + + + + + + + + + + diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/app.module.ts b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/app.module.ts deleted file mode 100644 index 835518a9c0..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/app.module.ts +++ /dev/null @@ -1,35 +0,0 @@ -// #docregion pre-bootstrap -import core from './core/core.module'; -import phoneList from './phone_list/phone_list.module'; -import phoneDetail from './phone_detail/phone_detail.module'; - -angular.module('phonecatApp', [ - 'ngAnimate', - 'ngRoute', - core.name, - phoneList.name, - phoneDetail.name -]).config(configure); - -configure.$inject = ['$routeProvider']; - -function configure($routeProvider) { - $routeProvider. - when('/phones', { - templateUrl: 'js/phone_list/phone_list.html', - controller: 'PhoneListCtrl', - controllerAs: 'vm' - }). - when('/phones/:phoneId', { - templateUrl: 'js/phone_detail/phone_detail.html', - controller: 'PhoneDetailCtrl', - controllerAs: 'vm' - }). - otherwise({ - redirectTo: '/phones' - }); -} -// #enddocregion pre-bootstrap -// #docregion bootstrap -angular.bootstrap(document.documentElement, ['phonecatApp']); -// #enddocregion bootstrap diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/core/core.module.ts b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/core/core.module.ts deleted file mode 100644 index c20ce33683..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/core/core.module.ts +++ /dev/null @@ -1,9 +0,0 @@ -// #docregion -import Phone from './phone.factory'; -import checkmarkFilter from './checkmark.filter'; - -export default angular.module('phonecat.core', [ - 'ngResource' - ]) - .factory('Phone', Phone) - .filter('checkmark', checkmarkFilter); diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/core/phone.factory.ts b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/core/phone.factory.ts deleted file mode 100644 index a8492b29fc..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/core/phone.factory.ts +++ /dev/null @@ -1,10 +0,0 @@ -// #docregion -Phone.$inject = ['$resource']; - -function Phone($resource) { - return $resource('phones/:phoneId.json', {}, { - query: {method:'GET', params:{phoneId:'phones'}, isArray:true} - }); -} - -export default Phone; diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/phone_detail/phone_detail.controller.ts b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/phone_detail/phone_detail.controller.ts deleted file mode 100644 index c8745c0cd2..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/phone_detail/phone_detail.controller.ts +++ /dev/null @@ -1,14 +0,0 @@ -// #docregion -PhoneDetailCtrl.$inject = ['$routeParams', 'Phone']; - -function PhoneDetailCtrl($routeParams, Phone) { - var vm = this; - vm.phone = Phone.get({phoneId: $routeParams.phoneId}, function(phone) { - vm.mainImageUrl = phone.images[0]; - }); - vm.setImage = function(imageUrl) { - vm.mainImageUrl = imageUrl; - }; -} - -export default PhoneDetailCtrl; diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/phone_detail/phone_detail.html b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/phone_detail/phone_detail.html deleted file mode 100644 index 954c65c2cd..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/phone_detail/phone_detail.html +++ /dev/null @@ -1,118 +0,0 @@ -
    - -
    - -

    {{vm.phone.name}}

    - -

    {{vm.phone.description}}

    - -
      -
    • - -
    • -
    - -
      -
    • - Availability and Networks -
      -
      Availability
      -
      {{availability}}
      -
      -
    • -
    • - Battery -
      -
      Type
      -
      {{vm.phone.battery.type}}
      -
      Talk Time
      -
      {{vm.phone.battery.talkTime}}
      -
      Standby time (max)
      -
      {{vm.phone.battery.standbyTime}}
      -
      -
    • -
    • - Storage and Memory -
      -
      RAM
      -
      {{vm.phone.storage.ram}}
      -
      Internal Storage
      -
      {{vm.phone.storage.flash}}
      -
      -
    • -
    • - Connectivity -
      -
      Network Support
      -
      {{vm.phone.connectivity.cell}}
      -
      WiFi
      -
      {{vm.phone.connectivity.wifi}}
      -
      Bluetooth
      -
      {{vm.phone.connectivity.bluetooth}}
      -
      Infrared
      -
      {{vm.phone.connectivity.infrared | checkmark}}
      -
      GPS
      -
      {{vm.phone.connectivity.gps | checkmark}}
      -
      -
    • -
    • - Android -
      -
      OS Version
      -
      {{vm.phone.android.os}}
      -
      UI
      -
      {{vm.phone.android.ui}}
      -
      -
    • -
    • - Size and Weight -
      -
      Dimensions
      -
      {{dim}}
      -
      Weight
      -
      {{vm.phone.sizeAndWeight.weight}}
      -
      -
    • -
    • - Display -
      -
      Screen size
      -
      {{vm.phone.display.screenSize}}
      -
      Screen resolution
      -
      {{vm.phone.display.screenResolution}}
      -
      Touch screen
      -
      {{vm.phone.display.touchScreen | checkmark}}
      -
      -
    • -
    • - Hardware -
      -
      CPU
      -
      {{vm.phone.hardware.cpu}}
      -
      USB
      -
      {{vm.phone.hardware.usb}}
      -
      Audio / headphone jack
      -
      {{vm.phone.hardware.audioJack}}
      -
      FM Radio
      -
      {{vm.phone.hardware.fmRadio | checkmark}}
      -
      Accelerometer
      -
      {{vm.phone.hardware.accelerometer | checkmark}}
      -
      -
    • -
    • - Camera -
      -
      Primary
      -
      {{vm.phone.camera.primary}}
      -
      Features
      -
      {{vm.phone.camera.features.join(', ')}}
      -
      -
    • -
    • - Additional Features -
      {{vm.phone.additionalFeatures}}
      -
    • -
    diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/phone_detail/phone_detail.module.ts b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/phone_detail/phone_detail.module.ts deleted file mode 100644 index 5ea1739577..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/phone_detail/phone_detail.module.ts +++ /dev/null @@ -1,8 +0,0 @@ -// #docregion -import PhoneDetailCtrl from './phone_detail.controller'; - -export default angular.module('phonecat.detail', [ - 'phonecat.core', - 'ngRoute' - ]) - .controller('PhoneDetailCtrl', PhoneDetailCtrl); diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/phone_list/phone_list.controller.ts b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/phone_list/phone_list.controller.ts deleted file mode 100644 index 63dc2a6548..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/phone_list/phone_list.controller.ts +++ /dev/null @@ -1,10 +0,0 @@ -// #docregion -PhoneListCtrl.$inject = ['Phone']; - -function PhoneListCtrl(Phone) { - var vm = this; - vm.phones = Phone.query(); - vm.orderProp = 'age'; -} - -export default PhoneListCtrl; diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/phone_list/phone_list.module.ts b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/phone_list/phone_list.module.ts deleted file mode 100644 index 758b937927..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/phone_list/phone_list.module.ts +++ /dev/null @@ -1,5 +0,0 @@ -// #docregion -import PhoneListCtrl from './phone_list.controller'; - -export default angular.module('phonecat.list', ['phonecat.core']) - .controller('PhoneListCtrl', PhoneListCtrl); diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-detail/phone-detail.component.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-detail/phone-detail.component.spec.ts new file mode 100644 index 0000000000..4d0b3c0cb7 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-detail/phone-detail.component.spec.ts @@ -0,0 +1,38 @@ +// #docregion top +import './phone-detail.module'; +// #enddocregion top + +describe('phoneDetail', function(){ + + // Load the module that contains the `phoneDetail` component before each test + beforeEach(angular.mock.module('phoneDetail')); + + // Test the controller + describe('PhoneDetailController', function() { + var $httpBackend, ctrl; + var xyzPhoneData = { + name: 'phone xyz', + images: ['image/url1.png', 'image/url2.png'] + }; + + beforeEach(inject(function($componentController, _$httpBackend_, $routeParams) { + $httpBackend = _$httpBackend_; + $httpBackend.expectGET('phones/xyz.json').respond(xyzPhoneData); + + $routeParams.phoneId = 'xyz'; + + ctrl = $componentController('phoneDetail', {$scope: {}}); + })); + + it('should fetch the phone details', function() { + jasmine.addCustomEqualityTester(angular.equals); + + expect(ctrl.phone).toEqual({}); + + $httpBackend.flush(); + expect(ctrl.phone).toEqual(xyzPhoneData); + }); + + }); + +}); diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-detail/phone-detail.component.ts b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-detail/phone-detail.component.ts new file mode 100644 index 0000000000..1e72fc1228 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-detail/phone-detail.component.ts @@ -0,0 +1,16 @@ +// #docregion + +export default { + templateUrl: 'phone-detail/phone-detail.template.html', + controller: ['$routeParams', 'Phone', + function PhoneDetailController($routeParams, Phone) { + var vm = this; + vm.phone = Phone.get({phoneId: $routeParams.phoneId}, (phone) => { + vm.setImage(phone.images[0]); + }); + vm.setImage = function setImage(imageUrl) { + vm.mainImageUrl = imageUrl; + }; + } + ] +}; diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-detail/phone-detail.module.ts b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-detail/phone-detail.module.ts new file mode 100644 index 0000000000..d9e95c0761 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-detail/phone-detail.module.ts @@ -0,0 +1,9 @@ +// #docregion +import phoneDetail from './phone-detail.component'; +import phone from '../core/phone/phone.module'; + +export default angular.module('phoneDetail', [ + 'ngRoute', + phone.name + ]) + .component('phoneDetail', phoneDetail); diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-detail/phone-detail.template.html b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-detail/phone-detail.template.html new file mode 100644 index 0000000000..019ccf45c7 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-detail/phone-detail.template.html @@ -0,0 +1,118 @@ +
    + +
    + +

    {{$ctrl.phone.name}}

    + +

    {{$ctrl.phone.description}}

    + +
      +
    • + +
    • +
    + +
      +
    • + Availability and Networks +
      +
      Availability
      +
      {{availability}}
      +
      +
    • +
    • + Battery +
      +
      Type
      +
      {{$ctrl.phone.battery.type}}
      +
      Talk Time
      +
      {{$ctrl.phone.battery.talkTime}}
      +
      Standby time (max)
      +
      {{$ctrl.phone.battery.standbyTime}}
      +
      +
    • +
    • + Storage and Memory +
      +
      RAM
      +
      {{$ctrl.phone.storage.ram}}
      +
      Internal Storage
      +
      {{$ctrl.phone.storage.flash}}
      +
      +
    • +
    • + Connectivity +
      +
      Network Support
      +
      {{$ctrl.phone.connectivity.cell}}
      +
      WiFi
      +
      {{$ctrl.phone.connectivity.wifi}}
      +
      Bluetooth
      +
      {{$ctrl.phone.connectivity.bluetooth}}
      +
      Infrared
      +
      {{$ctrl.phone.connectivity.infrared | checkmark}}
      +
      GPS
      +
      {{$ctrl.phone.connectivity.gps | checkmark}}
      +
      +
    • +
    • + Android +
      +
      OS Version
      +
      {{$ctrl.phone.android.os}}
      +
      UI
      +
      {{$ctrl.phone.android.ui}}
      +
      +
    • +
    • + Size and Weight +
      +
      Dimensions
      +
      {{dim}}
      +
      Weight
      +
      {{$ctrl.phone.sizeAndWeight.weight}}
      +
      +
    • +
    • + Display +
      +
      Screen size
      +
      {{$ctrl.phone.display.screenSize}}
      +
      Screen resolution
      +
      {{$ctrl.phone.display.screenResolution}}
      +
      Touch screen
      +
      {{$ctrl.phone.display.touchScreen | checkmark}}
      +
      +
    • +
    • + Hardware +
      +
      CPU
      +
      {{$ctrl.phone.hardware.cpu}}
      +
      USB
      +
      {{$ctrl.phone.hardware.usb}}
      +
      Audio / headphone jack
      +
      {{$ctrl.phone.hardware.audioJack}}
      +
      FM Radio
      +
      {{$ctrl.phone.hardware.fmRadio | checkmark}}
      +
      Accelerometer
      +
      {{$ctrl.phone.hardware.accelerometer | checkmark}}
      +
      +
    • +
    • + Camera +
      +
      Primary
      +
      {{$ctrl.phone.camera.primary}}
      +
      Features
      +
      {{$ctrl.phone.camera.features.join(', ')}}
      +
      +
    • +
    • + Additional Features +
      {{$ctrl.phone.additionalFeatures}}
      +
    • +
    diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-list/phone-list.component.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-list/phone-list.component.spec.ts new file mode 100644 index 0000000000..f0cf9987f9 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-list/phone-list.component.spec.ts @@ -0,0 +1,37 @@ +// #docregion top +import './phone-list.module'; +// #enddocregion top + +describe('phoneList', function() { + + // Load the module that contains the `phoneList` component before each test + beforeEach(angular.mock.module('phoneList')); + + // Test the controller + describe('PhoneListController', function() { + var $httpBackend, ctrl; + + beforeEach(inject(function($componentController, _$httpBackend_) { + $httpBackend = _$httpBackend_; + $httpBackend.expectGET('phones/phones.json') + .respond([{name: 'Nexus S'}, {name: 'Motorola DROID'}]); + + ctrl = $componentController('phoneList', {$scope: {}}); + })); + + it('should create a `phones` model with 2 phones fetched with `$http`', function() { + jasmine.addCustomEqualityTester(angular.equals); + + expect(ctrl.phones).toEqual([]); + + $httpBackend.flush(); + expect(ctrl.phones).toEqual([{name: 'Nexus S'}, {name: 'Motorola DROID'}]); + }); + + it('should set a default value for the `orderProp` model', function() { + expect(ctrl.orderProp).toBe('age'); + }); + + }); + +}); diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-list/phone-list.component.ts b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-list/phone-list.component.ts new file mode 100644 index 0000000000..5e6db2e74f --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-list/phone-list.component.ts @@ -0,0 +1,10 @@ +// #docregion +export default { + templateUrl: 'phone-list/phone-list.template.html', + controller: ['Phone', + function PhoneListController(Phone) { + this.phones = Phone.query(); + this.orderProp = 'age'; + } + ] +}; diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-list/phone-list.module.ts b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-list/phone-list.module.ts new file mode 100644 index 0000000000..feae92f9af --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-list/phone-list.module.ts @@ -0,0 +1,6 @@ +// #docregion +import phoneList from './phone-list.component'; +import phone from '../core/phone/phone.module'; + +export default angular.module('phoneList', [phone.name]) + .component('phoneList', phoneList); diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_list/phone_list.html b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-list/phone-list.template.html similarity index 77% rename from public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_list/phone_list.html rename to public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-list/phone-list.template.html index 471f474e89..95283ee032 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_list/phone_list.html +++ b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/phone-list/phone-list.template.html @@ -3,9 +3,9 @@
    - Search: + Search: Sort by: - @@ -15,7 +15,7 @@
      -
    • {{phone.name}} diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/systemjs.config.js b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/systemjs.config.js index 9a46070388..089b9c0d8a 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/systemjs.config.js +++ b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/systemjs.config.js @@ -5,7 +5,7 @@ var pkgPath = global.packagePath || '../node_modules/'; // path to packages System.config({ packages: { - 'js': { defaultExtension: 'js' }, + './': { defaultExtension: 'js' }, } }); diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/test/protractor-conf.js b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/e2e-tests/protractor-conf.js similarity index 94% rename from public/docs/_examples/upgrade-phonecat/ts/ng2_initial/test/protractor-conf.js rename to public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/e2e-tests/protractor-conf.js index 118c7b9ec2..a4099af352 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/test/protractor-conf.js +++ b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/e2e-tests/protractor-conf.js @@ -2,7 +2,7 @@ exports.config = { allScriptsTimeout: 11000, specs: [ - 'e2e/*.js' + '*.js' ], capabilities: { diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/e2e/scenarios.js b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/e2e-tests/scenarios.js similarity index 83% rename from public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/e2e/scenarios.js rename to public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/e2e-tests/scenarios.js index 5a505b5dae..f5774c189a 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/e2e/scenarios.js +++ b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/e2e-tests/scenarios.js @@ -20,8 +20,8 @@ describe('PhoneCat App', function() { it('should filter the phone list as a user types into the search box', function() { - var phoneList = element.all(by.repeater('phone in vm.phones')); - var query = element(by.model('vm.query')); + var phoneList = element.all(by.repeater('phone in $ctrl.phones')); + var query = element(by.model('$ctrl.query')); expect(phoneList.count()).toBe(20); @@ -36,8 +36,8 @@ describe('PhoneCat App', function() { it('should be possible to control phone order via the drop down select box', function() { - var phoneNameColumn = element.all(by.repeater('phone in vm.phones').column('phone.name')); - var query = element(by.model('vm.query')); + var phoneNameColumn = element.all(by.repeater('phone in $ctrl.phones').column('phone.name')); + var query = element(by.model('$ctrl.query')); function getNames() { return phoneNameColumn.map(function(elm) { @@ -52,7 +52,7 @@ describe('PhoneCat App', function() { "MOTOROLA XOOM\u2122" ]); - element(by.model('vm.orderProp')).element(by.css('option[value="name"]')).click(); + element(by.model('$ctrl.orderProp')).element(by.css('option[value="name"]')).click(); expect(getNames()).toEqual([ "MOTOROLA XOOM\u2122", @@ -62,7 +62,7 @@ describe('PhoneCat App', function() { it('should render phone specific links', function() { - var query = element(by.model('vm.query')); + var query = element(by.model('$ctrl.query')); query.sendKeys('nexus'); element.all(by.css('.phones li a')).first().click(); browser.getLocationAbsUrl().then(function(url) { @@ -80,7 +80,7 @@ describe('PhoneCat App', function() { it('should display nexus-s page', function() { - expect(element(by.binding('vm.phone.name')).getText()).toBe('Nexus S'); + expect(element(by.binding('$ctrl.phone.name')).getText()).toBe('Nexus S'); }); diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/karma.conf.1.js b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/karma.conf.1.js new file mode 100644 index 0000000000..5124a02418 --- /dev/null +++ b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/karma.conf.1.js @@ -0,0 +1,42 @@ +module.exports = function(config){ + config.set({ + + basePath: './app', + + // #docregion files + files : [ + 'bower_components/angular/angular.js', + 'bower_components/angular-route/angular-route.js', + 'bower_components/angular-resource/angular-resource.js', + 'bower_components/angular-animate/angular-animate.js', + 'bower_components/angular-mocks/angular-mocks.js', + '../node_modules/systemjs/dist/system.src.js', + '../karma_test_shim.js', + {pattern: '**/*.module.js', included: false, watched: true}, + {pattern: '*!(.module|.spec).js', included: false, watched: true}, + {pattern: '!(bower_components)/**/*!(.module|.spec).js', included: false, watched: true}, + {pattern: '**/*.spec.js', included: false, watched: true} + ], + // #enddocregion files + + autoWatch : true, + + frameworks: ['jasmine'], + + browsers : ['Chrome', 'Firefox'], + + plugins : [ + 'karma-chrome-launcher', + 'karma-firefox-launcher', + 'karma-jasmine' + ], + + junitReporter : { + outputFile: 'test_out/unit.xml', + suite: 'unit' + }, + + logLevel: config.LOG_DEBUG + + }); +}; diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/karma_test_shim.js b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/karma_test_shim.js similarity index 87% rename from public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/karma_test_shim.js rename to public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/karma_test_shim.js index 15cbee5d7d..d03229f0f5 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/karma_test_shim.js +++ b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/karma_test_shim.js @@ -5,7 +5,7 @@ __karma__.loaded = function() {}; System.config({ packages: { - 'base/app/js': { + 'base': { defaultExtension: false, format: 'register', map: Object.keys(window.__karma__.files). @@ -13,7 +13,7 @@ System.config({ reduce(function createPathRecords(pathsMapping, appPath) { // creates local module name mapping to global path with karma's fingerprint in path, e.g.: // './hero.service': '/base/src/app/hero.service.js?f4523daf879cfb7310ef6242682ccf10b2041b3e' - var moduleName = appPath.replace(/^\/base\/app\/js\//, './').replace(/\.js$/, ''); + var moduleName = appPath.replace(/^\/base\//, './').replace(/\.js$/, ''); pathsMapping[moduleName] = appPath + '?' + window.__karma__.files[appPath] return pathsMapping; }, {}) @@ -36,7 +36,7 @@ Promise.all( }); function onlyAppFiles(filePath) { - return /^\/base\/app\/js\/.*\.js$/.test(filePath) + return /^\/base\/.*\.(?!\.spec\.)js$/.test(filePath) } function onlySpecFiles(path) { diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/package.1.json b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/package.1.json index cec9c37aee..6c8c0c8a0a 100644 --- a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/package.1.json +++ b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/package.1.json @@ -26,12 +26,12 @@ "prestart": "npm install", "start": "http-server -a 0.0.0.0 -p 8000", "pretest": "npm install", - "test": "node node_modules/karma/bin/karma start test/karma.conf.js", - "test-single-run": "node node_modules/karma/bin/karma start test/karma.conf.js --single-run", + "test": "node node_modules/karma/bin/karma start karma.conf.js", + "test-single-run": "node node_modules/karma/bin/karma start karma.conf.js --single-run", "preupdate-webdriver": "npm install", "update-webdriver": "webdriver-manager update", "preprotractor": "npm run update-webdriver", - "protractor": "protractor test/protractor-conf.js", + "protractor": "protractor e2e-tests/protractor-conf.js", "typings": "typings", "tsc": "tsc -p . -w" } diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/jasmine_matchers.d.ts b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/jasmine_matchers.d.ts deleted file mode 100644 index 6d24879775..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/jasmine_matchers.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// #docregion -declare module jasmine { - interface Matchers { - toEqualData(expected: any):boolean; - } -} diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/karma.conf.1.js b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/karma.conf.1.js deleted file mode 100644 index 8f2e7d178f..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/karma.conf.1.js +++ /dev/null @@ -1,38 +0,0 @@ -module.exports = function(config){ - config.set({ - - basePath : '..', - - // #docregion files - files : [ - 'app/bower_components/angular/angular.js', - 'app/bower_components/angular-route/angular-route.js', - 'app/bower_components/angular-resource/angular-resource.js', - 'app/bower_components/angular-animate/angular-animate.js', - 'app/bower_components/angular-mocks/angular-mocks.js', - 'node_modules/systemjs/dist/system.src.js', - 'test/karma_test_shim.js', - {pattern: 'app/js/**/*.js', included: false, watched: true}, - {pattern: 'test/unit/**/*.js', included: false, watched: true} - ], - // #enddocregion files - - autoWatch : true, - - frameworks: ['jasmine'], - - browsers : ['Chrome', 'Firefox'], - - plugins : [ - 'karma-chrome-launcher', - 'karma-firefox-launcher', - 'karma-jasmine' - ], - - junitReporter : { - outputFile: 'test_out/unit.xml', - suite: 'unit' - } - - }); -}; diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/unit/phone.factory.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/unit/phone.factory.spec.ts deleted file mode 100644 index d7c95d347e..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/unit/phone.factory.spec.ts +++ /dev/null @@ -1,15 +0,0 @@ -// #docregion top -import '../../app/js/core/core.module'; -// #enddocregion top - -describe('phoneFactory', function() { - - // load modules - beforeEach(angular.mock.module('phonecat.core')); - - // Test service availability - it('check the existence of Phone factory', inject(function(Phone) { - expect(Phone).toBeDefined(); - })); - -}); diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/unit/phone_detail.controller.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/unit/phone_detail.controller.spec.ts deleted file mode 100644 index 02a3e20240..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/unit/phone_detail.controller.spec.ts +++ /dev/null @@ -1,44 +0,0 @@ -// #docregion top -import '../../app/js/phone_detail/phone_detail.module'; -// #enddocregion top - -describe('PhoneDetailCtrl', function(){ - var scope, $httpBackend, ctrl, - xyzPhoneData = function() { - return { - name: 'phone xyz', - images: ['image/url1.png', 'image/url2.png'] - } - }; - - beforeEach(angular.mock.module('phonecat.detail')); - - beforeEach(function(){ - jasmine.addMatchers({ - toEqualData: function(util, customEqualityTesters) { - return { - compare: function(actual, expected) { - return {pass: angular.equals(actual, expected)}; - } - }; - } - }); - }); - - beforeEach(inject(function(_$httpBackend_, $rootScope, $routeParams, $controller) { - $httpBackend = _$httpBackend_; - $httpBackend.expectGET('phones/xyz.json').respond(xyzPhoneData()); - - $routeParams.phoneId = 'xyz'; - scope = $rootScope.$new(); - ctrl = $controller('PhoneDetailCtrl', {$scope: scope}); - })); - - - it('should fetch phone detail', function() { - expect(ctrl.phone).toEqualData({}); - $httpBackend.flush(); - - expect(ctrl.phone).toEqualData(xyzPhoneData()); - }); -}); diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/unit/phone_list.controller.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/unit/phone_list.controller.spec.ts deleted file mode 100644 index efec5d5f08..0000000000 --- a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/test/unit/phone_list.controller.spec.ts +++ /dev/null @@ -1,44 +0,0 @@ -// #docregion top -import '../../app/js/phone_list/phone_list.module'; -// #enddocregion top - -describe('PhoneListCtrl', function(){ - var scope, ctrl, $httpBackend; - - beforeEach(angular.mock.module('phonecat.list')); - - beforeEach(function(){ - jasmine.addMatchers({ - toEqualData: function(util, customEqualityTesters) { - return { - compare: function(actual, expected) { - return {pass: angular.equals(actual, expected)}; - } - }; - } - }); - }); - - beforeEach(inject(function(_$httpBackend_, $rootScope, $controller) { - $httpBackend = _$httpBackend_; - $httpBackend.expectGET('phones/phones.json'). - respond([{name: 'Nexus S'}, {name: 'Motorola DROID'}]); - - scope = $rootScope.$new(); - ctrl = $controller('PhoneListCtrl', {$scope: scope}); - })); - - - it('should create "phones" model with 2 phones fetched from xhr', function() { - expect(ctrl.phones).toEqualData([]); - $httpBackend.flush(); - - expect(ctrl.phones).toEqualData( - [{name: 'Nexus S'}, {name: 'Motorola DROID'}]); - }); - - - it('should set the default value of orderProp model', function() { - expect(ctrl.orderProp).toBe('age'); - }); -}); diff --git a/public/docs/ts/latest/guide/upgrade.jade b/public/docs/ts/latest/guide/upgrade.jade index 95ee9314b9..350357e36e 100644 --- a/public/docs/ts/latest/guide/upgrade.jade +++ b/public/docs/ts/latest/guide/upgrade.jade @@ -44,7 +44,7 @@ include ../_util-fns 4. [PhoneCat Upgrade Tutorial](#phonecat-upgrade-tutorial) 1. [Bootstrapping A Hybrid 1+2 PhoneCat](#bootstrapping-a-hybrid-1-2-phonecat) 2. [Upgrading the Phone factory](#upgrading-the-phone-factory) - 3. [Upgrading Controllers to Components](#upgrading-controllers-to-components) + 3. [Upgrading Components](#upgrading-components) 4. [Switching To The Angular 2 Router And Bootstrap](#switching-to-the-angular-2-router-and-bootstrap) 5. [Saying Goodbye to Angular 1](#saying-goodbye-to-angular-1) @@ -60,7 +60,7 @@ include ../_util-fns ## Following The Angular Style Guide - The [Angular Style Guide](https://github.com/johnpapa/angular-styleguide) + The [Angular 1 Style Guide](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#single-responsibility) collects patterns and practices that have been proven to result in cleaner and more maintainable Angular 1 applications. It contains a wealth of information about how to write and organize Angular code - and equally @@ -80,7 +80,7 @@ include ../_util-fns states that there should be one component per file. This not only makes components easy to navigate and find, but will also allow us to migrate them between languages and frameworks one at a time. In this example application, - each controller, factory, and filter is in its own source file. + each controller, component, service, and filter is in its own source file. * The [Folders-by-Feature Structure](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#folders-by-feature-structure) and [Modularity](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#modularity) rules define similar principles on a higher level of abstraction: Different parts of the @@ -740,82 +740,75 @@ figure To follow along with the tutorial, clone the [angular-phonecat](https://github.com/angular/angular-phonecat) repository - and apply the steps as we go + and apply the steps as we go. -.alert.is-important - :marked - If you do clone this repository, note that it doesn't look like this guide - assumes yet. There's [a pull request](https://github.com/angular/angular-phonecat/pull/289) - that will change this. Meanwhile, you'll find a good starting point from - [this commit](https://github.com/teropa/angular-phonecat/commit/d6fb83e1c2db9d1812c7c478fdb8d92301ef0061). - -:marked - In terms of project structure, this is where our work begins + In terms of project structure, this is where our work begins: .filetree .file angular-phonecat .children .file bower.json + .file karma.conf.js .file package.json .file app .children - .file js + .file core .children - .file core + .file checkmark .children .file checkmark.filter.js - .file core.module.js - .file phone.factory.js - .file phone_detail + .file checkmark.filter.spec.js + .file phone .children - .file phone_detail.html - .file phone_detail.module.js - .file phone_detail.controller.js - .file phone_list - .children - .file phone_list.html - .file phone_list.module.js - .file phone_list.controller.js - .file app.module.js - .file css + .file phone.module.js + .file phone.service.js + .file phone.service.spec.js + .file core.module.js + .file phone-detail + .children + .file phone-detail.component.js + .file phone-detail.component.spec.js + .file phone-detail.module.js + .file phone-detail.template.html + .file phone-list .children - .file animations.css - .file app.css + .file phone-list.component.js + .file phone-list.component.spec.js + .file phone-list.module.js + .file phone-list.template.html .file img .children .file ... .file phones .children .file ... + .file app.animations.js + .file app.config.js + .file app.css + .file app.module.js .file index.html - .file test + .file e2e-tests .children - .file e2e - .children - .file scenarios.js - .file unit - .children - .file checkmark.filter.spec.js - .file phone_detail.controller.spec.js - .file phone.factory.spec.js - .file phone_list.controller.spec.js - .file karma.conf.js .file protractor-conf.js + .file scenarios.js :marked This is actually a pretty good starting point. In particular, this organization - follows the [Angular Style Guide](https://github.com/johnpapa/angular-styleguide), + follows the [Angular 1 Style Guide](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md), which is an important [preparation step](#following-the-angular-style-guide) before a successful upgrade. - * Each controller, factory, and filter is in its own source file, as per the - [Rule of 1](https://github.com/johnpapa/angular-styleguide#single-responsibility). - * The `core`, `phoneDetail`, and `phoneList` modules are each in their + * Each component, service, and filter is in its own source file, as per the + [Rule of 1](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#single-responsibility). + * The `core`, `phone-detail`, and `phone-list` modules are each in their own subdirectory. Those subdirectories contain the JavaScript code as well as the HTML templates that go with each particular feature. This is in line with the - [Folders-by-Feature Structure](https://github.com/johnpapa/angular-styleguide#style-y152) - and [Modularity](https://github.com/johnpapa/angular-styleguide#modularity) + [Folders-by-Feature Structure](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y152) + and [Modularity](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#modularity) rules. + * Unit tests are located side-by-side with application code where they are easily + found, as described in the rules for + [Organizing Tests](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y197). :marked ## Switching to TypeScript And Module Loading @@ -829,12 +822,6 @@ figure instead. We'll replace this approach with the [SystemJS loader](https://github.com/systemjs/systemjs). -.alert.is-helpful - :marked - Angular 2 itself doesn't require either TypeScript or SystemJS. - There will soon be other editions of this guide that show how to - do the upgrade using ES5. - :marked We will also start to gradually phase out the Bower package manager in favor of NPM. We'll install all new dependencies using NPM, and will eventually be @@ -859,9 +846,7 @@ code-example(format=""). :marked We can now use Typings to install the type definitions for Angular 1 and the Jasmine - unit test framework. This will add a `typings` directory to the project and install - a number of `.d.ts` files under it. It will also create a `typings.json` file to the - project, which contains metadata about the type definitions we've installed: + unit test framework: code-example(format=""). npm run typings install jquery -- --save --ambient @@ -883,8 +868,8 @@ code-example(format=""). +makeExample('upgrade-phonecat/ts/typescript-conversion/app/systemjs.config.js', ull, 'app/systemjs.config.js') :marked - This tells SystemJS that we have a module called `app.module` that - resides in the `js` subdirectory (relative to the `index.html` page). We then load that + This configuration tells SystemJS that we have a module called `app.module` that + resides in the same directory as the `index.html` page. We then load that module using `System.import`. This will load and execute the `app/app.module.js` file. We should also configure the TypeScript compiler so that it can understand our @@ -920,74 +905,81 @@ code-example(format=""). our existing code. Instead we'll introduce type annotations and other new features gradually over time. - Let's begin by renaming `app.module.js` to `app.module.ts`. The TypeScript - compiler should be able to compile it successfully right away. This means we can - move right along and go through the rest of our source files and convert them. - We'll rename each one to a `.ts` file, and add the imports and exports it needs. - - Beginning from the checkmark filter, here are the converted contents: + So, we'll go through each of our source files and convert them as we go, by + renaming each one to a `.ts` file and adding the imports and exports it needs. + Beginning from the `Phone` service, here are the converted contents: -+makeExample('upgrade-phonecat/ts/typescript-conversion/app/js/core/checkmark.filter.ts', null, 'app/js/core/checkmark.filter.ts') ++makeExample('upgrade-phonecat/ts/typescript-conversion/app/core/phone/phone.service.ts', null, 'app/core/phone/phone.service.ts') :marked - This file now has the filter factory function as the default export. Apart from + This file now has the factory function as the default export. Apart from the export, there's one other major change we've applied to the file, which - is that it does *not* contain the registration of the filter into an Angular - module. We will do that later in the `core` module's main file. + is that it does *not* contain the registration of the factory into an Angular + module. We do that in the `core.phone` module's main file, where we also then + export the module itself as the default export: + ++makeExample('upgrade-phonecat/ts/typescript-conversion/app/core/phone/phone.module.ts', null, 'app/core/phone/phone.module.ts') + +:marked + This'll be a pattern we follow for all our files: Rather than registering things + into the Angular 1 module system in every file, we use the ES2015 module system. + Angular 1 module management is centralized into the `.module.ts` files, where it is + easier to manage. It will also be easy to eventually remove when we complete the + upgrade. - Moving to the `Phone` factory file, it now has the factory function as the default + Moving on to the `checkmark` filter, it now has the filter factory function as the default export: -+makeExample('upgrade-phonecat/ts/typescript-conversion/app/js/core/phone.factory.ts', null, 'app/js/core/phone.factory.ts') ++makeExample('upgrade-phonecat/ts/typescript-conversion/app/core/checkmark/checkmark.filter.ts', null, 'app/core/checkmark/checkmark.filter.ts') :marked The `core` module's main module file will now import both the checkmark filter - and the Phone factory. This is where we actually register them into the Angular module. - We then export the module itself as this file's default export: + and the `core.phone` module: -+makeExample('upgrade-phonecat/ts/typescript-conversion/app/js/core/core.module.ts', null, 'app/js/core/core.module.ts') ++makeExample('upgrade-phonecat/ts/typescript-conversion/app/core/core.module.ts', null, 'app/core/core.module.ts') :marked - Notice that with this organization pattern, the files that hold the application - components themselves - filters and factories - aren't concerned with the makeup - of Angular modules. That's just something we previously *had* to do because there - were no other good solutions. Now we use a separate file just for the purpose - of forming the Angular module. + Note that we don't have to repeat the name string of the `core.phone` Angular 1 module + here. Since the module exports itself, we can just refer to its `name` attribute. + Rather than defining module dependencies using strings, we can just use the + ES2015 module system. Now switching to the phone detail module, we'll make similar changes here. In the - controller file we export the controller function as the default export: + component file we export the component object as the default export: -+makeExample('upgrade-phonecat/ts/typescript-conversion/app/js/phone_detail/phone_detail.controller.ts', null, 'app/js/phone_detail/phone_detail.controller.ts') ++makeExample('upgrade-phonecat/ts/typescript-conversion/app/phone-detail/phone-detail.component.ts', null, 'app/phone-detail/phone-detail.component.ts') :marked - In the main module file we import the controller and register it into the Angular + In the main module file we import the component and register it into the Angular module, which itself is then exported: -+makeExample('upgrade-phonecat/ts/typescript-conversion/app/js/phone_detail/phone_detail.module.ts', null, 'app/js/phone_detail/phone_detail.module.ts') ++makeExample('upgrade-phonecat/ts/typescript-conversion/app/phone-detail/phone-detail.module.ts', null, 'app/phone-detail/phone-detail.module.ts') :marked Then we'll repeat the same steps once more for the phone list module. - The controller file exports the controller function: + The component file exports the component object: -+makeExample('upgrade-phonecat/ts/typescript-conversion/app/js/phone_list/phone_list.controller.ts', null, 'app/js/phone_list/phone_list.controller.ts') ++makeExample('upgrade-phonecat/ts/typescript-conversion/app/phone-list/phone-list.component.ts', null, 'app/phone-list/phone-list.component.ts') :marked - And the main module file imports the controller and registers it: + The main module file then imports the component and registers it: -+makeExample('upgrade-phonecat/ts/typescript-conversion/app/js/phone_list/phone_list.module.ts', null, 'app/js/phone_list/phone_list.module.ts') ++makeExample('upgrade-phonecat/ts/typescript-conversion/app/phone-list/phone-list.module.ts', null, 'app/phone-list/phone-list.module.ts') :marked - Finally, we can now pull everything together in `app.module.ts`. We'll - import each of the three submodule files and register them as dependencies - of the main application module: + We'll also convert our application route config block so that it doesn't + register itself into a module. It is just exported: -+makeExample('upgrade-phonecat/ts/typescript-conversion/app/js/app.module.ts', 'pre-bootstrap', 'app/js/app.module.ts') ++makeExample('upgrade-phonecat/ts/typescript-conversion/app/app.config.ts', null, 'app/app.config.ts') :marked - Note that we don't have to repeat the submodule name strings here. Since the - modules export themselves, we can just refer to the `name` attribute of each - of them. + Finally, we can now pull everything together in `app.module.ts`. It here we'll + import each of the three submodule files as well as the config block. We then register + them into the main application module: ++makeExample('upgrade-phonecat/ts/typescript-conversion/app/app.module.ts', 'pre-bootstrap', 'app/app.module.ts') + +:marked Before this converted version of the application will run, we need to change the way we're bootstrapping it. It is currently bootstrapped using the `ng-app` directive attached to the `` element of the host page. This will no longer work because @@ -996,10 +988,10 @@ code-example(format=""). We should switch to a JavaScript-driven bootstrap instead. As it happens, this is also how Angular 2 apps are bootstrapped, so the switch brings us one step closer - to Angular as well. So, remove the `ng-app` attribute from `index.html`, and add + to Angular 2 as well. So, remove the `ng-app` attribute from `index.html`, and add this at the end of `app.module.ts`: -+makeExample('upgrade-phonecat/ts/typescript-conversion/app/js/app.module.ts', 'bootstrap', 'app/js/app.module.ts') ++makeExample('upgrade-phonecat/ts/typescript-conversion/app/app.module.ts', 'bootstrap', 'app/app.module.ts') :marked We now have a fully functional version of the application, all converted @@ -1029,7 +1021,7 @@ code-example(format=""). the application files. For this we'll use a shim file that will tweak the way files get loaded: -+makeExample('upgrade-phonecat/ts/typescript-conversion/test/karma_test_shim.js', null, 'test/karma_test_shim.js') ++makeExample('upgrade-phonecat/ts/typescript-conversion/karma_test_shim.js', null, 'karma_test_shim.js') .alert.is-important The shim is likely to be replaced by improved tooling, but is currently needed. @@ -1039,48 +1031,33 @@ code-example(format=""). We will *watch* them so that the test suite is triggered when changes occur, but we won't have Karma *include* them because that is now done by SystemJS and the shim. -+makeExample('upgrade-phonecat/ts/typescript-conversion/test/karma.conf.1.js', 'files', 'test/karma.conf.js') ++makeExample('upgrade-phonecat/ts/typescript-conversion/karma.conf.1.js', 'files', 'karma.conf.js') :marked Now we have the infrastructure in place and can convert the test files themselves. - This mainly just consists for changing the file extensions of those files, and adding + This mainly just consists of changing the file extensions of those files, and adding the necessary imports to them. In the checkmark filter spec, we'll import the core module file, so that it is available when we load the corresponding Angular module: -+makeExample('upgrade-phonecat/ts/typescript-conversion/test/unit/checkmark.filter.spec.ts', 'top', 'test/unit/checkmark.filter.spec.ts') ++makeExample('upgrade-phonecat/ts/typescript-conversion/app/core/checkmark/checkmark.filter.spec.ts', 'top', 'app/core/checkmark/checkmark.filter.spec.ts') :marked - We'll do the exact same thing for the phone factory spec: + For the phone service spec, on the other hand, we load the `core.phone` module file: -+makeExample('upgrade-phonecat/ts/typescript-conversion/test/unit/phone.factory.spec.ts', 'top', 'test/unit/phone.factory.spec.ts') ++makeExample('upgrade-phonecat/ts/typescript-conversion/app/core/phone/phone.service.spec.ts', 'top', 'app/core/phone/phone.service.spec.ts') :marked - In the phone detail controller spec, on the other hand, we should import - the phone detail module: + In the phone detail component spec we should import the phone detail module: -+makeExample('upgrade-phonecat/ts/typescript-conversion/test/unit/phone_detail.controller.spec.ts', 'top', 'test/unit/phone_detail.controller.spec.ts') ++makeExample('upgrade-phonecat/ts/typescript-conversion/app/phone-detail/phone-detail.component.spec.ts', 'top', 'app/phone-detail/phone-detail.component.spec.ts') :marked - Finally, the phone list controller spec should import the phone list + Finally, the phone list component spec should import the phone list module: -+makeExample('upgrade-phonecat/ts/typescript-conversion/test/unit/phone_list.controller.spec.ts', 'top', 'test/unit/phone_list.controller.spec.ts') - -:marked - There's one more issue we have in our controller tests, which is that TypeScript - isn't happy about compiling them at the moment. This is because we're using - the custom Jasmine matcher `toEqualData` in both of them. Because this is something - we define ourselves, it isn't included in the Jasmine type definitions that we - installed using Typings. - - We can add our own little type definition file for that extension, which extends - the `jasmine.Matchers` interface and adds our custom matcher to it. This will - satisfy the compiler and let us use our custom matcher while retaining the nice - type safety features of TypeScript: - -+makeExample('upgrade-phonecat/ts/typescript-conversion/test/jasmine_matchers.d.ts', null, 'test/jasmine_matchers.d.ts') ++makeExample('upgrade-phonecat/ts/typescript-conversion/app/phone-list/phone-list.component.spec.ts', 'top', 'app/phone-list/phone-list.component.spec.ts') :marked And now we have a fully functional test suite for our TypeScript-enabled @@ -1091,13 +1068,13 @@ code-example(format=""). Now that we have TypeScript, we can start benefiting from some of its other features in addition to the imports and exports that we're already using. - There's a lot of value the language can provide in Angular 1 applications. + There's a lot of value the language can provide to Angular 1 applications. For one thing, TypeScript is a superset of ES2015. Any app that has previously been written in ES5 - like the PhoneCat example has - can with TypeScript start incorporating all of the JavaScript features that are new to ES2015. - These include things like `let`s and `const`s, default function parameters, - and destructuring assignments. + These include things like `let`s and `const`s, arrow functions, default function + parameters, and destructuring assignments. Another thing we can do is start adding *type safety* to our code, by adding type annotations. For instance, we can annotate the checkmark @@ -1106,7 +1083,7 @@ code-example(format=""). possible for the TypeScript compiler to notify us when we're trying to use it with incompatible types. -+makeExample('upgrade-phonecat/ts/classes/app/js/core/checkmark.filter.ts', null, 'app/js/core/checkmark.filter.ts', {otl: /(:\w+)/g}) ++makeExample('upgrade-phonecat/ts/classes/app/core/checkmark/checkmark.filter.ts', null, 'app/core/checkmark/checkmark.filter.ts', {otl: /(:\w+)/g}) .l-sub-section :marked @@ -1124,37 +1101,41 @@ code-example(format=""). :marked Another TypeScript feature we can make use of is *classes*. In particular, we - can turn our controllers into classes. That way they'll be a step + can turn our component controllers into classes. That way they'll be a step closer to becoming Angular 2 component classes, which will make our life easier once we do the upgrade. Angular 1 expects controllers to be constructor functions. That's what - ES2015/TypeScript classes really are, so that means we can just register a - class as a controller and Angular 1 will happily use it. We also won't + ES2015/TypeScript classes really are, so that means we can just plug in a + class as a component controller and Angular 1 will happily use it. We also won't need to make any changes to our test suite as the external behavior of the - controllers will not change. + components will not change. - Here's what our new class for the phone list controller looks like. + Here's what our new class for the phone list component controller looks like: -+makeExample('upgrade-phonecat/ts/classes/app/js/phone_list/phone_list.controller.ts', null, 'app/js/phone_list/phone_list.controller.ts') ++makeExample('upgrade-phonecat/ts/classes/app/phone-list/phone-list.component.ts', null, 'app/phone-list/phone-list.component.ts') :marked What was previously done in the controller function is now done in the class - constructor function. The class additionally declares three members: The - array of phones, the name of the current sort key, and the search query. These - are all things we have already been attaching to the controller, - but that weren't explicitly declared anywhere. The last one of these isn't actually - used in the TypeScript code since it's only referred to in the template, but for - the sake of clarity we want to define all the members our controller will have. + constructor function. The dependency injection annotations are attached + to the class using a static TypeScript property `$inject`. At runtime this + becomes the `PhoneListController.$inject` property. + + The class additionally declares three members: The array of phones, the name of + the current sort key, and the search query. These are all things we have already + been attaching to the controller but that weren't explicitly declared anywhere. + The last one of these isn't actually used in the TypeScript code since it's only + referred to in the template, but for the sake of clarity we want to define all the + members our controller will have. In the Phone detail controller we'll have two members: One for the phone that the user is looking at and another for the URL of the currently displayed image. We can additionally introduce a TypeScript interface that explicitly defines what we expect the `$routeParams` object to contain when it is - passed to the controller. This interface is not exported and is just used internally + passed to the controller. This interface is not exported so it's just used internally inside this module: -+makeExample('upgrade-phonecat/ts/classes/app/js/phone_detail/phone_detail.controller.ts', null, 'app/js/phone_detail/phone_detail.controller.ts') ++makeExample('upgrade-phonecat/ts/classes/app/phone-detail/phone-detail.component.ts', null, 'app/phone-detail/phone-detail.component.ts') :marked This makes our controller code look a lot more like Angular 2 already. We're @@ -1196,9 +1177,9 @@ code-example(format=""). npm run typings install :marked - We should then load some Angular 2 dependencies into the application by adding - some `