Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

Commit

Permalink
Test when structured_text has blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
souljuse committed Mar 9, 2022
1 parent 021b043 commit d6c53fb
Showing 1 changed file with 93 additions and 32 deletions.
125 changes: 93 additions & 32 deletions test/src/seoTagsBuilder_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -621,41 +621,102 @@ describe('seoTagsBuilder', () => {
});

context('of structured_text type', () => {
beforeEach(() => {
excerptFieldType = memo(() => ({
type: 'structured_text',
editor: 'structured_text',
itemContent: {
schema: 'dast',
document: {
type: 'root',
children: [
{
type: 'heading',
level: 3,
children: [
{ type: 'span', value: 'This is an ' },
{
type: 'span',
value: 'excerpt',
marks: ['strong'],
},
],
},
{
type: 'paragraph',
children: [{ type: 'span', value: '!' }],
},
],
context('without blocks', () => {
beforeEach(() => {
excerptFieldType = memo(() => ({
type: 'structured_text',
editor: 'structured_text',
itemContent: {
schema: 'dast',
document: {
type: 'root',
children: [
{
type: 'heading',
level: 3,
children: [
{ type: 'span', value: 'This is an ' },
{
type: 'span',
value: 'excerpt',
marks: ['strong'],
},
],
},
{
type: 'paragraph',
children: [{ type: 'span', value: '!' }],
},
],
},
},
},
}));
}));
});

it('returns sanitized field', () => {
expect(descriptionValue()).to.eq('This is an excerpt !');
expect(ogValue()).to.eq('This is an excerpt !');
expect(cardValue()).to.eq('This is an excerpt !');
});
});

it('returns sanitized field', () => {
expect(descriptionValue()).to.eq('This is an excerpt !');
expect(ogValue()).to.eq('This is an excerpt !');
expect(cardValue()).to.eq('This is an excerpt !');
context('with blocks', () => {
beforeEach(() => {
excerptFieldType = memo(() => ({
type: 'structured_text',
editor: 'structured_text',
itemContent: {
schema: 'dast',
document: {
type: 'root',
children: [
{
type: 'heading',
level: 3,
children: [
{ type: 'span', value: 'This is an ' },
{
type: 'span',
value: 'excerpt',
marks: ['strong'],
},
{
type: 'itemLink',
item: '344312',
children: [
{
type: 'span',
value: 'link text ',
},
],
},
{
type: 'inlineItem',
item: '344312',
},
],
},
{
type: 'paragraph',
children: [{ type: 'span', value: '!' }],
},
{
type: 'block',
item: '812394',
},
],
},
},
}));
});

it('returns sanitized field', () => {
expect(descriptionValue()).to.eq(
'This is an excerpt link text !',
);
expect(ogValue()).to.eq('This is an excerpt link text !');
expect(cardValue()).to.eq('This is an excerpt link text !');
});
});
});
});
Expand Down

0 comments on commit d6c53fb

Please sign in to comment.