Commit bf2313ba authored by derek-knox's avatar derek-knox

Refactor rich_content_editor mocks (tighter cohesion)

Appease danger bot with a description...
parent ae811a1f
...@@ -11,7 +11,7 @@ import { ...@@ -11,7 +11,7 @@ import {
uneditableCloseToken, uneditableCloseToken,
uneditableCloseTokens, uneditableCloseTokens,
uneditableTokens, uneditableTokens,
} from '../../mock_data'; } from './mock_data';
describe('Build Uneditable Token renderer helper', () => { describe('Build Uneditable Token renderer helper', () => {
describe('buildUneditableOpenTokens', () => { describe('buildUneditableOpenTokens', () => {
......
// Node spec helpers
export const buildMockTextNode = literal => {
return {
firstChild: null,
literal,
type: 'text',
};
};
export const buildMockListNode = literal => {
return {
firstChild: {
firstChild: {
firstChild: buildMockTextNode(literal),
type: 'paragraph',
},
type: 'item',
},
type: 'list',
};
};
export const normalTextNode = buildMockTextNode('This is just normal text.');
export const normalListNode = buildMockListNode('Just another bullet point');
// Token spec helpers
const uneditableOpenToken = {
type: 'openTag',
tagName: 'div',
attributes: { contenteditable: false },
classNames: [
'gl-px-4 gl-py-2 gl-opacity-5 gl-bg-gray-100 gl-user-select-none gl-cursor-not-allowed',
],
};
export const uneditableCloseToken = { type: 'closeTag', tagName: 'div' };
export const originToken = {
type: 'text',
content: '{:.no_toc .hidden-md .hidden-lg}',
};
export const uneditableOpenTokens = [uneditableOpenToken, originToken];
export const uneditableCloseTokens = [originToken, uneditableCloseToken];
export const uneditableTokens = [...uneditableOpenTokens, uneditableCloseToken];
import renderer from '~/vue_shared/components/rich_content_editor/services/renderers/render_embedded_ruby_text'; import renderer from '~/vue_shared/components/rich_content_editor/services/renderers/render_embedded_ruby_text';
import { buildUneditableTokens } from '~/vue_shared/components/rich_content_editor/services/renderers/build_uneditable_token'; import { buildUneditableTokens } from '~/vue_shared/components/rich_content_editor/services/renderers/build_uneditable_token';
import { embeddedRubyTextNode, normalTextNode } from '../../mock_data'; import { buildMockTextNode, normalTextNode } from './mock_data';
const embeddedRubyTextNode = buildMockTextNode('<%= partial("some/path") %>');
describe('Render Embedded Ruby Text renderer', () => { describe('Render Embedded Ruby Text renderer', () => {
describe('canRender', () => { describe('canRender', () => {
......
...@@ -4,7 +4,9 @@ import { ...@@ -4,7 +4,9 @@ import {
buildUneditableCloseToken, buildUneditableCloseToken,
} from '~/vue_shared/components/rich_content_editor/services/renderers/build_uneditable_token'; } from '~/vue_shared/components/rich_content_editor/services/renderers/build_uneditable_token';
import { kramdownListNode, normalListNode } from '../../mock_data'; import { buildMockListNode, normalListNode } from './mock_data';
const kramdownListNode = buildMockListNode('TOC');
describe('Render Kramdown List renderer', () => { describe('Render Kramdown List renderer', () => {
describe('canRender', () => { describe('canRender', () => {
......
import renderer from '~/vue_shared/components/rich_content_editor/services/renderers/render_kramdown_text'; import renderer from '~/vue_shared/components/rich_content_editor/services/renderers/render_kramdown_text';
import { buildUneditableTokens } from '~/vue_shared/components/rich_content_editor/services/renderers/build_uneditable_token'; import { buildUneditableTokens } from '~/vue_shared/components/rich_content_editor/services/renderers/build_uneditable_token';
import { kramdownTextNode, normalTextNode } from '../../mock_data'; import { buildMockTextNode, normalTextNode } from './mock_data';
const kramdownTextNode = buildMockTextNode('{:toc}');
describe('Render Kramdown Text renderer', () => { describe('Render Kramdown Text renderer', () => {
describe('canRender', () => { describe('canRender', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment