|
1 | | -/** |
2 | | - * Copyright 2024, Optimizely |
3 | | - * |
4 | | - * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | | - * you may not use this file except in compliance with the License. |
6 | | - * You may obtain a copy of the License at |
7 | | - * |
8 | | - * https://www.apache.org/licenses/LICENSE-2.0 |
9 | | - * |
10 | | - * Unless required by applicable law or agreed to in writing, software |
11 | | - * distributed under the License is distributed on an "AS IS" BASIS, |
12 | | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | | - * See the License for the specific language governing permissions and |
14 | | - * limitations under the License. |
15 | | - */ |
16 | | - |
17 | 1 | import { assert } from 'chai'; |
18 | | -import { scheduleMicrotaskOrTimeout } from './'; |
19 | | - |
20 | | -describe('scheduleMicrotaskOrTimeout', () => { |
21 | | - let called; |
22 | | - |
23 | | - beforeEach(() => { |
24 | | - called = false; |
25 | | - }); |
| 2 | +import { scheduleMicrotaskOrTimeout } from '.'; |
26 | 3 |
|
| 4 | +describe.only('scheduleMicrotaskOrTimeout', () => { |
27 | 5 | it('should use queueMicrotask if available', (done) => { |
| 6 | + // Assuming queueMicrotask is available in the environment |
28 | 7 | scheduleMicrotaskOrTimeout(() => { |
29 | | - called = true; |
30 | | - assert.isTrue(called, 'queueMicrotask was called'); |
31 | 8 | done(); |
32 | 9 | }); |
33 | 10 | }); |
34 | 11 |
|
35 | 12 | it('should fallback to setTimeout if queueMicrotask is not available', (done) => { |
| 13 | + // Temporarily remove queueMicrotask to test the fallback |
36 | 14 | const originalQueueMicrotask = window.queueMicrotask; |
37 | 15 | window.queueMicrotask = undefined; |
38 | 16 |
|
39 | 17 | scheduleMicrotaskOrTimeout(() => { |
40 | | - assert.isTrue(true, 'setTimeout was called'); |
| 18 | + // Restore queueMicrotask before calling done |
41 | 19 | window.queueMicrotask = originalQueueMicrotask; |
42 | 20 | done(); |
43 | 21 | }); |
|
0 commit comments