-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit test for new breadcrumb helper
- Loading branch information
1 parent
8ddfbea
commit 16e3915
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
packages/web-app-files/tests/unit/helpers/breadcrumbs.spec.js
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,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 | ||
}) | ||
) | ||
}) | ||
}) |