NetanelBasal
4/2/2018 - 7:03 PM

test-obs-todos1.component.ts

const todosServiceStub = {
  get() {
    const todos = [{id: 1}];
    return of( todos );
  }
};

describe('TodosComponent', () => {
  
  beforeEach(() => {
    TestBed.configureTestingModule({
      declarations: [ TodosComponent ],
      providers: [{provide: TodosService, useValue: todosServiceStub}]
    })
  });

  it('should...', () => {
    fixture.detectChanges();
    expect(element.querySelectorAll('.todo').length).toEqual(1);
  });
});