Skip to content

Commit 85227b5

Browse files
authored
Merge pull request #17877 from ckeditor/release-emoji-cache
Internal: Implemented cache mechanism for Emoji requests.
2 parents 24d8796 + c11ce81 commit 85227b5

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

packages/ckeditor5-emoji/src/emojirepository.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ export default class EmojiRepository extends Plugin {
236236

237237
repositoryUrl.searchParams.set( 'editorVersion', version );
238238

239-
const result: Array<EmojiCdnResource> = await fetch( repositoryUrl )
239+
const result: Array<EmojiCdnResource> = await fetch( repositoryUrl, { cache: 'force-cache' } )
240240
.then( response => {
241241
if ( !response.ok ) {
242242
return [];

packages/ckeditor5-emoji/tests/emojirepository.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,26 @@ describe( 'EmojiRepository', () => {
103103
await editor.destroy();
104104
} );
105105

106+
it( 'should force using cache mechanism when sending a request', async () => {
107+
const { editor, domElement } = await createTestEditor( resolve => {
108+
const response = JSON.stringify( [
109+
{ emoji: '😐️', annotation: 'neutral face', group: 0, version: 15 },
110+
{ emoji: '😒', annotation: 'unamused face', group: 0, version: 15 }
111+
] );
112+
113+
resolve( new Response( response ) );
114+
} );
115+
116+
expect( fetchStub.calledOnce ).to.equal( true );
117+
118+
const fetchOptions = fetchStub.firstCall.args[ 1 ];
119+
120+
expect( fetchOptions ).to.have.property( 'cache', 'force-cache' );
121+
122+
domElement.remove();
123+
await editor.destroy();
124+
} );
125+
106126
it( 'should fetch the emoji version 16 (a plugin default)', async () => {
107127
const { editor, domElement } = await createTestEditor( resolve => {
108128
const response = JSON.stringify( [

0 commit comments

Comments
 (0)