Skip to content

Commit b2fa0ae

Browse files
committed
Add an after hook to delete tinymce
1 parent e603d76 commit b2fa0ae

4 files changed

Lines changed: 18 additions & 15 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import 'core-js/features/reflect';
22

33
import { TestBed } from '@angular/core/testing';
44
import { BrowserTestingModule, platformBrowserTesting } from '@angular/platform-browser/testing';
5-
import { NgModule, provideZonelessChangeDetection } from '@angular/core';
5+
import { NgModule } from '@angular/core';
66

77
@NgModule({
8-
providers: [ provideZonelessChangeDetection() ],
8+
providers: [],
99
})
1010
class AppTestingModule {}
1111

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ export const tinymceVersionHook = (version: Version) => {
2323
before(async () => {
2424
await VersionLoader.pLoadVersion(version);
2525
});
26-
after(() => {
27-
deleteTinymce();
28-
});
26+
27+
after(deleteTinymce);
2928
};
3029

3130
export interface EditorFixture<T> extends ComponentFixture<T> {
@@ -72,7 +71,7 @@ export const editorHook = <T = unknown>(component: Type<T>, moduleDef: TestModul
7271
return firstValueFrom(
7372

7473
editorComponent.onInit.pipe(
75-
throwTimeout(15000, `Timed out waiting for editor to load`),
74+
throwTimeout(10000, `Timed out waiting for editor to load`),
7675
switchMap(
7776
({ editor }) =>
7877
new Promise<Editor>((resolve) => {
@@ -85,14 +84,14 @@ export const editorHook = <T = unknown>(component: Type<T>, moduleDef: TestModul
8584
// after global tinymce is removed in a clean up. Specifically, it happens when unloading/loading different versions of TinyMCE
8685
if (editor.licenseKeyManager) {
8786
editor.licenseKeyManager.validate({}).then(() => {
88-
setTimeout(() => {
87+
// setTimeout(() => {
8988
resolve(editor as Editor);
90-
}, 500);
89+
// }, 500);
9190
}).catch((reason) => console.warn(reason));
9291
} else {
93-
setTimeout(() => {
92+
// setTimeout(() => {
9493
resolve(editor as Editor);
95-
}, 500);
94+
// }, 500);
9695
}
9796
});
9897
})

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import '../alien/InitTestEnvironment';
22

3-
import { describe, it } from '@ephox/bedrock-client';
3+
import { after, describe, it } from '@ephox/bedrock-client';
44

55
import { EditorComponent } from '../../../main/ts/public_api';
66
import { eachVersionContext, editorHook } from '../alien/TestHooks';
77
import { map, merge, timer, first, buffer, firstValueFrom } from 'rxjs';
88
import { Assertions } from '@ephox/agar';
99
import { Fun } from '@ephox/katamari';
10-
import { supportedTinymceVersions, throwTimeout } from '../alien/TestHelpers';
10+
import { deleteTinymce, supportedTinymceVersions, throwTimeout } from '../alien/TestHelpers';
1111

1212
describe('EventBlacklistingTest', () => {
1313
eachVersionContext(supportedTinymceVersions(), () => {
14+
after(() => {
15+
deleteTinymce();
16+
});
17+
1418
const createFixture = editorHook(EditorComponent);
1519

1620
it('Events should be bound when allowed', async () => {

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

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

33
import { Assertions } from '@ephox/agar';
4-
import { describe, it, context, before } from '@ephox/bedrock-client';
4+
import { describe, it, context, after } from '@ephox/bedrock-client';
55
import { Global } from '@ephox/katamari';
66

77
import { EditorComponent, TINYMCE_SCRIPT_SRC } from '../../../main/ts/public_api';
@@ -28,7 +28,7 @@ describe('LoadTinyTest', () => {
2828
],
2929
});
3030

31-
before(deleteTinymce);
31+
after(deleteTinymce);
3232

3333
it('Should be able to load local version of TinyMCE specified via dependency injection', async () => {
3434
const { editor } = await createFixture();
@@ -51,7 +51,7 @@ describe('LoadTinyTest', () => {
5151
context(`With cloud version ${version}`, () => {
5252
const createFixture = editorHook(EditorComponent);
5353

54-
before(deleteTinymce);
54+
after(deleteTinymce);
5555

5656
it(`Should be able to load TinyMCE ${version} from Cloud`, async () => {
5757
const { editor } = await createFixture({ cloudChannel: version, apiKey: key });

0 commit comments

Comments
 (0)