2020-09-19 05:10:32 +00:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright Google LLC All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
2024-09-20 15:23:15 +00:00
|
|
|
* found in the LICENSE file at https://angular.dev/license
|
2020-09-19 05:10:32 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import {ifEnvSupports} from '../test-util';
|
|
|
|
|
|
|
|
|
|
describe(
|
|
|
|
|
'queueMicrotask',
|
|
|
|
|
ifEnvSupports('queueMicrotask', function () {
|
|
|
|
|
it('callback in the queueMicrotask should be scheduled as microTask in the zone', (done: DoneFn) => {
|
|
|
|
|
const logs: string[] = [];
|
|
|
|
|
Zone.current
|
|
|
|
|
.fork({
|
|
|
|
|
name: 'queueMicrotask',
|
|
|
|
|
onScheduleTask: (delegate: ZoneDelegate, curr: Zone, target: Zone, task: Task) => {
|
|
|
|
|
logs.push(task.type);
|
|
|
|
|
logs.push(task.source);
|
|
|
|
|
return delegate.scheduleTask(target, task);
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
.run(() => {
|
|
|
|
|
queueMicrotask(() => {
|
|
|
|
|
expect(logs).toEqual(['microTask', 'queueMicrotask']);
|
|
|
|
|
expect(Zone.current.name).toEqual('queueMicrotask');
|
|
|
|
|
done();
|
2024-04-19 16:53:49 +00:00
|
|
|
});
|
2020-09-19 05:10:32 +00:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
);
|