-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} ); | ||
} ); | ||
} ); |