Skip to content

Commit ed074df

Browse files
author
Your Name
committed
Angular Testing Course
1 parent af1a437 commit ed074df

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/app/courses/home/async-examples.spec.ts

+25
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import {fakeAsync, flush, flushMicrotasks, tick} from '@angular/core/testing';
2+
import {of} from 'rxjs';
3+
import {delay} from 'rxjs/operators';
24

35

46
fdescribe('Async Testing Examples', () => {
@@ -106,6 +108,29 @@ fdescribe('Async Testing Examples', () => {
106108

107109
}));
108110

111+
it('Asynchronous test example - Observables', fakeAsync(() => {
112+
113+
let test = false;
114+
115+
console.log('Creating Observable');
116+
117+
const test$ = of(test).pipe(delay(1000));
118+
119+
test$.subscribe(() => {
120+
121+
test = true;
122+
123+
});
124+
125+
tick(1000);
126+
127+
console.log('Running test assertions');
128+
129+
expect(test).toBe(true);
130+
131+
132+
}));
133+
109134

110135
});
111136

0 commit comments

Comments
 (0)