Commit 9cf189f1 authored by derek-knox's avatar derek-knox

Apply feedback - add missing test

parent 1de2f6ee
......@@ -2,16 +2,19 @@ import {
buildUneditableOpenTokens,
buildUneditableCloseToken,
buildUneditableCloseTokens,
buildUneditableInlineTokens,
buildUneditableTokens,
buildUneditableInlineTokens,
buildUneditableHtmlAsTextTokens,
} from '~/vue_shared/components/rich_content_editor/services/renderers/build_uneditable_token';
import {
htmlBlockNode,
originInlineToken,
originToken,
uneditableOpenTokens,
uneditableCloseToken,
uneditableCloseTokens,
uneditableBlockTokens,
uneditableInlineTokens,
uneditableTokens,
} from './mock_data';
......@@ -41,6 +44,15 @@ describe('Build Uneditable Token renderer helper', () => {
});
});
describe('buildUneditableTokens', () => {
it('returns a 3-item array of tokens with the originToken wrapped in the middle of block tokens', () => {
const result = buildUneditableTokens(originToken);
expect(result).toHaveLength(3);
expect(result).toStrictEqual(uneditableTokens);
});
});
describe('buildUneditableInlineTokens', () => {
it('returns a 3-item array of tokens with the originInlineToken wrapped in the middle of inline tokens', () => {
const result = buildUneditableInlineTokens(originInlineToken);
......@@ -50,12 +62,12 @@ describe('Build Uneditable Token renderer helper', () => {
});
});
describe('buildUneditableTokens', () => {
it('returns a 3-item array of tokens with the originToken wrapped in the middle of block tokens', () => {
const result = buildUneditableTokens(originToken);
describe('buildUneditableHtmlAsTextTokens', () => {
it('returns a 3-item array of tokens with the htmlBlockNode wrapped as a text token in the middle of block tokens', () => {
const result = buildUneditableHtmlAsTextTokens(htmlBlockNode);
expect(result).toHaveLength(3);
expect(result).toStrictEqual(uneditableTokens);
expect(result).toStrictEqual(uneditableBlockTokens);
});
});
});
......@@ -10,6 +10,11 @@ export const buildMockTextNode = literal => {
export const normalTextNode = buildMockTextNode('This is just normal text.');
export const htmlBlockNode = {
type: 'htmlBlock',
literal: '<div data-tomark-pass ><h1>Some header</h1><p>Some paragraph</p></div>',
};
// Token spec helpers
const buildUneditableOpenToken = type => {
......@@ -45,3 +50,13 @@ export const uneditableInlineTokens = [
originInlineToken,
buildUneditableCloseToken('a'),
];
export const uneditableBlockTokens = [
buildUneditableOpenToken('div'),
{
type: 'text',
tagName: null,
content: '<div><h1>Some header</h1><p>Some paragraph</p></div>',
},
buildUneditableCloseToken('div'),
];
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