NetanelBasal
4/2/2018 - 7:26 PM

test-obs-todos2.component.ts

import { cold, getTestScheduler } from 'jasmine-marbles';

const todosServiceStub = {
  get() {
    const todos$ = cold('--x|', { x: [{id: 1}] });
    return todos$
  }
};

describe('TodosComponent', () => {

  it('should work', () => {
    const todos = element.querySelectorAll('.todo');
    const loading = element.querySelector('.loading');
    expect(loading).not.toBeNull();
    getTestScheduler().flush(); // flush the observables
    fixture.detectChanges();
    expect(element.querySelectorAll('.todo').length).toEqual(1);
    expect(element.querySelectorAll('.loading').length).toEqual(0);
  });

});