-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(examples): yarn workspace angular v12 example app (the tour of h…
…eroes) (#1185)
- Loading branch information
Showing
80 changed files
with
4,317 additions
and
572 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...les/example-app-yarn-workspace/packages/angular-app/src/app/about/about.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { HighlightDirective } from '../shared/highlight.directive'; | ||
|
||
import { AboutComponent } from './about.component'; | ||
|
||
let fixture: ComponentFixture<AboutComponent>; | ||
|
||
describe('AboutComponent (highlightDirective)', () => { | ||
beforeEach(() => { | ||
fixture = TestBed.configureTestingModule({ | ||
declarations: [AboutComponent, HighlightDirective], | ||
schemas: [CUSTOM_ELEMENTS_SCHEMA], | ||
}).createComponent(AboutComponent); | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should have skyblue <h2>', () => { | ||
const h2: HTMLElement = fixture.nativeElement.querySelector('h2'); | ||
const bgColor = h2.style.backgroundColor; | ||
expect(bgColor).toBe('skyblue'); | ||
}); | ||
}); |
9 changes: 9 additions & 0 deletions
9
examples/example-app-yarn-workspace/packages/angular-app/src/app/about/about.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Component } from '@angular/core'; | ||
@Component({ | ||
template: ` | ||
<h2 highlight="skyblue">About</h2> | ||
<h3>Quote of the day:</h3> | ||
<twain-quote></twain-quote> | ||
`, | ||
}) | ||
export class AboutComponent {} |
69 changes: 69 additions & 0 deletions
69
...les/example-app-yarn-workspace/packages/angular-app/src/app/app-initial.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { DebugElement } from '@angular/core'; | ||
import { TestBed, waitForAsync } from '@angular/core/testing'; | ||
import { ComponentFixture } from '@angular/core/testing'; | ||
|
||
import { AppComponent } from './app-initial.component'; | ||
|
||
describe('AppComponent (initial CLI version)', () => { | ||
beforeEach( | ||
waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [AppComponent], | ||
}).compileComponents(); | ||
}), | ||
); | ||
it( | ||
'should create the app', | ||
waitForAsync(() => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
const app = fixture.componentInstance; | ||
expect(app).toBeTruthy(); | ||
}), | ||
); | ||
it( | ||
`should have as title 'app'`, | ||
waitForAsync(() => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
const app = fixture.componentInstance; | ||
expect(app.title).toEqual('app'); | ||
}), | ||
); | ||
it( | ||
'should render title', | ||
waitForAsync(() => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
fixture.detectChanges(); | ||
const compiled = fixture.nativeElement as HTMLElement; | ||
expect(compiled.querySelector('h1')?.textContent).toContain('Welcome to app!'); | ||
}), | ||
); | ||
}); | ||
|
||
describe('AppComponent (initial CLI version - as it should be)', () => { | ||
let app: AppComponent; | ||
let de: DebugElement; | ||
let fixture: ComponentFixture<AppComponent>; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [AppComponent], | ||
}); | ||
|
||
fixture = TestBed.createComponent(AppComponent); | ||
app = fixture.componentInstance; | ||
de = fixture.debugElement; | ||
}); | ||
|
||
it('should create the app', () => { | ||
expect(app).toBeDefined(); | ||
}); | ||
|
||
it(`should have as title 'app'`, () => { | ||
expect(app.title).toEqual('app'); | ||
}); | ||
|
||
it('should render title in an h1 tag', () => { | ||
fixture.detectChanges(); | ||
expect(de.nativeElement.querySelector('h1').textContent).toContain('Welcome to app!'); | ||
}); | ||
}); |
9 changes: 9 additions & 0 deletions
9
examples/example-app-yarn-workspace/packages/angular-app/src/app/app-initial.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-root', | ||
template: '<h1>Welcome to {{title}}!</h1>', | ||
}) | ||
export class AppComponent { | ||
title = 'app'; | ||
} |
8 changes: 7 additions & 1 deletion
8
examples/example-app-yarn-workspace/packages/angular-app/src/app/app-routing.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file removed
0
examples/example-app-yarn-workspace/packages/angular-app/src/app/app.component.css
Empty file.
Oops, something went wrong.