aboutsummaryrefslogtreecommitdiff
path: root/website/src/docs-path.test.ts
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-07-22 14:58:26 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-07-22 14:59:09 +0300
commitc234f221f9be698bc0501c60459e1ae8e67df6c3 (patch)
tree944b4dec10fada8d93456dc5a85e6bfdb36a8b8b /website/src/docs-path.test.ts
parentef85fa0c7ebb48bb59fe7593af5a67f3e02ff3d4 (diff)
feat(docs): publish versioned release documentation
Diffstat (limited to 'website/src/docs-path.test.ts')
-rw-r--r--website/src/docs-path.test.ts49
1 files changed, 40 insertions, 9 deletions
diff --git a/website/src/docs-path.test.ts b/website/src/docs-path.test.ts
index 26f9a701..0fadb26e 100644
--- a/website/src/docs-path.test.ts
+++ b/website/src/docs-path.test.ts
@@ -1,16 +1,44 @@
import { describe, expect, test } from 'bun:test';
-import { docsChannel, docsPath } from './docs-path';
+import { docsPath, docsRoute, docsTargetHref, docsVersion } from './docs-path';
-describe('docsChannel', () => {
+const scopes = {
+ stable: { locales: { root: ['', 'install'], ja: ['', 'install'] } },
+ preview: { locales: { root: ['', 'install', 'new-page'], ja: ['', 'install'] } },
+ '0.7.4': { locales: { root: ['', 'install'], ja: [''] } },
+};
+
+describe('docsRoute', () => {
+ test.each([
+ ['/docs/', { isDocs: true, locale: undefined, target: 'stable', page: '' }],
+ ['/ja/docs/install/', { isDocs: true, locale: 'ja', target: 'stable', page: 'install' }],
+ ['/docs/preview/new-page/', { isDocs: true, locale: undefined, target: 'preview', page: 'new-page' }],
+ ['/zh-cn/docs/preview/', { isDocs: true, locale: 'zh-cn', target: 'preview', page: '' }],
+ ['/docs/0.7.4/install/', { isDocs: true, locale: undefined, target: '0.7.4', page: 'install' }],
+ ['/ja/docs/0.7.4/', { isDocs: true, locale: 'ja', target: '0.7.4', page: '' }],
+ ['/blog/', { isDocs: false, locale: undefined, target: 'stable', page: '' }],
+ ])('parses %s', (pathname, expected) => {
+ expect(docsRoute(pathname)).toEqual(expected);
+ });
+});
+
+describe('docsVersion', () => {
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);
+ ['/zh-cn/docs/0.7.4/', '0.7.4'],
+ ])('maps %s', (pathname, version) => {
+ expect(docsVersion(pathname)).toBe(version);
+ });
+});
+
+describe('docsTargetHref', () => {
+ test.each([
+ ['/docs/install/', 'preview', '/docs/preview/install/'],
+ ['/ja/docs/install/', '0.7.4', '/ja/docs/0.7.4/'],
+ ['/docs/0.7.4/install/', 'stable', '/docs/install/'],
+ ['/docs/preview/new-page/', '0.7.4', '/docs/0.7.4/'],
+ ])('maps %s to %s', (pathname, target, expected) => {
+ expect(docsTargetHref(docsRoute(pathname), target, scopes)).toBe(expected);
});
});
@@ -25,7 +53,10 @@ describe('docsPath', () => {
['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'],
+ ['_versions/0.7.4/index.mdx', 'docs/0.7.4'],
+ ['_versions/0.7.4/install.mdx', 'docs/0.7.4/install'],
+ ['_versions/0.7.4/ja/index.mdx', 'ja/docs/0.7.4'],
+ ['_versions/0.7.4/zh-cn/install.mdx', 'zh-cn/docs/0.7.4/install'],
])('maps %s to %s', (entry, expected) => {
expect(docsPath({ entry })).toBe(expected);
});