Skip to content

Instantly share code, notes, and snippets.

@wescopeland
Created June 16, 2019 13:29
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 wescopeland/0472c5ac61ce47a64784954d9d494192 to your computer and use it in GitHub Desktop.
Save wescopeland/0472c5ac61ce47a64784954d9d494192 to your computer and use it in GitHub Desktop.
stateful.component.spec.ts
import { Spectator, SpyObject, createTestComponentFactory } from '@netbasal/spectator/jest';
import { of } from 'rxjs';
import { StatefulComponent } from './stateful.component';
import { AwesomeEntitiesQuery } from './+state';
describe('Component: StatefulComponent', () => {
let query: SpyObject<AwesomeEntitiesQuery>;
let spectator: Spectator<StatefulComponent>;
const createComponent = createTestComponentFactory<StatefulComponent>({
component: StatefulComponent,
mocks: [AwesomeEntitiesQuery],
shallow: true
});
beforeEach(() => {
spectator = createComponent();
query = spectator.get<AwesomeEntitiesQuery>(AwesomeEntitiesQuery);
});
it('exists', () => {
expect(spectator.component).toBeDefined();
});
it('gets all the awesome entities on initialization', done => {
query.selectAll.andReturn(of([]));
spectator.component.ngOnInit();
spectator.component.awesomeEntities$.subscribe(val => {
expect(val).toEqual([]);
done();
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment