Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fix unit tests in toh-pt6 #24491

Closed
wants to merge 1 commit into from
Closed

docs: fix unit tests in toh-pt6 #24491

wants to merge 1 commit into from

Conversation

nicodh
Copy link
Contributor

@nicodh nicodh commented Jun 13, 2018

Added some tests to dashboard.component.spec

Resolves #20373

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] angular.io application / infrastructure changes
[x] Other... Please describe: fix broken unit tests

What is the current behavior?

executing ng test resulted in an error
Issue Number: 20373

What is the new behavior?

Tests are running

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

@brandonroberts brandonroberts self-assigned this Jun 18, 2018
@@ -1,16 +1,36 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { DashboardComponent } from './dashboard.component';
import { HeroSearchComponent } from '../hero-search/hero-search.component';

import { RouterModule } from '@angular/router';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use RouterTestingModule from @angular/router/testing instead.

HeroSearchComponent
],
imports: [
RouterModule.forRoot([])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be RouterTestingModule.withRoutes([]). Then you don't need to provide the APP_BASE_HREF in the tests

declarations: [ HeroSearchComponent ]
declarations: [ HeroSearchComponent ],
imports: [RouterModule.forRoot([]), HttpClientModule],
providers: [{ provide: APP_BASE_HREF, useValue: '/' }]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use HttpClientTestingModule and RouterTestingModule


describe('HeroesComponent', () => {
let component: HeroesComponent;
let fixture: ComponentFixture<HeroesComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ HeroesComponent ]
declarations: [ HeroesComponent ],
imports: [RouterModule.forRoot([]), HttpClientModule],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above. Use RouterTestingModule and remove APP_BASE_HREF


describe('DashboardComponent', () => {
let component: DashboardComponent;
let fixture: ComponentFixture<DashboardComponent>;
const heroService = jasmine.createSpyObj('HeroService', ['getHeroes']);
const getHeroesSpy = heroService.getHeroes.and.returnValue( of(HEROES) );

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spies should be set in the beforeEach, so they are reset for each test

@brandonroberts
Copy link
Contributor

Changes LGTM: Will you squash down to a single commit and change the commit message to docs: fix unit tests in toh-pt6?

Thanks

@brandonroberts brandonroberts added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews target: patch This PR is targeted for the next patch release comp: docs labels Jun 25, 2018
@brandonroberts brandonroberts changed the title fix(aio): fix unit tests in toh-pt6 docs: fix unit tests in toh-pt6 Jun 26, 2018
@brandonroberts brandonroberts added action: merge The PR is ready for merge by the caretaker and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Jun 26, 2018
jasonaden pushed a commit that referenced this pull request Jun 27, 2018
@jasonaden jasonaden closed this in 8dec381 Jun 27, 2018
@jenniferfell jenniferfell added the state: community Someone from the Angular community is working on this issue or submitted this PR label Oct 9, 2018
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes state: community Someone from the Angular community is working on this issue or submitted this PR target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Testing Documentation and Tutorial Enhancements
4 participants