Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- **Component:**
- ngOnInit(){
- this.globalFunctions.resulTest.subscribe(
- (value) => {
- this.test = value;
- });
- }
- **Service:**
- public resulTest = new Subject<any>();
- sendResult(result) {
- this.resulTest.next(result);
- }
- **specFile:**
- it('should test if the subsriber is active', () => {
- spyOn(globalFunctions, 'sendResult');
- spyOn(globalFunctions.resulTest, 'next');
- globalFunctions.sendResult('Test');
- expect(globalFunctions.sendResult).toHaveBeenCalled();
- expect(globalFunctions.resulTest.next).toHaveBeenCalled();
- expect(component.test).toEqual('test');
- });
Add Comment
Please, Sign In to add comment