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

Apply feedback - add missing test

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