Skip to content

Commit

Permalink
Add unit test for new breadcrumb helper
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalwengerter committed Mar 29, 2022
1 parent 8ddfbea commit 16e3915
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/web-app-files/tests/unit/helpers/breadcrumbs.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { breadcrumbsFromPath, concatBreadcrumbs } from '../../../src/helpers/breadcrumbs'

describe('builds an array of breadcrumbitems', () => {
it('from a path', () => {
const breadCrumbs = breadcrumbsFromPath('/files/spaces/personal/home/test', '/test')
expect(breadCrumbs).toEqual([
{ allowContextActions: true, text: 'test', to: '/files/spaces/personal/home/test' }
])
})

it('from an array of breadcrumbitems', () => {
const initialBreadCrumbs = [{ text: 'Foo' }, { text: 'Bar' }]
const breadCrumbsFromPath = breadcrumbsFromPath('/app/foo/bar?all=500', '/bar')
const result = concatBreadcrumbs(...initialBreadCrumbs, breadCrumbsFromPath)
expect(result[0]).toMatchObject({ text: 'Foo' })
expect(result[1]).toMatchObject({ text: 'Bar' })
expect(JSON.stringify(result[2])).toEqual(
JSON.stringify({
allowContextActions: undefined,
onClick: () => jest.fn(() => {}),
text: undefined
})
)
})
})

0 comments on commit 16e3915

Please sign in to comment.