Created
June 16, 2019 13:29
-
-
Save wescopeland/0472c5ac61ce47a64784954d9d494192 to your computer and use it in GitHub Desktop.
stateful.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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