Skip to content

Commit

Permalink
Add useCKEditorCloud testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Mati365 committed Aug 16, 2024
1 parent 81b0cfa commit dcb7b0e
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions tests/useCKEditorCloud.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md.
*/

import { beforeEach, describe, it, vi, expect } from 'vitest';
import { flushPromises } from '@vue/test-utils';
import { ref } from 'vue';

import { removeAllCkCdnResources } from '@ckeditor/ckeditor5-integrations-common/test-utils';
import type { CKEditorCloudConfig } from '@ckeditor/ckeditor5-integrations-common';

import useCKEditorCloud from '../src/useCKEditorCloud';

describe( 'useCKEditorCloud', () => {
beforeEach( removeAllCkCdnResources );

it( 'should load CKEditor bundle from CDN', async () => {
const { data } = useCKEditorCloud( {
version: '43.0.0'
} );

await flushPromises();
await vi.waitFor( () => {
expect( data.value?.CKEditor ).toBeDefined();
} );
} );

it( 'should load CKEditor premium bundle from CDN', async () => {
const { data } = useCKEditorCloud( {
version: '43.0.0',
withPremiumFeatures: true
} );

await flushPromises();
await vi.waitFor( () => {
expect( data.value?.CKEditor ).toBeDefined();
expect( data.value?.CKEditorPremiumFeatures ).toBeDefined();
} );
} );

it( 'should load additional resources from CDN after updating config ref', async () => {
const config = ref<CKEditorCloudConfig>( {
version: '43.0.0'
} );

const { data } = useCKEditorCloud( config );

config.value.withPremiumFeatures = true;

await vi.waitFor( () => {
expect( data.value?.CKEditor ).toBeDefined();
expect( data.value?.CKEditorPremiumFeatures ).toBeDefined();
} );
} );
} );

0 comments on commit dcb7b0e

Please sign in to comment.