From ca7ae086e8d6e80f6efc969d541b390328a6d143 Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Tue, 14 Jul 2026 02:41:24 +0300 Subject: fix(website): scope docs search by locale and channel --- website/src/docs-path.test.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 website/src/docs-path.test.ts (limited to 'website/src/docs-path.test.ts') diff --git a/website/src/docs-path.test.ts b/website/src/docs-path.test.ts new file mode 100644 index 00000000..26f9a701 --- /dev/null +++ b/website/src/docs-path.test.ts @@ -0,0 +1,32 @@ +import { describe, expect, test } from 'bun:test'; +import { docsChannel, docsPath } from './docs-path'; + +describe('docsChannel', () => { + test.each([ + ['/docs/', 'stable'], + ['/ja/docs/install/', 'stable'], + ['/zh-cn/docs/', 'stable'], + ['/docs/preview/', 'preview'], + ['/ja/docs/preview/install/', 'preview'], + ['/zh-cn/docs/preview/', 'preview'], + ])('maps %s to %s', (pathname, expected) => { + expect(docsChannel(pathname)).toBe(expected); + }); +}); + +describe('docsPath', () => { + test.each([ + ['index.mdx', 'docs'], + ['install.mdx', 'docs/install'], + ['ja/index.mdx', 'ja/docs'], + ['ja/install.mdx', 'ja/docs/install'], + ['zh-cn/install.mdx', 'zh-cn/docs/install'], + ['preview/index.mdx', 'docs/preview'], + ['preview/install.mdx', 'docs/preview/install'], + ['preview/ja/index.mdx', 'ja/docs/preview'], + ['preview/ja/install.mdx', 'ja/docs/preview/install'], + ['preview/zh-cn/install.mdx', 'zh-cn/docs/preview/install'], + ])('maps %s to %s', (entry, expected) => { + expect(docsPath({ entry })).toBe(expected); + }); +}); -- cgit v1.2.3