-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Rewrote the test for `parseComponentPath` 2. Added test for `getNavigationTree` 3. renamed `get-nav-tree.ts` to `get-navigation-tree.ts` Co-authored-by: Preston Bourne <[email protected]>
- Loading branch information
1 parent
39d7737
commit 7d3935f
Showing
6 changed files
with
116 additions
and
17 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
101 changes: 101 additions & 0 deletions
101
packages/swingset/__tests__/get-navigation-tree.test.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,101 @@ | ||
import { describe, it } from 'vitest' | ||
import { getNavigationTree } from '../src/get-navigation-tree' | ||
import { ComponentEntity, NavigationTree } from '../src/types' | ||
|
||
describe(getNavigationTree.name, () => { | ||
it('Builds the Navigation Tree', ({ expect }) => { | ||
const input: ComponentEntity[] = [ | ||
{ | ||
__type: 'component', | ||
category: 'default', | ||
componentPath: '../../..', | ||
filepath: '../../..', | ||
frontmatter: {}, | ||
normalizedPath: '', | ||
relativePath: '', | ||
slug: '', | ||
title: '', | ||
load: '', | ||
}, | ||
] | ||
|
||
const expectation: NavigationTree = [ | ||
{ | ||
children: [ | ||
{ | ||
__type: 'component', | ||
componentPath: '../../..', | ||
slug: '', | ||
title: '', | ||
}, | ||
], | ||
title: 'default', | ||
__type: 'category', | ||
}, | ||
] | ||
|
||
const result = getNavigationTree(input) | ||
|
||
expect(result).toEqual(expectation) | ||
}) | ||
it('Supports duplicate entities', ({ expect }) => { | ||
const input: ComponentEntity[] = [ | ||
{ | ||
__type: 'component', | ||
category: 'default', | ||
componentPath: '../../..', | ||
filepath: '../../..', | ||
frontmatter: {}, | ||
normalizedPath: '', | ||
relativePath: '', | ||
slug: '', | ||
title: '', | ||
load: '', | ||
}, | ||
{ | ||
__type: 'component', | ||
category: 'default', | ||
componentPath: '../../..', | ||
filepath: '../../..', | ||
frontmatter: {}, | ||
normalizedPath: '', | ||
relativePath: '', | ||
slug: '', | ||
title: '', | ||
load: '', | ||
}, | ||
] | ||
|
||
const expectation: NavigationTree = [ | ||
{ | ||
children: [ | ||
{ | ||
__type: 'component', | ||
componentPath: '../../..', | ||
slug: '', | ||
title: '', | ||
}, | ||
{ | ||
__type: 'component', | ||
componentPath: '../../..', | ||
slug: '', | ||
title: '', | ||
}, | ||
], | ||
title: 'default', | ||
__type: 'category', | ||
}, | ||
] | ||
|
||
const result = getNavigationTree(input) | ||
|
||
expect(result).toEqual(expectation) | ||
}) | ||
it('Returns an empty array if it receives one', ({ expect }) => { | ||
const input: ComponentEntity[] = [] | ||
const expectation: NavigationTree = [] | ||
const result = getNavigationTree(input) | ||
|
||
expect(result).toEqual(expectation) | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
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
File renamed without changes.
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