tagHandler - Handle H6 + tests

This commit is contained in:
2019-12-21 23:13:28 +05:30
parent 297eeaafcd
commit fdd00f9262
2 changed files with 12 additions and 11 deletions
+9 -11
View File
@@ -58,6 +58,10 @@ test('should render plain h5 with text', () => {
expect((render(<h5>abcd</h5>) as string).trim()).toBe('##### abcd'); expect((render(<h5>abcd</h5>) as string).trim()).toBe('##### abcd');
}); });
test('should render plain h6 with text', () => {
expect((render(<h6>abcd</h6>) as string).trim()).toBe('###### abcd');
});
test('should render plain strong with text', () => { test('should render plain strong with text', () => {
expect((render(<strong>abcd</strong>) as string).trim()).toBe('**abcd**'); expect((render(<strong>abcd</strong>) as string).trim()).toBe('**abcd**');
}); });
@@ -110,24 +114,18 @@ test('should render image with alt text and title', () => {
test('should render image with only alt text', () => { test('should render image with only alt text', () => {
expect( expect(
(render( (render(<img src="./test.jpg" alt="some alt" />) as string).trim()
<img src="./test.jpg" alt="some alt" />
) as string).trim()
).toBe('![some alt](./test.jpg)'); ).toBe('![some alt](./test.jpg)');
}); });
test('should render image with only title', () => { test('should render image with only title', () => {
expect( expect(
(render( (render(<img src="./test.jpg" title="some title" />) as string).trim()
<img src="./test.jpg" title="some title" />
) as string).trim()
).toBe('![](./test.jpg "some title")'); ).toBe('![](./test.jpg "some title")');
}); });
test('should render image without attributes', () => { test('should render image without attributes', () => {
expect( expect((render(<img src="./test.jpg" />) as string).trim()).toBe(
(render( '![](./test.jpg)'
<img src="./test.jpg" /> );
) as string).trim()
).toBe('![](./test.jpg)');
}); });
+3
View File
@@ -38,6 +38,9 @@ export default function handleTag(
case 'h5': case 'h5':
newParentASTNode = childASTNode = heading(5); newParentASTNode = childASTNode = heading(5);
break; break;
case 'h6':
newParentASTNode = childASTNode = heading(6);
break;
// END - Handle all headings // END - Handle all headings
// START - Handle strong and em // START - Handle strong and em