From 8dbd431533cb7889494dbed8fe542b6b4c6ac489 Mon Sep 17 00:00:00 2001 From: winkerVSbecks Date: Thu, 29 Aug 2024 21:33:10 -0400 Subject: [PATCH] nav group transform tests --- .../Navigation/transform-nav-groups.test.ts | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/src/components/Navigation/transform-nav-groups.test.ts b/src/components/Navigation/transform-nav-groups.test.ts index a144078f..8f4b475a 100644 --- a/src/components/Navigation/transform-nav-groups.test.ts +++ b/src/components/Navigation/transform-nav-groups.test.ts @@ -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([ @@ -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([ {