Commit 7a33f641 authored by Enrique Alcántara's avatar Enrique Alcántara

Merge branch '230565-renderer-mock-data-cleanup' into 'master'

DRY mock data cleanup

Closes #230565

See merge request gitlab-org/gitlab!40775
parents 95d6252f a9ae4ef6
// Node spec helpers // Node spec helpers
export const buildMockTextNode = literal => { export const buildMockTextNode = literal => ({ literal, type: 'text' });
return {
firstChild: null,
literal,
type: 'text',
};
};
export const normalTextNode = buildMockTextNode('This is just normal text.'); export const normalTextNode = buildMockTextNode('This is just normal text.');
...@@ -23,17 +17,20 @@ const buildMockUneditableOpenToken = type => { ...@@ -23,17 +17,20 @@ const buildMockUneditableOpenToken = type => {
}; };
}; };
const buildMockUneditableCloseToken = type => { const buildMockTextToken = content => {
return { type: 'closeTag', tagName: type }; return {
type: 'text',
tagName: null,
content,
};
}; };
export const originToken = { const buildMockUneditableCloseToken = type => ({ type: 'closeTag', tagName: type });
type: 'text',
tagName: null, export const originToken = buildMockTextToken('{:.no_toc .hidden-md .hidden-lg}');
content: '{:.no_toc .hidden-md .hidden-lg}', const uneditableOpenToken = buildMockUneditableOpenToken('div');
}; export const uneditableOpenTokens = [uneditableOpenToken, originToken];
export const uneditableCloseToken = buildMockUneditableCloseToken('div'); export const uneditableCloseToken = buildMockUneditableCloseToken('div');
export const uneditableOpenTokens = [buildMockUneditableOpenToken('div'), originToken];
export const uneditableCloseTokens = [originToken, uneditableCloseToken]; export const uneditableCloseTokens = [originToken, uneditableCloseToken];
export const uneditableTokens = [...uneditableOpenTokens, uneditableCloseToken]; export const uneditableTokens = [...uneditableOpenTokens, uneditableCloseToken];
...@@ -41,6 +38,7 @@ export const originInlineToken = { ...@@ -41,6 +38,7 @@ export const originInlineToken = {
type: 'text', type: 'text',
content: '<i>Inline</i> content', content: '<i>Inline</i> content',
}; };
export const uneditableInlineTokens = [ export const uneditableInlineTokens = [
buildMockUneditableOpenToken('a'), buildMockUneditableOpenToken('a'),
originInlineToken, originInlineToken,
...@@ -48,13 +46,9 @@ export const uneditableInlineTokens = [ ...@@ -48,13 +46,9 @@ export const uneditableInlineTokens = [
]; ];
export const uneditableBlockTokens = [ export const uneditableBlockTokens = [
buildMockUneditableOpenToken('div'), uneditableOpenToken,
{ buildMockTextToken('<div><h1>Some header</h1><p>Some paragraph</p></div>'),
type: 'text', uneditableCloseToken,
tagName: null,
content: '<div><h1>Some header</h1><p>Some paragraph</p></div>',
},
buildMockUneditableCloseToken('div'),
]; ];
export const attributeDefinition = '{:.no_toc .hidden-md .hidden-lg}'; export const attributeDefinition = '{:.no_toc .hidden-md .hidden-lg}';
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