diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
commit | 36a59d088eca61b834191dacea009677a96c052f (patch) | |
tree | e4f33972dab5d8ef79e3944a9f403035fceea43f /spec/frontend/content_editor/extensions/code_block_highlight_spec.js | |
parent | a1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff) |
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'spec/frontend/content_editor/extensions/code_block_highlight_spec.js')
-rw-r--r-- | spec/frontend/content_editor/extensions/code_block_highlight_spec.js | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/spec/frontend/content_editor/extensions/code_block_highlight_spec.js b/spec/frontend/content_editor/extensions/code_block_highlight_spec.js index 02e5b1dc271..fc8460c7f84 100644 --- a/spec/frontend/content_editor/extensions/code_block_highlight_spec.js +++ b/spec/frontend/content_editor/extensions/code_block_highlight_spec.js @@ -1,4 +1,5 @@ import CodeBlockHighlight from '~/content_editor/extensions/code_block_highlight'; +import languageLoader from '~/content_editor/services/code_block_language_loader'; import { createTestEditor, createDocBuilder, triggerNodeInputRule } from '../test_utils'; const CODE_BLOCK_HTML = `<pre class="code highlight js-syntax-highlight language-javascript" lang="javascript" v-pre="true"> @@ -9,20 +10,20 @@ const CODE_BLOCK_HTML = `<pre class="code highlight js-syntax-highlight language </code> </pre>`; +jest.mock('~/content_editor/services/code_block_language_loader'); + describe('content_editor/extensions/code_block_highlight', () => { let parsedCodeBlockHtmlFixture; let tiptapEditor; let doc; let codeBlock; - let languageLoader; const parseHTML = (html) => new DOMParser().parseFromString(html, 'text/html'); const preElement = () => parsedCodeBlockHtmlFixture.querySelector('pre'); beforeEach(() => { - languageLoader = { loadLanguages: jest.fn() }; tiptapEditor = createTestEditor({ - extensions: [CodeBlockHighlight.configure({ languageLoader })], + extensions: [CodeBlockHighlight], }); ({ @@ -70,6 +71,8 @@ describe('content_editor/extensions/code_block_highlight', () => { const language = 'javascript'; beforeEach(() => { + languageLoader.loadLanguageFromInputRule.mockReturnValueOnce({ language }); + triggerNodeInputRule({ tiptapEditor, inputRuleText: `${inputRule}${language} `, @@ -83,7 +86,9 @@ describe('content_editor/extensions/code_block_highlight', () => { }); it('loads language when language loader is available', () => { - expect(languageLoader.loadLanguages).toHaveBeenCalledWith([language]); + expect(languageLoader.loadLanguageFromInputRule).toHaveBeenCalledWith( + expect.arrayContaining([`${inputRule}${language} `, language]), + ); }); }); }); |