aboutsummaryrefslogtreecommitdiff
path: root/website/src/docs-path.test.ts
blob: 26f9a7014b3feba2fb9a14627a8e7453f200e7c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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);
  });
});