fix: add test for an empty section

This commit is contained in:
Valeriy S
2019-03-01 18:54:09 +03:00
committed by Stuart Taylor
parent 6d5e3865e7
commit 28fb711a10
3 changed files with 8 additions and 77 deletions

View File

@ -12,8 +12,6 @@ Object {
<p><pre><code class=\\"language-html\\">&#x3C;p>We aim to preserve this&#x3C;/p> <p><pre><code class=\\"language-html\\">&#x3C;p>We aim to preserve this&#x3C;/p>
</code></pre></p> </code></pre></p>
</section>", </section>",
"instructions": "<section id=\\"instructions\\"> "instructions": "",
<p>To pass the test on this challenge, change your <code>h1</code> element's text to say \\"Hello World\\".</p>
</section>",
} }
`; `;

View File

@ -397,80 +397,6 @@
"type": "text", "type": "text",
"value": "\n" "value": "\n"
}, },
{
"type": "element",
"tagName": "p",
"properties": {},
"children": [
{
"type": "text",
"value": "To pass the test on this challenge, change your ",
"position": {
"start": {
"line": 27,
"column": 1,
"offset": 489
},
"end": {
"line": 27,
"column": 49,
"offset": 537
}
}
},
{
"type": "element",
"tagName": "code",
"properties": {},
"children": [
{
"type": "text",
"value": "h1"
}
],
"position": {
"start": {
"line": 27,
"column": 49,
"offset": 537
},
"end": {
"line": 27,
"column": 53,
"offset": 541
}
}
},
{
"type": "text",
"value": " element's text to say \"Hello World\".",
"position": {
"start": {
"line": 27,
"column": 53,
"offset": 541
},
"end": {
"line": 27,
"column": 90,
"offset": 578
}
}
}
],
"position": {
"start": {
"line": 27,
"column": 1,
"offset": 489
},
"end": {
"line": 27,
"column": 90,
"offset": 578
}
}
},
{ {
"type": "text", "type": "text",
"value": "\n" "value": "\n"

View File

@ -54,6 +54,13 @@ describe('text-to-data', () => {
expect(file.data[expectedField].includes(expectedText)).toBe(true); expect(file.data[expectedField].includes(expectedText)).toBe(true);
}); });
// eslint-disable-next-line max-len
it('should add an empty string relating to the section id without data to `file.data`', () => {
const plugin = textToData([otherExpectedField]);
plugin(mockAST, file);
expect(file.data[otherExpectedField]).toEqual('');
});
it('should preserve nested html', () => { it('should preserve nested html', () => {
const plugin = textToData([expectedField]); const plugin = textToData([expectedField]);
plugin(mockAST, file); plugin(mockAST, file);