describe('the pizza service', () => {
it('should have getPizze', () => {
let pizzaService = new PizzaService();
expect(service.getPizze).toBeDefined();
});
describe('getPizze should return salami pizza', () => {
it('should return some pizza', () => {
let pizzaService = new PizzaService();
let salami = new Pizza('Salami');
let pizze: Pizza[] = service.getPizze();
expect(pizze).toContain(salami);
});
});
});
describe('MyComp', () => {
let component: MyComp;
let fixture: ComponentFixture<MyComp>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [MyComp]
});
fixture = TestBed.createComponent(MyComp);
component = fixture.componentInstance;
});
it('should work', () => {
let de: DebugElement = fixture.debugElement.query(
By.css('h3'));
let el: HTMLElement = de.nativeElement;
component.title = 'my title';
fixture.detectChanges();
expect(el.textContent).toEqual('my title');
});
});
describe('Header Component with a host component', () => {
@Component({
template: `<comp [prop]="'dummy value'"></comp>`
})
class HostComponent {
}
let fixture: ComponentFixture<HostComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [HostComponent, MyComponent],
});
fixture = TestBed.createComponent(HostComponent);
});
// ....
// eigentlicher Test Code
});
import {KebabPipe} from "./kebab.pipe";
describe('KebabPipe', () => {
let pipe = new MyPipe();
it('should make camel to kebab"', () => {
expect(pipe.transform('aBcdE')).toBe('a-bcd-e');
});
});