mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-04 12:20:19 +03:00
test: add tests to cover fix for double title displaying case
This commit is contained in:
parent
9bb51e469d
commit
fcc7df7af3
|
@ -97,4 +97,22 @@ describe('Markdown renderer', () => {
|
||||||
expect(part.component).toBe(TestComponent);
|
expect(part.component).toBe(TestComponent);
|
||||||
expect(part.props).toEqual({ children: ' Test Test ' });
|
expect(part.props).toEqual({ children: ' Test Test ' });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should properly extract title from text', () => {
|
||||||
|
const rawTexts = ['text before\n# Test', 'text before\n # Test', 'text before\n# Test\n'];
|
||||||
|
rawTexts.forEach(text => {
|
||||||
|
const headings = renderer.extractHeadings(text);
|
||||||
|
expect(headings).toHaveLength(1);
|
||||||
|
expect(headings[0].name).toEqual('Test');
|
||||||
|
expect(headings[0].description).toEqual('');
|
||||||
|
});
|
||||||
|
|
||||||
|
const rawTexts2 = ['# Test \n text after', '# Test \ntext after'];
|
||||||
|
rawTexts2.forEach(text => {
|
||||||
|
const headings = renderer.extractHeadings(text);
|
||||||
|
expect(headings).toHaveLength(1);
|
||||||
|
expect(headings[0].name).toEqual('Test');
|
||||||
|
expect(headings[0].description).toEqual('text after');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -47,6 +47,30 @@ describe('Models', () => {
|
||||||
expect(info.summary).toEqual('Test summary\nsome text\n## Heading\n test');
|
expect(info.summary).toEqual('Test summary\nsome text\n## Heading\n test');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should correctly populate description when 2nd line is started by white space', () => {
|
||||||
|
parser.spec = {
|
||||||
|
openapi: '3.0.0',
|
||||||
|
info: {
|
||||||
|
description: 'text before\n # Test',
|
||||||
|
},
|
||||||
|
} as any;
|
||||||
|
|
||||||
|
const info = new ApiInfoModel(parser);
|
||||||
|
expect(info.description).toEqual('text before\n');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should correctly populate description when 2nd line is only white space', () => {
|
||||||
|
parser.spec = {
|
||||||
|
openapi: '3.0.0',
|
||||||
|
info: {
|
||||||
|
description: 'text before\n \n # Test',
|
||||||
|
},
|
||||||
|
} as any;
|
||||||
|
|
||||||
|
const info = new ApiInfoModel(parser);
|
||||||
|
expect(info.description).toEqual('text before\n');
|
||||||
|
});
|
||||||
|
|
||||||
test('should correctly populate license identifier', () => {
|
test('should correctly populate license identifier', () => {
|
||||||
parser.spec = {
|
parser.spec = {
|
||||||
openapi: '3.1.0',
|
openapi: '3.1.0',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user