-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(core): add title and collapsible menu to nx.dev docs viewer
- Loading branch information
Showing
16 changed files
with
270 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
nx-dev/data-access-documents/src/lib/documents.utils.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { extractTitle } from './documents.utils'; | ||
|
||
describe('extractTitle', () => { | ||
it('should return header if it exists', () => { | ||
const content = ` | ||
# This is the title | ||
Hello, this is just a test document... | ||
`; | ||
|
||
const result = extractTitle(content); | ||
|
||
expect(result).toEqual('This is the title'); | ||
}); | ||
|
||
it('should return null if title cannot be found', () => { | ||
const content = ` | ||
## Secondary header | ||
Hello, this is just a test document... | ||
`; | ||
|
||
const result = extractTitle(content); | ||
|
||
expect(result).toEqual(null); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,55 @@ | ||
import React from 'react'; | ||
import { screen } from '@testing-library/dom'; | ||
import { render } from '@testing-library/react'; | ||
|
||
import Sidebar from './sidebar'; | ||
|
||
describe('Sidebar', () => { | ||
it('should render successfully', () => { | ||
const { baseElement } = render( | ||
<Sidebar menu={{ version: 'preview', flavor: 'react', sections: [] }} /> | ||
it('should render sections', () => { | ||
render( | ||
<Sidebar | ||
menu={{ | ||
version: 'preview', | ||
flavor: 'react', | ||
sections: [ | ||
{ | ||
id: 'basic', | ||
name: 'Basic', | ||
hideSectionHeader: true, | ||
itemList: [ | ||
{ | ||
id: 'getting-started', | ||
name: 'getting started', | ||
itemList: [ | ||
{ id: 'a', name: 'A', path: '/a' }, | ||
{ id: 'b', name: 'B', path: '/b' }, | ||
{ id: 'c', name: 'C', path: '/c' }, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
id: 'api', | ||
name: 'API', | ||
itemList: [ | ||
{ | ||
id: 'overview', | ||
name: 'overview', | ||
itemList: [ | ||
{ id: 'd', name: 'D', path: '/d' }, | ||
{ id: 'e', name: 'E', path: '/e' }, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}} | ||
/> | ||
); | ||
expect(baseElement).toBeTruthy(); | ||
|
||
expect(() => screen.getByTestId('section-h4:basic')).toThrow( | ||
/Unable to find/ | ||
); | ||
expect(screen.getByTestId('section-h4:api')).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.