Skip to content

Commit 4d09d4c

Browse files
[FSSDK-10201] dir rename, testcase addition
1 parent e3dae0c commit 4d09d4c

File tree

4 files changed

+47
-2
lines changed

4 files changed

+47
-2
lines changed

lib/core/odp/odp_event_manager.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { OdpConfig } from './odp_config';
2424
import { IOdpEventApiManager } from './odp_event_api_manager';
2525
import { invalidOdpDataFound } from './odp_utils';
2626
import { IUserAgentParser } from './user_agent_parser';
27-
import { scheduleMicrotaskOrTimeout } from '../../utils/microtasks';
27+
import { scheduleMicrotaskOrTimeout } from '../../utils/microtask';
2828

2929
const MAX_RETRIES = 3;
3030

lib/core/project_config/project_config_manager.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { ERROR_MESSAGES } from '../../utils/enums';
2020
import { createOptimizelyConfig } from '../optimizely_config';
2121
import { OnReadyResult, OptimizelyConfig, DatafileManager } from '../../shared_types';
2222
import { ProjectConfig, toDatafile, tryCreatingProjectConfig } from '../project_config';
23-
import { scheduleMicrotaskOrTimeout } from '../../utils/microtasks';
23+
import { scheduleMicrotaskOrTimeout } from '../../utils/microtask';
2424

2525
const logger = getLogger();
2626
const MODULE_NAME = 'PROJECT_CONFIG_MANAGER';

lib/utils/microtask/index.tests.js

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
import { assert } from 'chai';
18+
import { scheduleMicrotaskOrTimeout } from './';
19+
20+
describe('scheduleMicrotaskOrTimeout', () => {
21+
let called;
22+
23+
beforeEach(() => {
24+
called = false;
25+
});
26+
27+
it('should use queueMicrotask if available', (done) => {
28+
scheduleMicrotaskOrTimeout(() => {
29+
called = true;
30+
assert.isTrue(called, 'queueMicrotask was called');
31+
done();
32+
});
33+
});
34+
35+
it('should fallback to setTimeout if queueMicrotask is not available', (done) => {
36+
const originalQueueMicrotask = window.queueMicrotask;
37+
window.queueMicrotask = undefined;
38+
39+
scheduleMicrotaskOrTimeout(() => {
40+
assert.isTrue(true, 'setTimeout was called');
41+
window.queueMicrotask = originalQueueMicrotask;
42+
done();
43+
});
44+
});
45+
});
File renamed without changes.

0 commit comments

Comments
 (0)