Skip to content

Commit

Permalink
tests: updte "Returns first child with source..." test
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgeorpinel committed Jan 6, 2020
1 parent d71036c commit a09dcc1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ lib-cov
# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

Expand Down
27 changes: 20 additions & 7 deletions src/utils/sidebar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,20 +336,31 @@ describe('SidebarMenu/helper', () => {
expect(getItemByPath('/doc')).toEqual(result)
})

it('Returns first child with source for sourceless parents', () => {
// eslint-disable-next-line max-len
it('Returns first child with source for all parents with source:false', () => {
const rawData = [
{
slug: 'item-name',
slug: 'item',
source: false,
children: [
{ slug: 'nested-item', source: false, children: ['subnested-item'] }
{
slug: 'nested',
source: false,
children: [
{
slug: 'subnested',
source: false,
children: ['leaf-item']
}
]
}
]
}
]
const result = {
label: 'Subnested Item',
path: '/doc/item-name/nested-item/subnested-item',
source: '/static/docs/item-name/nested-item/subnested-item.md',
label: 'Leaf Item',
path: '/doc/item/nested/subnested/leaf-item',
source: '/static/docs/item/nested/subnested/leaf-item.md',
tutorials: {},
prev: undefined,
next: undefined
Expand All @@ -358,7 +369,9 @@ describe('SidebarMenu/helper', () => {
jest.doMock('../../public/static/docs/sidebar.json', () => rawData)
const { getItemByPath } = require('./sidebar')

expect(getItemByPath('/doc/item-name')).toEqual(result)
expect(getItemByPath('/doc/item')).toEqual(result)
expect(getItemByPath('/doc/item/nested')).toEqual(result)
expect(getItemByPath('/doc/item/nested/subnested')).toEqual(result)
})
})

Expand Down

0 comments on commit a09dcc1

Please sign in to comment.