Skip to content

Commit af1a437

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

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

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

+35-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ fdescribe('Async Testing Examples', () => {
4444
}));
4545

4646

47-
fit('Asynchronous test example - plain Promise', fakeAsync(() => {
47+
it('Asynchronous test example - plain Promise', fakeAsync(() => {
4848

4949
let test = false;
5050

@@ -73,6 +73,40 @@ fdescribe('Async Testing Examples', () => {
7373
}));
7474

7575

76+
it('Asynchronous test example - Promises + setTimeout()', fakeAsync(() => {
77+
78+
let counter = 0;
79+
80+
Promise.resolve()
81+
.then(() => {
82+
83+
counter+=10;
84+
85+
setTimeout(() => {
86+
87+
counter += 1;
88+
89+
}, 1000);
90+
91+
});
92+
93+
expect(counter).toBe(0);
94+
95+
flushMicrotasks();
96+
97+
expect(counter).toBe(10);
98+
99+
tick(500);
100+
101+
expect(counter).toBe(10);
102+
103+
tick(500);
104+
105+
expect(counter).toBe(11);
106+
107+
}));
108+
109+
76110
});
77111

78112

0 commit comments

Comments
 (0)