Skip to content

Commit

Permalink
nav group transform tests
Browse files Browse the repository at this point in the history
  • Loading branch information
winkerVSbecks committed Aug 30, 2024
1 parent e42b87f commit 8dbd431
Showing 1 changed file with 95 additions and 0 deletions.
95 changes: 95 additions & 0 deletions src/components/Navigation/transform-nav-groups.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,54 @@ describe("transformNavGroups", () => {
]);
});

test("Sets nested group's order to 999 when not specified", () => {
expect(
transformNavGroups([
{
title: "Storybook",
items: [
{
title: "Modes",
items: [
{
id: "modes.mdx",
slug: "modes",
collection: "modes",
data: {
title: "Story Modes",
sidebar: {
label: "Story Modes",
hide: false,
},
},
},
],
},
],
},
]),
).toEqual([
{
title: "Storybook",
items: [
{
hide: false,
title: "Modes",
order: 999,
items: [
{
hide: false,
label: "Story Modes",
order: 999,
slug: "modes",
},
],
},
],
},
]);
});

test("Sets hide to false when not specified", () => {
expect(
transformNavGroups([
Expand Down Expand Up @@ -388,6 +436,53 @@ describe("transformNavGroups", () => {
]);
});

test("Sets nested group's hide to false when not specified", () => {
expect(
transformNavGroups([
{
title: "Storybook",
items: [
{
title: "Modes",
items: [
{
id: "modes.mdx",
slug: "modes",
collection: "modes",
data: {
title: "Story Modes",
sidebar: {
label: "Story Modes",
},
},
},
],
},
],
},
]),
).toEqual([
{
title: "Storybook",
items: [
{
hide: false,
title: "Modes",
order: 999,
items: [
{
hide: false,
label: "Story Modes",
order: 999,
slug: "modes",
},
],
},
],
},
]);
});

test("transforms and sorts single level groups", () => {
expect(transformNavGroups([mockGroups[0]])).toEqual([
{
Expand Down

0 comments on commit 8dbd431

Please sign in to comment.