Skip to content

Commit 39c8f72

Browse files
[FSSDK-10201] test improvement, redundant code removal
1 parent 4d09d4c commit 39c8f72

File tree

1 file changed

+5
-27
lines changed

1 file changed

+5
-27
lines changed

lib/utils/microtask/index.tests.js

+5-27
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,21 @@
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-
171
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 '.';
263

4+
describe.only('scheduleMicrotaskOrTimeout', () => {
275
it('should use queueMicrotask if available', (done) => {
6+
// Assuming queueMicrotask is available in the environment
287
scheduleMicrotaskOrTimeout(() => {
29-
called = true;
30-
assert.isTrue(called, 'queueMicrotask was called');
318
done();
329
});
3310
});
3411

3512
it('should fallback to setTimeout if queueMicrotask is not available', (done) => {
13+
// Temporarily remove queueMicrotask to test the fallback
3614
const originalQueueMicrotask = window.queueMicrotask;
3715
window.queueMicrotask = undefined;
3816

3917
scheduleMicrotaskOrTimeout(() => {
40-
assert.isTrue(true, 'setTimeout was called');
18+
// Restore queueMicrotask before calling done
4119
window.queueMicrotask = originalQueueMicrotask;
4220
done();
4321
});

0 commit comments

Comments
 (0)