Skip to content

Commit

Permalink
INT-3297: Utilise majorVersion prop in LoadTinyTest.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
danoaky-tiny committed Apr 10, 2024
1 parent a675164 commit 25e9cb7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/test/ts/alien/Loader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface Context {
DOMNode: HTMLElement;
editor: TinyMCEEditor;
ref: React.RefObject<Editor>;
version: string;
majorVersion: string;
}

const getRoot = () => Optional.from(document.getElementById('root')).getOrThunk(() => {
Expand Down Expand Up @@ -69,7 +69,7 @@ export const render = async (props: Partial<IAllProps> = {}, container: HTMLElem
ref,
editor,
DOMNode,
version: Global.tinymce.majorVersion
majorVersion: Global.tinymce.majorVersion
});
});
}, 0);
Expand Down
22 changes: 11 additions & 11 deletions src/test/ts/browser/LoadTinyTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,45 @@ import { describe, it } from '@ephox/bedrock-client';
import { Global } from '@ephox/katamari';

import { CLOUD_VERSIONS, VALID_API_KEY, VERSIONS, type Version } from '../alien/TestHelpers';
import { render } from '../alien/Loader';
import { render, ReactEditorContext } from '../alien/Loader';

const assertTinymceVersion = (version: Version) => {
Assertions.assertEq(`Loaded version of TinyMCE should be ${version}`, version, Global.tinymce.majorVersion);
const assertTinymceVersion = (ctx: ReactEditorContext, version: Version) => {
Assertions.assertEq(`Loaded version of TinyMCE should be ${version}`, version, ctx.majorVersion);
};

describe('LoadTinyTest', () => {
VERSIONS.forEach((version) => {
it(`Should be able to load local version (${version}) of TinyMCE using the tinymceScriptSrc prop`, async () => {
using _ctx = await render({ tinymceScriptSrc: `/project/node_modules/tinymce-${version}/tinymce.min.js`, licenseKey: 'gpl' });
assertTinymceVersion(version);
using ctx = await render({ tinymceScriptSrc: `/project/node_modules/tinymce-${version}/tinymce.min.js`, licenseKey: 'gpl' });
assertTinymceVersion(ctx, version);
});
});

CLOUD_VERSIONS.forEach((version) => {
it(`Should be able to load TinyMCE from Cloud (${version})`, async () => {
const apiKey = 'a-fake-api-key';
using _ctx = await render({ apiKey, cloudChannel: version });
assertTinymceVersion(version);
using ctx = await render({ apiKey, cloudChannel: version });
assertTinymceVersion(ctx, version);
Assertions.assertEq(
'TinyMCE should have been loaded from Cloud',
`https://cdn.tiny.cloud/1/${apiKey}/tinymce/${version}`,
Global.tinymce.baseURI.source
ctx.editor.baseURI.source
);
});

it(`Should be able to load TinyMCE (${version}) in hybrid`, async () => {
using _ctx = await render({
using ctx = await render({
tinymceScriptSrc: [
`/project/node_modules/tinymce-${version}/tinymce.min.js`,
`https://cdn.tiny.cloud/1/${VALID_API_KEY}/tinymce/${version}/cloud-plugins.min.js?tinydrive=${version}`
],
plugins: [ 'tinydrive' ]
});
assertTinymceVersion(version);
assertTinymceVersion(ctx, version);
Assertions.assertEq(
'TinyMCE should have been loaded locally',
`/project/node_modules/tinymce-${version}`,
Global.tinymce.baseURI.path
ctx.editor.baseURI.source
);
Assertions.assertEq(
'The tinydrive plugin should have defaults for the cloud',
Expand Down

0 comments on commit 25e9cb7

Please sign in to comment.