Skip to content

Commit 0593b02

Browse files
INT-3396: mark test file as zonefull
1 parent 16cf963 commit 0593b02

2 files changed

Lines changed: 26 additions & 7 deletions

File tree

tinymce-angular-component/src/test/ts/alien/InitTestEnvironment.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
import 'core-js/features/reflect';
2+
3+
// zone.js is imported here because our test suite needs to cover both zoneless and
4+
// zone.js-based Angular applications. As a component library, our users may run
5+
// either mode, so we must ensure compatibility with both. Since Angular 21, zoneless
6+
// is the default, but zone.js remains supported. Once Angular drops zone.js support
7+
// entirely, this import, ng-zone specific tests and the zone.js devDependency can be removed.
8+
//
9+
// Note: importing zone.js patches native browser APIs (addEventListener, setTimeout,
10+
// setInterval, etc.), but Angular does not use these patches for change detection by
11+
// default. Change detection only relies on zone.js in tests that explicitly configure
12+
// `provideZoneChangeDetection`.
213
import 'zone.js';
314
import 'zone.js/plugins/fake-async-test';
415

tinymce-angular-component/src/test/ts/browser/NgZoneTest.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
import '../alien/InitTestEnvironment';
22

3-
import { NgZone } from '@angular/core';
3+
import { NgZone, provideZoneChangeDetection } from '@angular/core';
44
import { Assertions } from '@ephox/agar';
5-
import { describe, it } from '@ephox/bedrock-client';
5+
import { beforeEach, describe, it } from '@ephox/bedrock-client';
66

77
import { EditorComponent } from '../../../main/ts/editor/editor.component';
8-
import { eachVersionContext, fixtureHook } from '../alien/TestHooks';
8+
import { eachVersionContext } from '../alien/TestHooks';
99
import { first } from 'rxjs';
1010
import { throwTimeout } from '../alien/TestHelpers';
11+
import { TestBed } from '@angular/core/testing';
1112

12-
describe.skip('NgZoneTest', () => {
13+
describe('NgZoneTest', () => {
1314
eachVersionContext([ '4', '5', '6', '7', '8' ], () => {
14-
const createFixture = fixtureHook(EditorComponent, { imports: [ EditorComponent ] });
15+
beforeEach(async () => {
16+
await TestBed.configureTestingModule({
17+
imports: [ EditorComponent ],
18+
providers: [ provideZoneChangeDetection() ]
19+
}).compileComponents();
20+
});
1521

1622
it('Subscribers to events should run within NgZone', async () => {
17-
const fixture = createFixture();
23+
const fixture = TestBed.createComponent(EditorComponent);
1824
const editor = fixture.componentInstance;
1925
fixture.detectChanges();
26+
2027
await new Promise<void>((resolve) => {
2128
editor.onInit.pipe(first(), throwTimeout(10000, 'Timed out waiting for init event')).subscribe(() => {
2229
Assertions.assertEq('Subscribers to onInit should run within NgZone', true, NgZone.isInAngularZone());
@@ -27,9 +34,10 @@ describe.skip('NgZoneTest', () => {
2734

2835
// Lets just test one EventEmitter, if one works all should work
2936
it('Subscribers to onKeyUp should run within NgZone', async () => {
30-
const fixture = createFixture();
37+
const fixture = TestBed.createComponent(EditorComponent);
3138
const editor = fixture.componentInstance;
3239
fixture.detectChanges();
40+
3341
await new Promise<void>((resolve) => {
3442
editor.onKeyUp.pipe(first(), throwTimeout(10000, 'Timed out waiting for key up event')).subscribe(() => {
3543
Assertions.assertEq('Subscribers to onKeyUp should run within NgZone', true, NgZone.isInAngularZone());

0 commit comments

Comments
 (0)