From d707124fd958715a9e4e707e14b02731590180d6 Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Mon, 23 Mar 2020 17:31:55 +0200 Subject: [PATCH] test(docs-infra): fix unit tests and run them for specific docs examples on CI (#36143) Previously, only e2e tests were run for docs examples on CI. As a result, unit tests (which are included in the zipped archives we provide for users to download and play with the examples locally) were often outdated and broken. This commit configures specific docs examples that have meaningful unit tests to run them on CI (via the `run-example-e2e.js` script). Where necessary, the unit tests are fixed to ensure they pass and reflect the changes in the corresponding component/service. This commit also removes some auto-generated unit tests that are not meaningful (e.g. make trivial assertions, such that a component instance is truthy) and are often broken anyway (e.g. because the corresponding component has been changed in ways that make the tests fail). PR Close #36143 --- .../src/app/app.component.spec.ts | 27 -------------- .../src/app/app.component.spec.ts | 27 -------------- .../src/app/app.component.spec.ts | 32 ----------------- .../src/app/item.directive.spec.ts | 8 ----- .../item-detail/item-detail.component.spec.ts | 25 ------------- .../src/app/app.component.spec.ts | 16 --------- .../src/app/app.component.spec.ts | 27 -------------- .../item-detail/item-detail.component.spec.ts | 25 ------------- .../src/app/app.component.spec.ts | 32 ----------------- .../customer-dashboard.component.spec.ts | 25 ------------- .../forms-overview/example-config.json | 6 ++++ .../src/app/reactive/reactive.module.spec.ts | 13 ------- .../src/app/template/template.module.spec.ts | 13 ------- aio/content/examples/http/example-config.json | 6 +++- .../app/aliasing/aliasing.component.spec.ts | 25 ------------- .../src/app/app.component.spec.ts | 27 -------------- .../in-the-metadata.component.spec.ts | 25 ------------- .../input-output.component.spec.ts | 25 ------------- .../item-detail/item-detail.component.spec.ts | 25 ------------- .../item-output/item-output.component.spec.ts | 25 ------------- .../src/app/app.component.spec.ts | 16 --------- .../src/app/app.component.spec.ts | 36 ------------------- .../app/customers/customers.component.spec.ts | 25 ------------- .../src/app/orders/orders.component.spec.ts | 25 ------------- .../ngmodules/src/app/app.component.spec.ts | 32 ----------------- .../src/app/contact/contact.component.spec.ts | 25 ------------- .../src/app/items/items.component.spec.ts | 25 ------------- .../src/app/app.component.spec.ts | 27 -------------- .../item-detail/item-detail.component.spec.ts | 25 ------------- .../app/item-list/item-list.component.spec.ts | 25 ------------- .../string-init/string-init.component.spec.ts | 25 ------------- .../providers/src/app/app.component.spec.ts | 32 ----------------- .../providers/src/app/user.service.spec.ts | 12 ------- .../src/app/app.component.spec.ts | 27 -------------- .../page-not-found.component.spec.ts | 25 ------------- .../src/app/app.component.spec.ts | 27 -------------- .../examples/setup/example-config.json | 6 ++++ .../setup/src/app/app.component.spec.ts | 4 +-- .../src/app/app.component.spec.ts | 27 -------------- .../src/app/app.component.spec.ts | 27 -------------- .../examples/testing/example-config.json | 6 +++- .../src/app/about/about.component.spec.ts | 2 +- .../testing/src/app/app-routing.module.ts | 18 +++++----- .../src/app/app.component.router.spec.ts | 20 ++++++----- .../examples/testing/src/app/app.module.ts | 3 +- .../testing/src/app/demo/demo.testbed.spec.ts | 14 ++++---- .../src/app/welcome/welcome.component.spec.ts | 22 ++++-------- .../src/app/welcome/welcome.component.ts | 4 +-- aio/content/examples/testing/src/tests.sb.ts | 1 + .../toh-pt0/src/app/app.component.spec.ts | 32 ----------------- .../src/app/heroes/heroes.component.spec.ts | 25 ------------- .../src/app/heroes/heroes.component.spec.ts | 25 ------------- .../src/app/heroes/heroes.component.spec.ts | 25 ------------- .../src/app/heroes/heroes.component.spec.ts | 25 ------------- .../toh-pt4/src/app/message.service.spec.ts | 15 -------- .../app/messages/messages.component.spec.ts | 25 ------------- .../app/dashboard/dashboard.component.spec.ts | 25 ------------- .../src/app/heroes/heroes.component.spec.ts | 25 ------------- .../toh-pt5/src/app/message.service.spec.ts | 15 -------- .../app/messages/messages.component.spec.ts | 25 ------------- .../examples/toh-pt6/example-config.json | 6 ++++ .../hero-search/hero-search.component.spec.ts | 29 --------------- .../src/app/heroes/heroes.component.spec.ts | 27 -------------- .../toh-pt6/src/app/message.service.spec.ts | 15 -------- .../app/messages/messages.component.spec.ts | 25 ------------- .../src/app/app.component.spec.ts | 27 -------------- .../src/app/sizer/sizer.component.spec.ts | 25 ------------- .../app/dashboard/dashboard.component.spec.ts | 25 ------------- .../hero-search/hero-search.component.spec.ts | 25 ------------- .../src/app/heroes/heroes.component.spec.ts | 25 ------------- .../universal/src/app/message.service.spec.ts | 15 -------- .../app/messages/messages.component.spec.ts | 25 ------------- .../upgrade-phonecat-3-final/README.md | 3 -- .../run-unit-tests.sh | 6 ---- aio/content/guide/testing.md | 12 ------- aio/tools/examples/run-example-e2e.js | 3 ++ 76 files changed, 74 insertions(+), 1478 deletions(-) delete mode 100644 aio/content/examples/attribute-binding/src/app/app.component.spec.ts delete mode 100644 aio/content/examples/binding-syntax/src/app/app.component.spec.ts delete mode 100644 aio/content/examples/bootstrapping/src/app/app.component.spec.ts delete mode 100644 aio/content/examples/bootstrapping/src/app/item.directive.spec.ts delete mode 100644 aio/content/examples/built-in-directives/src/app/item-detail/item-detail.component.spec.ts delete mode 100644 aio/content/examples/built-in-template-functions/src/app/app.component.spec.ts delete mode 100644 aio/content/examples/event-binding/src/app/app.component.spec.ts delete mode 100644 aio/content/examples/event-binding/src/app/item-detail/item-detail.component.spec.ts delete mode 100644 aio/content/examples/feature-modules/src/app/app.component.spec.ts delete mode 100644 aio/content/examples/feature-modules/src/app/customer-dashboard/customer-dashboard/customer-dashboard.component.spec.ts delete mode 100644 aio/content/examples/forms-overview/src/app/reactive/reactive.module.spec.ts delete mode 100644 aio/content/examples/forms-overview/src/app/template/template.module.spec.ts delete mode 100644 aio/content/examples/inputs-outputs/src/app/aliasing/aliasing.component.spec.ts delete mode 100644 aio/content/examples/inputs-outputs/src/app/app.component.spec.ts delete mode 100644 aio/content/examples/inputs-outputs/src/app/in-the-metadata/in-the-metadata.component.spec.ts delete mode 100644 aio/content/examples/inputs-outputs/src/app/input-output/input-output.component.spec.ts delete mode 100644 aio/content/examples/inputs-outputs/src/app/item-detail/item-detail.component.spec.ts delete mode 100644 aio/content/examples/inputs-outputs/src/app/item-output/item-output.component.spec.ts delete mode 100644 aio/content/examples/interpolation/src/app/app.component.spec.ts delete mode 100644 aio/content/examples/lazy-loading-ngmodules/src/app/app.component.spec.ts delete mode 100644 aio/content/examples/lazy-loading-ngmodules/src/app/customers/customers.component.spec.ts delete mode 100644 aio/content/examples/lazy-loading-ngmodules/src/app/orders/orders.component.spec.ts delete mode 100644 aio/content/examples/ngmodules/src/app/app.component.spec.ts delete mode 100644 aio/content/examples/ngmodules/src/app/contact/contact.component.spec.ts delete mode 100644 aio/content/examples/ngmodules/src/app/items/items.component.spec.ts delete mode 100644 aio/content/examples/property-binding/src/app/app.component.spec.ts delete mode 100644 aio/content/examples/property-binding/src/app/item-detail/item-detail.component.spec.ts delete mode 100644 aio/content/examples/property-binding/src/app/item-list/item-list.component.spec.ts delete mode 100644 aio/content/examples/property-binding/src/app/string-init/string-init.component.spec.ts delete mode 100644 aio/content/examples/providers/src/app/app.component.spec.ts delete mode 100644 aio/content/examples/providers/src/app/user.service.spec.ts delete mode 100644 aio/content/examples/reactive-forms/src/app/app.component.spec.ts delete mode 100644 aio/content/examples/router/src/app/page-not-found/page-not-found.component.spec.ts delete mode 100755 aio/content/examples/service-worker-getting-started/src/app/app.component.spec.ts delete mode 100644 aio/content/examples/template-expression-operators/src/app/app.component.spec.ts delete mode 100644 aio/content/examples/template-reference-variables/src/app/app.component.spec.ts delete mode 100644 aio/content/examples/toh-pt0/src/app/app.component.spec.ts delete mode 100644 aio/content/examples/toh-pt1/src/app/heroes/heroes.component.spec.ts delete mode 100644 aio/content/examples/toh-pt2/src/app/heroes/heroes.component.spec.ts delete mode 100644 aio/content/examples/toh-pt3/src/app/heroes/heroes.component.spec.ts delete mode 100644 aio/content/examples/toh-pt4/src/app/heroes/heroes.component.spec.ts delete mode 100644 aio/content/examples/toh-pt4/src/app/message.service.spec.ts delete mode 100644 aio/content/examples/toh-pt4/src/app/messages/messages.component.spec.ts delete mode 100644 aio/content/examples/toh-pt5/src/app/dashboard/dashboard.component.spec.ts delete mode 100644 aio/content/examples/toh-pt5/src/app/heroes/heroes.component.spec.ts delete mode 100644 aio/content/examples/toh-pt5/src/app/message.service.spec.ts delete mode 100644 aio/content/examples/toh-pt5/src/app/messages/messages.component.spec.ts delete mode 100644 aio/content/examples/toh-pt6/src/app/hero-search/hero-search.component.spec.ts delete mode 100644 aio/content/examples/toh-pt6/src/app/heroes/heroes.component.spec.ts delete mode 100644 aio/content/examples/toh-pt6/src/app/message.service.spec.ts delete mode 100644 aio/content/examples/toh-pt6/src/app/messages/messages.component.spec.ts delete mode 100644 aio/content/examples/two-way-binding/src/app/app.component.spec.ts delete mode 100644 aio/content/examples/two-way-binding/src/app/sizer/sizer.component.spec.ts delete mode 100644 aio/content/examples/universal/src/app/dashboard/dashboard.component.spec.ts delete mode 100644 aio/content/examples/universal/src/app/hero-search/hero-search.component.spec.ts delete mode 100644 aio/content/examples/universal/src/app/heroes/heroes.component.spec.ts delete mode 100644 aio/content/examples/universal/src/app/message.service.spec.ts delete mode 100644 aio/content/examples/universal/src/app/messages/messages.component.spec.ts delete mode 100644 aio/content/examples/upgrade-phonecat-3-final/run-unit-tests.sh diff --git a/aio/content/examples/attribute-binding/src/app/app.component.spec.ts b/aio/content/examples/attribute-binding/src/app/app.component.spec.ts deleted file mode 100644 index 1f327e6574..0000000000 --- a/aio/content/examples/attribute-binding/src/app/app.component.spec.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { TestBed, async } from '@angular/core/testing'; -import { AppComponent } from './app.component'; -describe('AppComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ - AppComponent - ], - }).compileComponents(); - })); - it('should create the app', async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app).toBeTruthy(); - })); - it(`should have as title 'app'`, async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app.title).toEqual('app'); - })); - it('should render title', async(() => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!'); - })); -}); diff --git a/aio/content/examples/binding-syntax/src/app/app.component.spec.ts b/aio/content/examples/binding-syntax/src/app/app.component.spec.ts deleted file mode 100644 index 1f327e6574..0000000000 --- a/aio/content/examples/binding-syntax/src/app/app.component.spec.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { TestBed, async } from '@angular/core/testing'; -import { AppComponent } from './app.component'; -describe('AppComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ - AppComponent - ], - }).compileComponents(); - })); - it('should create the app', async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app).toBeTruthy(); - })); - it(`should have as title 'app'`, async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app.title).toEqual('app'); - })); - it('should render title', async(() => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!'); - })); -}); diff --git a/aio/content/examples/bootstrapping/src/app/app.component.spec.ts b/aio/content/examples/bootstrapping/src/app/app.component.spec.ts deleted file mode 100644 index 0e3504562b..0000000000 --- a/aio/content/examples/bootstrapping/src/app/app.component.spec.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { TestBed, async } from '@angular/core/testing'; -import { AppComponent } from './app.component'; - -describe('AppComponent', () => { - beforeEach(() => { - TestBed.configureTestingModule({ - declarations: [ - AppComponent - ], - }); - TestBed.compileComponents(); - }); - - it('should create the app', async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app).toBeTruthy(); - })); - - it(`should have as title 'app works!'`, async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app.title).toEqual('app works!'); - })); - - it('should render title', async(() => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1').textContent).toContain('app works!'); - })); -}); diff --git a/aio/content/examples/bootstrapping/src/app/item.directive.spec.ts b/aio/content/examples/bootstrapping/src/app/item.directive.spec.ts deleted file mode 100644 index 0c184d30da..0000000000 --- a/aio/content/examples/bootstrapping/src/app/item.directive.spec.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { ItemDirective } from './item.directive'; - -describe('ItemDirective', () => { - it('should create an instance', () => { - const directive = new ItemDirective(); - expect(directive).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/built-in-directives/src/app/item-detail/item-detail.component.spec.ts b/aio/content/examples/built-in-directives/src/app/item-detail/item-detail.component.spec.ts deleted file mode 100644 index 7559cb65f6..0000000000 --- a/aio/content/examples/built-in-directives/src/app/item-detail/item-detail.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { ItemDetailComponent } from './item-detail.component'; - -describe('ItemDetailComponent', () => { - let component: ItemDetailComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ ItemDetailComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(ItemDetailComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/built-in-template-functions/src/app/app.component.spec.ts b/aio/content/examples/built-in-template-functions/src/app/app.component.spec.ts deleted file mode 100644 index f28fb061be..0000000000 --- a/aio/content/examples/built-in-template-functions/src/app/app.component.spec.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { TestBed, async } from '@angular/core/testing'; -import { AppComponent } from './app.component'; -describe('AppComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ - AppComponent - ], - }).compileComponents(); - })); - it('should create the app', async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app).toBeTruthy(); - })); -}); diff --git a/aio/content/examples/event-binding/src/app/app.component.spec.ts b/aio/content/examples/event-binding/src/app/app.component.spec.ts deleted file mode 100644 index 70abd5114b..0000000000 --- a/aio/content/examples/event-binding/src/app/app.component.spec.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { TestBed, async } from '@angular/core/testing'; -import { AppComponent } from './app.component'; -describe('AppComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ - AppComponent - ], - }).compileComponents(); - })); - it('should create the app', async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app).toBeTruthy(); - })); - it(`should have as title 'Featured product:'`, async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app.title).toEqual('Featured product:'); - })); - it('should render title in a p tag', async(() => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('p').textContent).toContain('Featured product:'); - })); -}); diff --git a/aio/content/examples/event-binding/src/app/item-detail/item-detail.component.spec.ts b/aio/content/examples/event-binding/src/app/item-detail/item-detail.component.spec.ts deleted file mode 100644 index 7559cb65f6..0000000000 --- a/aio/content/examples/event-binding/src/app/item-detail/item-detail.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { ItemDetailComponent } from './item-detail.component'; - -describe('ItemDetailComponent', () => { - let component: ItemDetailComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ ItemDetailComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(ItemDetailComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/feature-modules/src/app/app.component.spec.ts b/aio/content/examples/feature-modules/src/app/app.component.spec.ts deleted file mode 100644 index 0e3504562b..0000000000 --- a/aio/content/examples/feature-modules/src/app/app.component.spec.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { TestBed, async } from '@angular/core/testing'; -import { AppComponent } from './app.component'; - -describe('AppComponent', () => { - beforeEach(() => { - TestBed.configureTestingModule({ - declarations: [ - AppComponent - ], - }); - TestBed.compileComponents(); - }); - - it('should create the app', async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app).toBeTruthy(); - })); - - it(`should have as title 'app works!'`, async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app.title).toEqual('app works!'); - })); - - it('should render title', async(() => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1').textContent).toContain('app works!'); - })); -}); diff --git a/aio/content/examples/feature-modules/src/app/customer-dashboard/customer-dashboard/customer-dashboard.component.spec.ts b/aio/content/examples/feature-modules/src/app/customer-dashboard/customer-dashboard/customer-dashboard.component.spec.ts deleted file mode 100644 index 2420d05521..0000000000 --- a/aio/content/examples/feature-modules/src/app/customer-dashboard/customer-dashboard/customer-dashboard.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { CustomerDashboardComponent } from './customer-dashboard.component'; - -describe('CustomerDashboardComponent', () => { - let component: CustomerDashboardComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ CustomerDashboardComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(CustomerDashboardComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/forms-overview/example-config.json b/aio/content/examples/forms-overview/example-config.json index e69de29bb2..a3fb39d2be 100644 --- a/aio/content/examples/forms-overview/example-config.json +++ b/aio/content/examples/forms-overview/example-config.json @@ -0,0 +1,6 @@ +{ + "e2e": [ + {"cmd": "yarn", "args": ["test", "--browsers=ChromeHeadless", "--no-watch"]}, + {"cmd": "yarn", "args": ["e2e", "--prod", "--protractor-config=e2e/protractor-puppeteer.conf.js", "--no-webdriver-update", "--port={PORT}"]} + ] +} diff --git a/aio/content/examples/forms-overview/src/app/reactive/reactive.module.spec.ts b/aio/content/examples/forms-overview/src/app/reactive/reactive.module.spec.ts deleted file mode 100644 index 3add422b83..0000000000 --- a/aio/content/examples/forms-overview/src/app/reactive/reactive.module.spec.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { ReactiveModule } from './reactive.module'; - -describe('ReactiveModule', () => { - let reactiveModule: ReactiveModule; - - beforeEach(() => { - reactiveModule = new ReactiveModule(); - }); - - it('should create an instance', () => { - expect(reactiveModule).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/forms-overview/src/app/template/template.module.spec.ts b/aio/content/examples/forms-overview/src/app/template/template.module.spec.ts deleted file mode 100644 index cb28c36acd..0000000000 --- a/aio/content/examples/forms-overview/src/app/template/template.module.spec.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { TemplateModule } from './template.module'; - -describe('TemplateModule', () => { - let templateModule: TemplateModule; - - beforeEach(() => { - templateModule = new TemplateModule(); - }); - - it('should create an instance', () => { - expect(templateModule).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/http/example-config.json b/aio/content/examples/http/example-config.json index 317e9458f3..f6afa36536 100644 --- a/aio/content/examples/http/example-config.json +++ b/aio/content/examples/http/example-config.json @@ -1,3 +1,7 @@ { - "projectType": "testing" + "projectType": "testing", + "e2e": [ + {"cmd": "yarn", "args": ["test", "--browsers=ChromeHeadless", "--no-watch"]}, + {"cmd": "yarn", "args": ["e2e", "--prod", "--protractor-config=e2e/protractor-puppeteer.conf.js", "--no-webdriver-update", "--port={PORT}"]} + ] } diff --git a/aio/content/examples/inputs-outputs/src/app/aliasing/aliasing.component.spec.ts b/aio/content/examples/inputs-outputs/src/app/aliasing/aliasing.component.spec.ts deleted file mode 100644 index 8f93c989bc..0000000000 --- a/aio/content/examples/inputs-outputs/src/app/aliasing/aliasing.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { AliasingComponent } from './aliasing.component'; - -describe('AliasingComponent', () => { - let component: AliasingComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ AliasingComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(AliasingComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/inputs-outputs/src/app/app.component.spec.ts b/aio/content/examples/inputs-outputs/src/app/app.component.spec.ts deleted file mode 100644 index 1f327e6574..0000000000 --- a/aio/content/examples/inputs-outputs/src/app/app.component.spec.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { TestBed, async } from '@angular/core/testing'; -import { AppComponent } from './app.component'; -describe('AppComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ - AppComponent - ], - }).compileComponents(); - })); - it('should create the app', async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app).toBeTruthy(); - })); - it(`should have as title 'app'`, async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app.title).toEqual('app'); - })); - it('should render title', async(() => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!'); - })); -}); diff --git a/aio/content/examples/inputs-outputs/src/app/in-the-metadata/in-the-metadata.component.spec.ts b/aio/content/examples/inputs-outputs/src/app/in-the-metadata/in-the-metadata.component.spec.ts deleted file mode 100644 index eaa33528a9..0000000000 --- a/aio/content/examples/inputs-outputs/src/app/in-the-metadata/in-the-metadata.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { InTheMetadataComponent } from './in-the-metadata.component'; - -describe('InTheMetadataComponent', () => { - let component: InTheMetadataComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ InTheMetadataComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(InTheMetadataComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/inputs-outputs/src/app/input-output/input-output.component.spec.ts b/aio/content/examples/inputs-outputs/src/app/input-output/input-output.component.spec.ts deleted file mode 100644 index 7e49af8ac4..0000000000 --- a/aio/content/examples/inputs-outputs/src/app/input-output/input-output.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { InputOutputComponent } from './input-output.component'; - -describe('InputOutputComponent', () => { - let component: InputOutputComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ InputOutputComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(InputOutputComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/inputs-outputs/src/app/item-detail/item-detail.component.spec.ts b/aio/content/examples/inputs-outputs/src/app/item-detail/item-detail.component.spec.ts deleted file mode 100644 index 7559cb65f6..0000000000 --- a/aio/content/examples/inputs-outputs/src/app/item-detail/item-detail.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { ItemDetailComponent } from './item-detail.component'; - -describe('ItemDetailComponent', () => { - let component: ItemDetailComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ ItemDetailComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(ItemDetailComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/inputs-outputs/src/app/item-output/item-output.component.spec.ts b/aio/content/examples/inputs-outputs/src/app/item-output/item-output.component.spec.ts deleted file mode 100644 index c307491352..0000000000 --- a/aio/content/examples/inputs-outputs/src/app/item-output/item-output.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { ItemOutputComponent } from './item-output.component'; - -describe('ItemOutputComponent', () => { - let component: ItemOutputComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ ItemOutputComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(ItemOutputComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/interpolation/src/app/app.component.spec.ts b/aio/content/examples/interpolation/src/app/app.component.spec.ts deleted file mode 100644 index f28fb061be..0000000000 --- a/aio/content/examples/interpolation/src/app/app.component.spec.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { TestBed, async } from '@angular/core/testing'; -import { AppComponent } from './app.component'; -describe('AppComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ - AppComponent - ], - }).compileComponents(); - })); - it('should create the app', async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app).toBeTruthy(); - })); -}); diff --git a/aio/content/examples/lazy-loading-ngmodules/src/app/app.component.spec.ts b/aio/content/examples/lazy-loading-ngmodules/src/app/app.component.spec.ts deleted file mode 100644 index 37a8e88df0..0000000000 --- a/aio/content/examples/lazy-loading-ngmodules/src/app/app.component.spec.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { TestBed, async } from '@angular/core/testing'; -import { RouterTestingModule } from '@angular/router/testing'; -import { AppComponent } from './app.component'; - -describe('AppComponent', () => { - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ - RouterTestingModule - ], - declarations: [ - AppComponent - ], - }); - TestBed.compileComponents(); - }); - - it('should create the app', async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app).toBeTruthy(); - })); - - it(`should have as title 'customer-app'`, async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app.title).toEqual('customer-app'); - })); - - it('should render title', async(() => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1').textContent).toContain('customer-app'); - })); -}); diff --git a/aio/content/examples/lazy-loading-ngmodules/src/app/customers/customers.component.spec.ts b/aio/content/examples/lazy-loading-ngmodules/src/app/customers/customers.component.spec.ts deleted file mode 100644 index 1543c2d317..0000000000 --- a/aio/content/examples/lazy-loading-ngmodules/src/app/customers/customers.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { CustomersComponent } from './customers.component'; - -describe('CustomerListComponent', () => { - let component: CustomersComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ CustomersComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(CustomersComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/lazy-loading-ngmodules/src/app/orders/orders.component.spec.ts b/aio/content/examples/lazy-loading-ngmodules/src/app/orders/orders.component.spec.ts deleted file mode 100644 index bc78306cb0..0000000000 --- a/aio/content/examples/lazy-loading-ngmodules/src/app/orders/orders.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { OrdersComponent } from './orders.component'; - -describe('OrderListComponent', () => { - let component: OrdersComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ OrdersComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(OrdersComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/ngmodules/src/app/app.component.spec.ts b/aio/content/examples/ngmodules/src/app/app.component.spec.ts deleted file mode 100644 index 0e3504562b..0000000000 --- a/aio/content/examples/ngmodules/src/app/app.component.spec.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { TestBed, async } from '@angular/core/testing'; -import { AppComponent } from './app.component'; - -describe('AppComponent', () => { - beforeEach(() => { - TestBed.configureTestingModule({ - declarations: [ - AppComponent - ], - }); - TestBed.compileComponents(); - }); - - it('should create the app', async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app).toBeTruthy(); - })); - - it(`should have as title 'app works!'`, async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app.title).toEqual('app works!'); - })); - - it('should render title', async(() => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1').textContent).toContain('app works!'); - })); -}); diff --git a/aio/content/examples/ngmodules/src/app/contact/contact.component.spec.ts b/aio/content/examples/ngmodules/src/app/contact/contact.component.spec.ts deleted file mode 100644 index 427633e0a0..0000000000 --- a/aio/content/examples/ngmodules/src/app/contact/contact.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { ContactComponent } from './contact.component'; - -describe('ContactComponent', () => { - let component: ContactComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ ContactComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(ContactComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/ngmodules/src/app/items/items.component.spec.ts b/aio/content/examples/ngmodules/src/app/items/items.component.spec.ts deleted file mode 100644 index b77cce74ec..0000000000 --- a/aio/content/examples/ngmodules/src/app/items/items.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { ItemsComponent } from './items.component'; - -describe('ItemsComponent', () => { - let component: ItemsComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ ItemsComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(ItemsComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/property-binding/src/app/app.component.spec.ts b/aio/content/examples/property-binding/src/app/app.component.spec.ts deleted file mode 100644 index 1f327e6574..0000000000 --- a/aio/content/examples/property-binding/src/app/app.component.spec.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { TestBed, async } from '@angular/core/testing'; -import { AppComponent } from './app.component'; -describe('AppComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ - AppComponent - ], - }).compileComponents(); - })); - it('should create the app', async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app).toBeTruthy(); - })); - it(`should have as title 'app'`, async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app.title).toEqual('app'); - })); - it('should render title', async(() => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!'); - })); -}); diff --git a/aio/content/examples/property-binding/src/app/item-detail/item-detail.component.spec.ts b/aio/content/examples/property-binding/src/app/item-detail/item-detail.component.spec.ts deleted file mode 100644 index 7559cb65f6..0000000000 --- a/aio/content/examples/property-binding/src/app/item-detail/item-detail.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { ItemDetailComponent } from './item-detail.component'; - -describe('ItemDetailComponent', () => { - let component: ItemDetailComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ ItemDetailComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(ItemDetailComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/property-binding/src/app/item-list/item-list.component.spec.ts b/aio/content/examples/property-binding/src/app/item-list/item-list.component.spec.ts deleted file mode 100644 index e11a57d78c..0000000000 --- a/aio/content/examples/property-binding/src/app/item-list/item-list.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { ItemListComponent } from './item-list.component'; - -describe('ItemListComponent', () => { - let component: ItemListComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ ItemListComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(ItemListComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/property-binding/src/app/string-init/string-init.component.spec.ts b/aio/content/examples/property-binding/src/app/string-init/string-init.component.spec.ts deleted file mode 100644 index 2c8e97ec82..0000000000 --- a/aio/content/examples/property-binding/src/app/string-init/string-init.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { StringInitComponent } from './string-init.component'; - -describe('StringInitComponent', () => { - let component: StringInitComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ StringInitComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(StringInitComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/providers/src/app/app.component.spec.ts b/aio/content/examples/providers/src/app/app.component.spec.ts deleted file mode 100644 index 0e3504562b..0000000000 --- a/aio/content/examples/providers/src/app/app.component.spec.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { TestBed, async } from '@angular/core/testing'; -import { AppComponent } from './app.component'; - -describe('AppComponent', () => { - beforeEach(() => { - TestBed.configureTestingModule({ - declarations: [ - AppComponent - ], - }); - TestBed.compileComponents(); - }); - - it('should create the app', async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app).toBeTruthy(); - })); - - it(`should have as title 'app works!'`, async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app.title).toEqual('app works!'); - })); - - it('should render title', async(() => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1').textContent).toContain('app works!'); - })); -}); diff --git a/aio/content/examples/providers/src/app/user.service.spec.ts b/aio/content/examples/providers/src/app/user.service.spec.ts deleted file mode 100644 index dcf5565717..0000000000 --- a/aio/content/examples/providers/src/app/user.service.spec.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { TestBed, inject } from '@angular/core/testing'; -import { UserService } from './user.service'; - -describe('UserService', () => { - beforeEach(() => { - TestBed.configureTestingModule({}); - }); - - it('should ...', inject([UserService], (service: UserService) => { - expect(service).toBeTruthy(); - })); -}); diff --git a/aio/content/examples/reactive-forms/src/app/app.component.spec.ts b/aio/content/examples/reactive-forms/src/app/app.component.spec.ts deleted file mode 100644 index 355989efcd..0000000000 --- a/aio/content/examples/reactive-forms/src/app/app.component.spec.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { TestBed, async } from '@angular/core/testing'; -import { AppComponent } from './app.component'; -describe('AppComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ - AppComponent - ], - }).compileComponents(); - })); - it('should create the app', async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app).toBeTruthy(); - })); - it(`should have as title 'app'`, async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app.title).toEqual('app'); - })); - it('should render title', async(() => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1').textContent).toContain('Welcome to reactive-forms!'); - })); -}); diff --git a/aio/content/examples/router/src/app/page-not-found/page-not-found.component.spec.ts b/aio/content/examples/router/src/app/page-not-found/page-not-found.component.spec.ts deleted file mode 100644 index 697a946572..0000000000 --- a/aio/content/examples/router/src/app/page-not-found/page-not-found.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { PageNotFoundComponent } from './page-not-found.component'; - -describe('PageNotFoundComponent', () => { - let component: PageNotFoundComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ PageNotFoundComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(PageNotFoundComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/service-worker-getting-started/src/app/app.component.spec.ts b/aio/content/examples/service-worker-getting-started/src/app/app.component.spec.ts deleted file mode 100755 index b59df0cbc1..0000000000 --- a/aio/content/examples/service-worker-getting-started/src/app/app.component.spec.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { TestBed, async } from '@angular/core/testing'; -import { AppComponent } from './app.component'; -describe('AppComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ - AppComponent - ], - }).compileComponents(); - })); - it('should create the app', async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app).toBeTruthy(); - })); - it(`should have as title 'app'`, async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app.title).toEqual('Service Workers'); - })); - it('should render title', async(() => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1').textContent).toContain('Welcome to Service Workers!'); - })); -}); diff --git a/aio/content/examples/setup/example-config.json b/aio/content/examples/setup/example-config.json index e69de29bb2..a3fb39d2be 100644 --- a/aio/content/examples/setup/example-config.json +++ b/aio/content/examples/setup/example-config.json @@ -0,0 +1,6 @@ +{ + "e2e": [ + {"cmd": "yarn", "args": ["test", "--browsers=ChromeHeadless", "--no-watch"]}, + {"cmd": "yarn", "args": ["e2e", "--prod", "--protractor-config=e2e/protractor-puppeteer.conf.js", "--no-webdriver-update", "--port={PORT}"]} + ] +} diff --git a/aio/content/examples/setup/src/app/app.component.spec.ts b/aio/content/examples/setup/src/app/app.component.spec.ts index 4998dec904..eebc33ed8a 100644 --- a/aio/content/examples/setup/src/app/app.component.spec.ts +++ b/aio/content/examples/setup/src/app/app.component.spec.ts @@ -1,10 +1,10 @@ import { AppComponent } from './app.component'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { By } from '@angular/platform-browser'; +import { By } from '@angular/platform-browser'; import { DebugElement } from '@angular/core'; -describe('AppComponent', function () { +describe('AppComponent', () => { let de: DebugElement; let comp: AppComponent; let fixture: ComponentFixture; diff --git a/aio/content/examples/template-expression-operators/src/app/app.component.spec.ts b/aio/content/examples/template-expression-operators/src/app/app.component.spec.ts deleted file mode 100644 index 1f327e6574..0000000000 --- a/aio/content/examples/template-expression-operators/src/app/app.component.spec.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { TestBed, async } from '@angular/core/testing'; -import { AppComponent } from './app.component'; -describe('AppComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ - AppComponent - ], - }).compileComponents(); - })); - it('should create the app', async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app).toBeTruthy(); - })); - it(`should have as title 'app'`, async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app.title).toEqual('app'); - })); - it('should render title', async(() => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!'); - })); -}); diff --git a/aio/content/examples/template-reference-variables/src/app/app.component.spec.ts b/aio/content/examples/template-reference-variables/src/app/app.component.spec.ts deleted file mode 100644 index 1f327e6574..0000000000 --- a/aio/content/examples/template-reference-variables/src/app/app.component.spec.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { TestBed, async } from '@angular/core/testing'; -import { AppComponent } from './app.component'; -describe('AppComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ - AppComponent - ], - }).compileComponents(); - })); - it('should create the app', async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app).toBeTruthy(); - })); - it(`should have as title 'app'`, async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app.title).toEqual('app'); - })); - it('should render title', async(() => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!'); - })); -}); diff --git a/aio/content/examples/testing/example-config.json b/aio/content/examples/testing/example-config.json index 317e9458f3..f6afa36536 100644 --- a/aio/content/examples/testing/example-config.json +++ b/aio/content/examples/testing/example-config.json @@ -1,3 +1,7 @@ { - "projectType": "testing" + "projectType": "testing", + "e2e": [ + {"cmd": "yarn", "args": ["test", "--browsers=ChromeHeadless", "--no-watch"]}, + {"cmd": "yarn", "args": ["e2e", "--prod", "--protractor-config=e2e/protractor-puppeteer.conf.js", "--no-webdriver-update", "--port={PORT}"]} + ] } diff --git a/aio/content/examples/testing/src/app/about/about.component.spec.ts b/aio/content/examples/testing/src/app/about/about.component.spec.ts index 80bebd99a7..0960de315c 100644 --- a/aio/content/examples/testing/src/app/about/about.component.spec.ts +++ b/aio/content/examples/testing/src/app/about/about.component.spec.ts @@ -10,7 +10,7 @@ describe('AboutComponent (highlightDirective)', () => { // #docregion tests beforeEach(() => { fixture = TestBed.configureTestingModule({ - declarations: [ AboutComponent, HighlightDirective], + declarations: [ AboutComponent, HighlightDirective ], schemas: [ NO_ERRORS_SCHEMA ] }) .createComponent(AboutComponent); diff --git a/aio/content/examples/testing/src/app/app-routing.module.ts b/aio/content/examples/testing/src/app/app-routing.module.ts index 97fa809ad9..937f6035c3 100644 --- a/aio/content/examples/testing/src/app/app-routing.module.ts +++ b/aio/content/examples/testing/src/app/app-routing.module.ts @@ -1,16 +1,18 @@ -import { NgModule } from '@angular/core'; -import { RouterModule } from '@angular/router'; +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; import { AboutComponent } from './about/about.component'; +export const routes: Routes = [ + { path: '', redirectTo: 'dashboard', pathMatch: 'full'}, + { path: 'about', component: AboutComponent }, + { path: 'heroes', loadChildren: () => import('./hero/hero.module').then(m => m.HeroModule)}, +]; + @NgModule({ imports: [ - RouterModule.forRoot([ - { path: '', redirectTo: 'dashboard', pathMatch: 'full'}, - { path: 'about', component: AboutComponent }, - { path: 'heroes', loadChildren: () => import('./hero/hero.module').then(m => m.HeroModule)} - ]) + RouterModule.forRoot(routes), ], exports: [ RouterModule ] // re-export the module declarations }) -export class AppRoutingModule { }; +export class AppRoutingModule { } diff --git a/aio/content/examples/testing/src/app/app.component.router.spec.ts b/aio/content/examples/testing/src/app/app.component.router.spec.ts index df04f405fc..6e183a3aad 100644 --- a/aio/content/examples/testing/src/app/app.component.router.spec.ts +++ b/aio/content/examples/testing/src/app/app.component.router.spec.ts @@ -1,16 +1,13 @@ // For more examples: // https://github.com/angular/angular/blob/master/modules/@angular/router/test/integration.spec.ts -import { async, ComponentFixture, fakeAsync, TestBed, tick, -} from '@angular/core/testing'; +import { async, ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; import { asyncData } from '../testing'; import { RouterTestingModule } from '@angular/router/testing'; import { SpyLocation } from '@angular/common/testing'; -// r - for relatively obscure router symbols -import * as r from '@angular/router'; import { Router, RouterLinkWithHref } from '@angular/router'; import { By } from '@angular/platform-browser'; @@ -19,6 +16,7 @@ import { Location } from '@angular/common'; import { click } from '../testing'; +import { routes } from './app-routing.module'; import { AppModule } from './app.module'; import { AppComponent } from './app.component'; import { AboutComponent } from './about/about.component'; @@ -37,7 +35,10 @@ describe('AppComponent & RouterTestingModule', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [ AppModule, RouterTestingModule ], + imports: [ + AppModule, + RouterTestingModule.withRoutes(routes), + ], providers: [ { provide: HeroService, useClass: TestHeroService } ] @@ -48,7 +49,7 @@ describe('AppComponent & RouterTestingModule', () => { it('should navigate to "Dashboard" immediately', fakeAsync(() => { createComponent(); tick(); // wait for async data to arrive - expect(location.path()).toEqual('/dashboard', 'after initialNavigation()'); + expectPathToBe('/dashboard', 'after initialNavigation()'); expectElementOf(DashboardComponent); })); @@ -96,14 +97,17 @@ xdescribe('AppComponent & Lazy Loading (not working yet)', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [ AppModule, RouterTestingModule ] + imports: [ + AppModule, + RouterTestingModule.withRoutes(routes), + ], }) .compileComponents(); })); beforeEach(fakeAsync(() => { createComponent(); - loader = TestBed.inject(NgModuleFactoryLoader); + loader = TestBed.inject(NgModuleFactoryLoader) as SpyNgModuleFactoryLoader; loader.stubbedModules = { expected: HeroModule }; router.resetConfig([{path: 'heroes', loadChildren: 'expected'}]); })); diff --git a/aio/content/examples/testing/src/app/app.module.ts b/aio/content/examples/testing/src/app/app.module.ts index aecf6ea5e2..65f620dca7 100644 --- a/aio/content/examples/testing/src/app/app.module.ts +++ b/aio/content/examples/testing/src/app/app.module.ts @@ -44,7 +44,8 @@ import { InMemoryDataService } from './in-memory-data.service'; AboutComponent, BannerComponent, TwainComponent, - WelcomeComponent ], + WelcomeComponent, + ], bootstrap: [ AppComponent ] }) export class AppModule { } diff --git a/aio/content/examples/testing/src/app/demo/demo.testbed.spec.ts b/aio/content/examples/testing/src/app/demo/demo.testbed.spec.ts index 2e75604446..c22391b16a 100644 --- a/aio/content/examples/testing/src/app/demo/demo.testbed.spec.ts +++ b/aio/content/examples/testing/src/app/demo/demo.testbed.spec.ts @@ -110,7 +110,7 @@ describe('demo (with TestBed):', () => { }); // Inject both the service-to-test and its (spy) dependency masterService = TestBed.inject(MasterService); - valueServiceSpy = TestBed.inject(ValueService); + valueServiceSpy = TestBed.inject(ValueService) as jasmine.SpyObj; }); // #enddocregion master-service-before-each @@ -373,14 +373,14 @@ describe('demo (with TestBed):', () => { expect(el.context).toBe(childComp, 'context is the child component'); - expect(el.attributes['account']).toBe(childComp.id, 'account attribute'); - expect(el.attributes['bank']).toBe(childComp.bank, 'bank attribute'); + expect(el.attributes.account).toBe(childComp.id, 'account attribute'); + expect(el.attributes.bank).toBe(childComp.bank, 'bank attribute'); - expect(el.classes['closed']).toBe(true, 'closed class'); - expect(el.classes['open']).toBe(false, 'open class'); + expect(el.classes.closed).toBe(true, 'closed class'); + expect(el.classes.open).toBeFalsy('open class'); - expect(el.styles['color']).toBe(comp.color, 'color style'); - expect(el.styles['width']).toBe(comp.width + 'px', 'width style'); + expect(el.styles.color).toBe(comp.color, 'color style'); + expect(el.styles.width).toBe(comp.width + 'px', 'width style'); // #enddocregion dom-attributes // Removed on 12/02/2016 when ceased public discussion of the `Renderer`. Revive in future? diff --git a/aio/content/examples/testing/src/app/welcome/welcome.component.spec.ts b/aio/content/examples/testing/src/app/welcome/welcome.component.spec.ts index a85ca4be99..67ff86b1d3 100644 --- a/aio/content/examples/testing/src/app/welcome/welcome.component.spec.ts +++ b/aio/content/examples/testing/src/app/welcome/welcome.component.spec.ts @@ -58,7 +58,7 @@ describe('WelcomeComponent', () => { let el: HTMLElement; // the DOM element with the welcome message // #docregion setup, user-service-stub - let userServiceStub: Partial; + let userServiceStub: Partial; // #enddocregion user-service-stub beforeEach(() => { @@ -66,7 +66,7 @@ describe('WelcomeComponent', () => { // #docregion user-service-stub userServiceStub = { isLoggedIn: true, - user: { name: 'Test User'} + user: { name: 'Test User' }, }; // #enddocregion user-service-stub @@ -74,10 +74,10 @@ describe('WelcomeComponent', () => { TestBed.configureTestingModule({ declarations: [ WelcomeComponent ], // #enddocregion setup - // providers: [ UserService ] // NO! Don't provide the real service! - // Provide a test-double instead + // providers: [ UserService ], // NO! Don't provide the real service! + // Provide a test-double instead // #docregion setup - providers: [ {provide: UserService, useValue: userServiceStub } ] + providers: [ { provide: UserService, useValue: userServiceStub } ], }); // #enddocregion config-test-module @@ -85,7 +85,7 @@ describe('WelcomeComponent', () => { comp = fixture.componentInstance; // #enddocregion setup - // #docregion injected-service + // #docregion injected-service // UserService actually injected into the component userService = fixture.debugElement.injector.get(UserService); // #enddocregion injected-service @@ -132,14 +132,4 @@ describe('WelcomeComponent', () => { it('TestBed and Component UserService should be the same', () => { expect(userService === componentUserService).toBe(true); }); - - // #docregion stub-not-injected - it('stub object and injected UserService should not be the same', () => { - expect(userServiceStub === userService).toBe(false); - - // Changing the stub object has no effect on the injected service - userServiceStub.isLoggedIn = false; - expect(userService.isLoggedIn).toBe(true); - }); - // #enddocregion stub-not-injected }); diff --git a/aio/content/examples/testing/src/app/welcome/welcome.component.ts b/aio/content/examples/testing/src/app/welcome/welcome.component.ts index 802f30cc4a..5eff2cd9fb 100644 --- a/aio/content/examples/testing/src/app/welcome/welcome.component.ts +++ b/aio/content/examples/testing/src/app/welcome/welcome.component.ts @@ -1,6 +1,6 @@ // #docregion import { Component, OnInit } from '@angular/core'; -import { UserService } from '../model/user.service'; +import { UserService } from '../model/user.service'; // #docregion component @Component({ @@ -8,7 +8,7 @@ import { UserService } from '../model/user.service'; template: '

{{welcome}}

' }) // #docregion class -export class WelcomeComponent implements OnInit { +export class WelcomeComponent implements OnInit { welcome: string; constructor(private userService: UserService) { } diff --git a/aio/content/examples/testing/src/tests.sb.ts b/aio/content/examples/testing/src/tests.sb.ts index 2cb3b440f6..8c3e9ae454 100644 --- a/aio/content/examples/testing/src/tests.sb.ts +++ b/aio/content/examples/testing/src/tests.sb.ts @@ -18,6 +18,7 @@ import './app/hero/hero-detail.component.spec.ts'; import './app/hero/hero-list.component.spec.ts'; import './app/model/hero.service.spec.ts'; import './app/model/testing/http-client.spec.ts'; +import './app/shared/canvas.component.spec.ts'; import './app/shared/highlight.directive.spec.ts'; import './app/shared/title-case.pipe.spec.ts'; import './app/twain/twain.component.spec.ts'; diff --git a/aio/content/examples/toh-pt0/src/app/app.component.spec.ts b/aio/content/examples/toh-pt0/src/app/app.component.spec.ts deleted file mode 100644 index 8ea1e2a3e1..0000000000 --- a/aio/content/examples/toh-pt0/src/app/app.component.spec.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { TestBed, async } from '@angular/core/testing'; - -import { AppComponent } from './app.component'; - -describe('AppComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ - AppComponent - ], - }).compileComponents(); - })); - - it('should create the app', async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app).toBeTruthy(); - })); - - it(`should have as title 'app'`, async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app.title).toEqual('app'); - })); - - it('should render title', async(() => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!'); - })); -}); diff --git a/aio/content/examples/toh-pt1/src/app/heroes/heroes.component.spec.ts b/aio/content/examples/toh-pt1/src/app/heroes/heroes.component.spec.ts deleted file mode 100644 index 9c3b1c4d9f..0000000000 --- a/aio/content/examples/toh-pt1/src/app/heroes/heroes.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { HeroesComponent } from './heroes.component'; - -describe('HeroesComponent', () => { - let component: HeroesComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ HeroesComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(HeroesComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should be created', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/toh-pt2/src/app/heroes/heroes.component.spec.ts b/aio/content/examples/toh-pt2/src/app/heroes/heroes.component.spec.ts deleted file mode 100644 index 9c3b1c4d9f..0000000000 --- a/aio/content/examples/toh-pt2/src/app/heroes/heroes.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { HeroesComponent } from './heroes.component'; - -describe('HeroesComponent', () => { - let component: HeroesComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ HeroesComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(HeroesComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should be created', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/toh-pt3/src/app/heroes/heroes.component.spec.ts b/aio/content/examples/toh-pt3/src/app/heroes/heroes.component.spec.ts deleted file mode 100644 index 9c3b1c4d9f..0000000000 --- a/aio/content/examples/toh-pt3/src/app/heroes/heroes.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { HeroesComponent } from './heroes.component'; - -describe('HeroesComponent', () => { - let component: HeroesComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ HeroesComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(HeroesComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should be created', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/toh-pt4/src/app/heroes/heroes.component.spec.ts b/aio/content/examples/toh-pt4/src/app/heroes/heroes.component.spec.ts deleted file mode 100644 index 9c3b1c4d9f..0000000000 --- a/aio/content/examples/toh-pt4/src/app/heroes/heroes.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { HeroesComponent } from './heroes.component'; - -describe('HeroesComponent', () => { - let component: HeroesComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ HeroesComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(HeroesComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should be created', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/toh-pt4/src/app/message.service.spec.ts b/aio/content/examples/toh-pt4/src/app/message.service.spec.ts deleted file mode 100644 index 63ecfd8ff6..0000000000 --- a/aio/content/examples/toh-pt4/src/app/message.service.spec.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { TestBed, inject } from '@angular/core/testing'; - -import { MessageService } from './message.service'; - -describe('MessageService', () => { - beforeEach(() => { - TestBed.configureTestingModule({ - providers: [MessageService] - }); - }); - - it('should be created', inject([MessageService], (service: MessageService) => { - expect(service).toBeTruthy(); - })); -}); diff --git a/aio/content/examples/toh-pt4/src/app/messages/messages.component.spec.ts b/aio/content/examples/toh-pt4/src/app/messages/messages.component.spec.ts deleted file mode 100644 index 3c2b2b1537..0000000000 --- a/aio/content/examples/toh-pt4/src/app/messages/messages.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { MessagesComponent } from './messages.component'; - -describe('MessagesComponent', () => { - let component: MessagesComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ MessagesComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(MessagesComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should be created', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/toh-pt5/src/app/dashboard/dashboard.component.spec.ts b/aio/content/examples/toh-pt5/src/app/dashboard/dashboard.component.spec.ts deleted file mode 100644 index fea6bfb4db..0000000000 --- a/aio/content/examples/toh-pt5/src/app/dashboard/dashboard.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { DashboardComponent } from './dashboard.component'; - -describe('DashboardComponent', () => { - let component: DashboardComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ DashboardComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(DashboardComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should be created', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/toh-pt5/src/app/heroes/heroes.component.spec.ts b/aio/content/examples/toh-pt5/src/app/heroes/heroes.component.spec.ts deleted file mode 100644 index 9c3b1c4d9f..0000000000 --- a/aio/content/examples/toh-pt5/src/app/heroes/heroes.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { HeroesComponent } from './heroes.component'; - -describe('HeroesComponent', () => { - let component: HeroesComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ HeroesComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(HeroesComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should be created', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/toh-pt5/src/app/message.service.spec.ts b/aio/content/examples/toh-pt5/src/app/message.service.spec.ts deleted file mode 100644 index 63ecfd8ff6..0000000000 --- a/aio/content/examples/toh-pt5/src/app/message.service.spec.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { TestBed, inject } from '@angular/core/testing'; - -import { MessageService } from './message.service'; - -describe('MessageService', () => { - beforeEach(() => { - TestBed.configureTestingModule({ - providers: [MessageService] - }); - }); - - it('should be created', inject([MessageService], (service: MessageService) => { - expect(service).toBeTruthy(); - })); -}); diff --git a/aio/content/examples/toh-pt5/src/app/messages/messages.component.spec.ts b/aio/content/examples/toh-pt5/src/app/messages/messages.component.spec.ts deleted file mode 100644 index 3c2b2b1537..0000000000 --- a/aio/content/examples/toh-pt5/src/app/messages/messages.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { MessagesComponent } from './messages.component'; - -describe('MessagesComponent', () => { - let component: MessagesComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ MessagesComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(MessagesComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should be created', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/toh-pt6/example-config.json b/aio/content/examples/toh-pt6/example-config.json index e69de29bb2..a3fb39d2be 100644 --- a/aio/content/examples/toh-pt6/example-config.json +++ b/aio/content/examples/toh-pt6/example-config.json @@ -0,0 +1,6 @@ +{ + "e2e": [ + {"cmd": "yarn", "args": ["test", "--browsers=ChromeHeadless", "--no-watch"]}, + {"cmd": "yarn", "args": ["e2e", "--prod", "--protractor-config=e2e/protractor-puppeteer.conf.js", "--no-webdriver-update", "--port={PORT}"]} + ] +} diff --git a/aio/content/examples/toh-pt6/src/app/hero-search/hero-search.component.spec.ts b/aio/content/examples/toh-pt6/src/app/hero-search/hero-search.component.spec.ts deleted file mode 100644 index 8414f1c223..0000000000 --- a/aio/content/examples/toh-pt6/src/app/hero-search/hero-search.component.spec.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { RouterTestingModule } from '@angular/router/testing'; -import { HttpClientTestingModule } from '@angular/common/http/testing'; - -import { HeroSearchComponent } from './hero-search.component'; - - -describe('HeroSearchComponent', () => { - let component: HeroSearchComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ HeroSearchComponent ], - imports: [RouterTestingModule.withRoutes([]), HttpClientTestingModule] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(HeroSearchComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/toh-pt6/src/app/heroes/heroes.component.spec.ts b/aio/content/examples/toh-pt6/src/app/heroes/heroes.component.spec.ts deleted file mode 100644 index 6991d69010..0000000000 --- a/aio/content/examples/toh-pt6/src/app/heroes/heroes.component.spec.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { RouterTestingModule } from '@angular/router/testing'; -import { HeroesComponent } from './heroes.component'; -import { HttpClientTestingModule } from '@angular/common/http/testing'; - -describe('HeroesComponent', () => { - let component: HeroesComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ HeroesComponent ], - imports: [RouterTestingModule.withRoutes([]), HttpClientTestingModule], - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(HeroesComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should be created', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/toh-pt6/src/app/message.service.spec.ts b/aio/content/examples/toh-pt6/src/app/message.service.spec.ts deleted file mode 100644 index 63ecfd8ff6..0000000000 --- a/aio/content/examples/toh-pt6/src/app/message.service.spec.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { TestBed, inject } from '@angular/core/testing'; - -import { MessageService } from './message.service'; - -describe('MessageService', () => { - beforeEach(() => { - TestBed.configureTestingModule({ - providers: [MessageService] - }); - }); - - it('should be created', inject([MessageService], (service: MessageService) => { - expect(service).toBeTruthy(); - })); -}); diff --git a/aio/content/examples/toh-pt6/src/app/messages/messages.component.spec.ts b/aio/content/examples/toh-pt6/src/app/messages/messages.component.spec.ts deleted file mode 100644 index 3c2b2b1537..0000000000 --- a/aio/content/examples/toh-pt6/src/app/messages/messages.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { MessagesComponent } from './messages.component'; - -describe('MessagesComponent', () => { - let component: MessagesComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ MessagesComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(MessagesComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should be created', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/two-way-binding/src/app/app.component.spec.ts b/aio/content/examples/two-way-binding/src/app/app.component.spec.ts deleted file mode 100644 index 1f327e6574..0000000000 --- a/aio/content/examples/two-way-binding/src/app/app.component.spec.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { TestBed, async } from '@angular/core/testing'; -import { AppComponent } from './app.component'; -describe('AppComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ - AppComponent - ], - }).compileComponents(); - })); - it('should create the app', async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app).toBeTruthy(); - })); - it(`should have as title 'app'`, async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app.title).toEqual('app'); - })); - it('should render title', async(() => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!'); - })); -}); diff --git a/aio/content/examples/two-way-binding/src/app/sizer/sizer.component.spec.ts b/aio/content/examples/two-way-binding/src/app/sizer/sizer.component.spec.ts deleted file mode 100644 index 3c3a3ada05..0000000000 --- a/aio/content/examples/two-way-binding/src/app/sizer/sizer.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { SizerComponent } from './sizer.component'; - -describe('SizerComponent', () => { - let component: SizerComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ SizerComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(SizerComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/universal/src/app/dashboard/dashboard.component.spec.ts b/aio/content/examples/universal/src/app/dashboard/dashboard.component.spec.ts deleted file mode 100644 index fea6bfb4db..0000000000 --- a/aio/content/examples/universal/src/app/dashboard/dashboard.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { DashboardComponent } from './dashboard.component'; - -describe('DashboardComponent', () => { - let component: DashboardComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ DashboardComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(DashboardComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should be created', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/universal/src/app/hero-search/hero-search.component.spec.ts b/aio/content/examples/universal/src/app/hero-search/hero-search.component.spec.ts deleted file mode 100644 index 901bb7f2ab..0000000000 --- a/aio/content/examples/universal/src/app/hero-search/hero-search.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { HeroSearchComponent } from './hero-search.component'; - -describe('HeroSearchComponent', () => { - let component: HeroSearchComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ HeroSearchComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(HeroSearchComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/universal/src/app/heroes/heroes.component.spec.ts b/aio/content/examples/universal/src/app/heroes/heroes.component.spec.ts deleted file mode 100644 index 9c3b1c4d9f..0000000000 --- a/aio/content/examples/universal/src/app/heroes/heroes.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { HeroesComponent } from './heroes.component'; - -describe('HeroesComponent', () => { - let component: HeroesComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ HeroesComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(HeroesComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should be created', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/universal/src/app/message.service.spec.ts b/aio/content/examples/universal/src/app/message.service.spec.ts deleted file mode 100644 index 63ecfd8ff6..0000000000 --- a/aio/content/examples/universal/src/app/message.service.spec.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { TestBed, inject } from '@angular/core/testing'; - -import { MessageService } from './message.service'; - -describe('MessageService', () => { - beforeEach(() => { - TestBed.configureTestingModule({ - providers: [MessageService] - }); - }); - - it('should be created', inject([MessageService], (service: MessageService) => { - expect(service).toBeTruthy(); - })); -}); diff --git a/aio/content/examples/universal/src/app/messages/messages.component.spec.ts b/aio/content/examples/universal/src/app/messages/messages.component.spec.ts deleted file mode 100644 index 3c2b2b1537..0000000000 --- a/aio/content/examples/universal/src/app/messages/messages.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { MessagesComponent } from './messages.component'; - -describe('MessagesComponent', () => { - let component: MessagesComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ MessagesComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(MessagesComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should be created', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/aio/content/examples/upgrade-phonecat-3-final/README.md b/aio/content/examples/upgrade-phonecat-3-final/README.md index 7448da44e6..83d1f4a7c4 100644 --- a/aio/content/examples/upgrade-phonecat-3-final/README.md +++ b/aio/content/examples/upgrade-phonecat-3-final/README.md @@ -3,9 +3,6 @@ structure. The following changes from vanilla Phonecat are applied: -* Karma config for unit tests is in karma.conf.ng1.js because the boilerplate - Karma config is not compatible with the way tests in this project need to be run. - The shell script run-unit-tests.sh can be used to run the unit tests. * E2E tests have been moved to the parent directory, where `run-e2e-tests` can discover and run them along with all the other examples. * Most of the phone JSON and image data removed in the interest of keeping diff --git a/aio/content/examples/upgrade-phonecat-3-final/run-unit-tests.sh b/aio/content/examples/upgrade-phonecat-3-final/run-unit-tests.sh deleted file mode 100644 index d90e45c2e9..0000000000 --- a/aio/content/examples/upgrade-phonecat-3-final/run-unit-tests.sh +++ /dev/null @@ -1,6 +0,0 @@ -## The boilerplate Karma configuration won't work with AngularJS tests -## which require their own special loading configuration, `karma.conf.ng1.js`. -## This scripts runs the AngularJS tests with that AngularJS config. - -PATH=$(npm bin):$PATH -tsc && karma start karma.conf.ng1.js diff --git a/aio/content/guide/testing.md b/aio/content/guide/testing.md index 6d5a2ef7eb..9052d2513b 100644 --- a/aio/content/guide/testing.md +++ b/aio/content/guide/testing.md @@ -1103,18 +1103,6 @@ explains when and why you must get the service from the component's injector ins -{@a service-from-injector} - -#### Always get the service from an injector - -Do _not_ reference the `userServiceStub` object -that's provided to the testing module in the body of your test. -**It does not work!** -The `userService` instance injected into the component is a completely _different_ object, -a clone of the provided `userServiceStub`. - - - {@a welcome-spec-setup} #### Final setup and tests diff --git a/aio/tools/examples/run-example-e2e.js b/aio/tools/examples/run-example-e2e.js index 2213a5c454..0c202226d5 100644 --- a/aio/tools/examples/run-example-e2e.js +++ b/aio/tools/examples/run-example-e2e.js @@ -9,6 +9,9 @@ const findFreePort = require('find-free-port'); shelljs.set('-e'); +// Set `CHROME_BIN` as an environment variable for Karma to pick up in unit tests. +process.env.CHROME_BIN = require('puppeteer').executablePath(); + const AIO_PATH = path.join(__dirname, '../../'); const SHARED_PATH = path.join(__dirname, '/shared'); const EXAMPLES_PATH = path.join(AIO_PATH, './content/examples/');