From dcb7b0ecc0f4977e2e832b1d9b694338aa789eb6 Mon Sep 17 00:00:00 2001 From: Mateusz Baginski Date: Fri, 16 Aug 2024 08:44:27 +0200 Subject: [PATCH] Add `useCKEditorCloud` testing --- tests/useCKEditorCloud.test.ts | 56 ++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 tests/useCKEditorCloud.test.ts diff --git a/tests/useCKEditorCloud.test.ts b/tests/useCKEditorCloud.test.ts new file mode 100644 index 0000000..7d25c67 --- /dev/null +++ b/tests/useCKEditorCloud.test.ts @@ -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( { + 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(); + } ); + } ); +} );