Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 37 additions & 48 deletions src/utils/__tests__/findDirectoryNode.test.ts
Original file line number Diff line number Diff line change
@@ -1,70 +1,59 @@
import { findDirectoryNode } from '../findDirectoryNode';

jest.mock(
'@/directory/directory.json',
() => {
const mockDirectory = {
title: 'Root',
description: 'Root page',
jest.mock('@/directory/directory.json', () => ({
title: 'Root',
description: 'Root page',
platforms: [],
route: '/',
children: [
{
title: 'Route 1 Route 2',
description: 'Route 1 Route 2 page',
platforms: [],
route: '/',
route: '/route1/route2',
children: [
{
title: 'Route 1 Route 2',
description: 'Route 1 Route 2 page',
title: 'Child 1',
description: 'Child 1 page',
platforms: [],
route: '/route1/route2',
route: '/route1/route2/child1',
children: [
{
title: 'Child 1',
description: 'Child 1 page',
title: 'Child 1 Child 1',
description: 'Child 1 Child 1 page',
platforms: [],
route: '/route1/route2/child1',
children: [
{
title: 'Child 1 Child 1',
description: 'Child 1 Child 1 page',
platforms: [],
route: '/route1/route2/child1/child1'
},
{
title: 'Child 1 Child 2',
description: 'Child 1 Child 2 page',
platforms: [],
route: '/route1/route2/child1/child2'
},
{
title: 'Child 1 Child 3',
description: 'Child 1 Child 3 page',
platforms: [],
route: '/route1/route2/child1/child3'
}
]
route: '/route1/route2/child1/child1'
},
{
title: 'Child 2',
description: 'Child 2 page',
title: 'Child 1 Child 2',
description: 'Child 1 Child 2 page',
platforms: [],
route: '/route1/route2/child2'
route: '/route1/route2/child1/child2'
},
{
title: 'Child 3',
description: 'Child 3 page',
title: 'Child 1 Child 3',
description: 'Child 1 Child 3 page',
platforms: [],
route: '/route1/route2/child3'
route: '/route1/route2/child1/child3'
}
]
},
{
title: 'Child 2',
description: 'Child 2 page',
platforms: [],
route: '/route1/route2/child2'
},
{
title: 'Child 3',
description: 'Child 3 page',
platforms: [],
route: '/route1/route2/child3'
}
]
};

return {
__esModule: true,
default: mockDirectory
};
},
{ virtual: true }
);
}
]
}));

describe('findDirectoryNode', () => {
it('should return directory page node if it exists', () => {
Expand Down
82 changes: 37 additions & 45 deletions src/utils/__tests__/getChildPageNodes.test.ts
Original file line number Diff line number Diff line change
@@ -1,67 +1,59 @@
import { getChildPageNodes } from '../getChildPageNodes';

jest.mock(
'@/directory/directory.json',
() => {
const mockDirectory = {
title: 'Root',
description: 'Root page',
jest.mock('@/directory/directory.json', () => ({
title: 'Root',
description: 'Root page',
platforms: [],
route: '/',
children: [
{
title: 'Route 1 Route 2',
description: 'Route 1 Route 2 page',
platforms: [],
route: '/',
route: '/route1/route2',
children: [
{
title: 'Route 1 Route 2',
description: 'Route 1 Route 2 page',
title: 'Child 1',
description: 'Child 1 page',
platforms: [],
route: '/route1/route2',
route: '/route1/route2/child1',
children: [
{
title: 'Child 1',
description: 'Child 1 page',
title: 'Child 1 Child 1',
description: 'Child 1 Child 1 page',
platforms: [],
route: '/route1/route2/child1',
children: [
{
title: 'Child 1 Child 1',
description: 'Child 1 Child 1 page',
platforms: [],
route: '/route1/route2/child1/child1'
},
{
title: 'Child 1 Child 2',
description: 'Child 1 Child 2 page',
platforms: [],
route: '/route1/route2/child1/child2'
},
{
title: 'Child 1 Child 3',
description: 'Child 1 Child 3 page',
platforms: [],
route: '/route1/route2/child1/child3'
}
]
route: '/route1/route2/child1/child1'
},
{
title: 'Child 2',
description: 'Child 2 page',
title: 'Child 1 Child 2',
description: 'Child 1 Child 2 page',
platforms: [],
route: '/route1/route2/child2'
route: '/route1/route2/child1/child2'
},
{
title: 'Child 3',
description: 'Child 3 page',
title: 'Child 1 Child 3',
description: 'Child 1 Child 3 page',
platforms: [],
route: '/route1/route2/child3'
route: '/route1/route2/child1/child3'
}
]
},
{
title: 'Child 2',
description: 'Child 2 page',
platforms: [],
route: '/route1/route2/child2'
},
{
title: 'Child 3',
description: 'Child 3 page',
platforms: [],
route: '/route1/route2/child3'
}
]
};

return mockDirectory;
},
{ virtual: true }
);
}
]
}));

describe('getChildPageNodes', () => {
it('should return the children of a non-root node when the route matches a non-root node', () => {
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6125,9 +6125,9 @@ __metadata:
linkType: hard

"basic-ftp@npm:^5.0.2":
version: 5.0.4
resolution: "basic-ftp@npm:5.0.4"
checksum: 10c0/0bd580652a4f75d5ea8e442e27921ff7089c91764f9eab975235d0b177bb7631339cbf50fb8f4cd5c94087ac6c003a8c80e33076228fd94e23e99d42531e3ac0
version: 5.2.0
resolution: "basic-ftp@npm:5.2.0"
checksum: 10c0/a0f85c01deae0723021f9bf4a7be29378186fa8bba41e74ea11832fe74c187ce90c3599c3cc5ec936581cfd150020e79f4a9ed0ee9fb20b2308e69b045f3a059
languageName: node
linkType: hard

Expand Down
Loading