Created
September 9, 2017 00:20
-
-
Save kylewhitaker/86dda45793230e33a2abfb8d7d05e236 to your computer and use it in GitHub Desktop.
Unit testing an Observable with Jasmine's done() function
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 { SomeComponent } from './some.component'; | |
describe('SomeComponent:', () => { | |
let component: SomeComponent; | |
beforeEach(() => { | |
component = new SomeComponent(); | |
}); | |
describe('returnSomeObservable', () => { | |
it('should return an observable that emits a \'test\' string value', (done) => { | |
component.returnSomeObservable().subscribe((value) => { | |
expect(value).toEqual('test'); | |
done(); | |
}); | |
}); | |
}); | |
}); |
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 { Observable } from 'rxjs'; | |
export class SomeComponent { | |
returnSomeObservable(): Observable<string> { | |
return Observable.of('test'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment