Skip to content

Instantly share code, notes, and snippets.

@jnizet
Created April 6, 2019 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jnizet/81c9a6889c615c40fd46560cf2ba1bec to your computer and use it in GitHub Desktop.
Save jnizet/81c9a6889c615c40fd46560cf2ba1bec to your computer and use it in GitHub Desktop.
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Component, Input, OnInit } from '@angular/core';
@Component({
selector: 'foo',
template: 'hello {{ nameCopy }}'
})
class FooComponent implements OnInit {
@Input() name: string;
nameCopy: string;
ngOnInit() {
this.nameCopy = this.name.toUpperCase();
}
}
fdescribe('FooComponent', () => {
let component: FooComponent;
let fixture: ComponentFixture<FooComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [ FooComponent ]
});
fixture = TestBed.createComponent(FooComponent);
component = fixture.componentInstance;
component.name = 'test';
fixture.detectChanges();
});
it('should display hello TEST', () => {
expect(fixture.nativeElement.textContent).toContain('hello TEST');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment