From bf939947a3b219a75cd7ac8ade27694c8a927937 Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Mon, 16 Sep 2024 16:33:17 +0200 Subject: Re-enable skipped navigation test (#2329) --- .../__tests__/build-format-file/navigation.test.ts | 125 +++++++++++++++++++++ .../__tests__/build-format-file/navigation.ts | 125 --------------------- 2 files changed, 125 insertions(+), 125 deletions(-) create mode 100644 packages/starlight/__tests__/build-format-file/navigation.test.ts delete mode 100644 packages/starlight/__tests__/build-format-file/navigation.ts diff --git a/packages/starlight/__tests__/build-format-file/navigation.test.ts b/packages/starlight/__tests__/build-format-file/navigation.test.ts new file mode 100644 index 00000000..f91e98a3 --- /dev/null +++ b/packages/starlight/__tests__/build-format-file/navigation.test.ts @@ -0,0 +1,125 @@ +import { describe, expect, test, vi } from 'vitest'; +import { getSidebar } from '../../utils/navigation'; + +vi.mock('astro:content', async () => + (await import('../test-utils')).mockedAstroContent({ + docs: [ + ['index.mdx', { title: 'Home Page' }], + ['environmental-impact.md', { title: 'Eco-friendly docs' }], + ['reference/configuration.mdx', { title: 'Config Reference' }], + ['reference/frontmatter.md', { title: 'Frontmatter Reference' }], + // @ts-expect-error — Using a slug not present in Starlight docs site + ['api/v1/users.md', { title: 'Users API' }], + ['guides/components.mdx', { title: 'Components' }], + ], + }) +); + +describe('getSidebar with build.format = "file"', () => { + test('returns an array of sidebar entries with its file extension', () => { + expect(getSidebar('/index.html', undefined)).toMatchInlineSnapshot(` + [ + { + "attrs": {}, + "badge": undefined, + "href": "/index.html", + "isCurrent": true, + "label": "Home", + "type": "link", + }, + { + "badge": undefined, + "collapsed": false, + "entries": [ + { + "attrs": {}, + "badge": { + "text": "New", + "variant": "success", + }, + "href": "/intro.html", + "isCurrent": false, + "label": "Introduction", + "type": "link", + }, + { + "attrs": {}, + "badge": { + "text": "Deprecated", + "variant": "default", + }, + "href": "/next-steps.html", + "isCurrent": false, + "label": "Next Steps", + "type": "link", + }, + { + "attrs": { + "class": "showcase-link", + "target": "_blank", + }, + "badge": undefined, + "href": "/showcase.html", + "isCurrent": false, + "label": "Showcase", + "type": "link", + }, + { + "attrs": {}, + "badge": undefined, + "href": "https://astro.build/", + "isCurrent": false, + "label": "Astro", + "type": "link", + }, + ], + "label": "Start Here", + "type": "group", + }, + { + "badge": { + "text": "Experimental", + "variant": "default", + }, + "collapsed": false, + "entries": [ + { + "attrs": {}, + "badge": undefined, + "href": "/reference/configuration.html", + "isCurrent": false, + "label": "Config Reference", + "type": "link", + }, + { + "attrs": {}, + "badge": undefined, + "href": "/reference/frontmatter.html", + "isCurrent": false, + "label": "Frontmatter Reference", + "type": "link", + }, + ], + "label": "Reference", + "type": "group", + }, + { + "badge": undefined, + "collapsed": false, + "entries": [ + { + "attrs": {}, + "badge": undefined, + "href": "/api/v1/users.html", + "isCurrent": false, + "label": "Users API", + "type": "link", + }, + ], + "label": "API v1", + "type": "group", + }, + ] + `); + }); +}); diff --git a/packages/starlight/__tests__/build-format-file/navigation.ts b/packages/starlight/__tests__/build-format-file/navigation.ts deleted file mode 100644 index f733049a..00000000 --- a/packages/starlight/__tests__/build-format-file/navigation.ts +++ /dev/null @@ -1,125 +0,0 @@ -import { describe, expect, test, vi } from 'vitest'; -import { getSidebar } from '../../utils/navigation'; - -vi.mock('astro:content', async () => - (await import('../test-utils')).mockedAstroContent({ - docs: [ - ['index.mdx', { title: 'Home Page' }], - ['environmental-impact.md', { title: 'Eco-friendly docs' }], - ['reference/configuration.mdx', { title: 'Config Reference' }], - ['reference/frontmatter.md', { title: 'Frontmatter Reference' }], - // @ts-expect-error — Using a slug not present in Starlight docs site - ['api/v1/users.md', { title: 'Users API' }], - ['guides/components.mdx', { title: 'Components' }], - ], - }) -); - -describe('getSidebar with build.format = "file"', () => { - test('returns an array of sidebar entries with its file extension', () => { - expect(getSidebar('/', undefined)).toMatchInlineSnapshot(` - [ - { - "attrs": {}, - "badge": undefined, - "href": "/index.html", - "isCurrent": true, - "label": "Home", - "type": "link", - }, - { - "badge": undefined, - "collapsed": false, - "entries": [ - { - "attrs": {}, - "badge": { - "text": "New", - "variant": "success", - }, - "href": "/intro.html", - "isCurrent": false, - "label": "Introduction", - "type": "link", - }, - { - "attrs": {}, - "badge": { - "text": "Deprecated", - "variant": "default", - }, - "href": "/next-steps.html", - "isCurrent": false, - "label": "Next Steps", - "type": "link", - }, - { - "attrs": { - "class": "showcase-link", - "target": "_blank", - }, - "badge": undefined, - "href": "/showcase.html", - "isCurrent": false, - "label": "Showcase", - "type": "link", - }, - { - "attrs": {}, - "badge": undefined, - "href": "https://astro.build/", - "isCurrent": false, - "label": "Astro", - "type": "link", - }, - ], - "label": "Start Here", - "type": "group", - }, - { - "badge": { - "text": "Experimental", - "variant": "default", - }, - "collapsed": false, - "entries": [ - { - "attrs": {}, - "badge": undefined, - "href": "/reference/configuration.html", - "isCurrent": false, - "label": "Config Reference", - "type": "link", - }, - { - "attrs": {}, - "badge": undefined, - "href": "/reference/frontmatter.html", - "isCurrent": false, - "label": "Frontmatter Reference", - "type": "link", - }, - ], - "label": "Reference", - "type": "group", - }, - { - "badge": undefined, - "collapsed": false, - "entries": [ - { - "attrs": {}, - "badge": undefined, - "href": "/api/v1/users.html", - "isCurrent": false, - "label": "Users API", - "type": "link", - }, - ], - "label": "API v1", - "type": "group", - }, - ] - `); - }); -}); -- cgit