Files
dependabot[bot]andTonyRL 6bce9493b5 chore(deps-dev): bump eslint-plugin-unicorn from 71.1.0 to 72.0.0 (#22723)
* chore(deps-dev): bump eslint-plugin-unicorn from 71.1.0 to 72.0.0

Bumps [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn) from 71.1.0 to 72.0.0.
- [Release notes](https://github.com/sindresorhus/eslint-plugin-unicorn/releases)
- [Commits](https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v71.1.0...v72.0.0)

---
updated-dependencies:
- dependency-name: eslint-plugin-unicorn
  dependency-version: 72.0.0
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* style: fix prefer-dom-node-html-methods

* style: fix prefer-split-limit

* style: fix no-unnecessary-string-trim

* style: fix no-multiple-promise-resolver-calls

* style: add v72 preset

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: TonyRL <TonyRL@users.noreply.github.com>
2026-07-15 23:11:15 +08:00

47 lines
1.6 KiB
TypeScript

import type { Next } from 'hono';
import { describe, expect, it } from 'vitest';
import api from '@/api';
import { handler as oneHandler } from '@/api/namespace/one';
import { namespaces } from '@/registry';
const noopNext: Next = () => Promise.resolve();
const createCtx = (param: Record<string, string> = {}) =>
({
req: {
valid: () => param,
},
json: (data: unknown) => data,
}) as any;
describe('api/namespace/one', () => {
const nestedKey = Object.keys(namespaces).find((key) => key.includes('/')) as string;
it('returns a single namespace', async () => {
const result = await oneHandler(createCtx({ namespace: 'test' }), noopNext);
expect(result).toBe(namespaces.test);
});
it('returns a nested namespace', async () => {
expect(nestedKey).toBeDefined();
const [namespace, sub] = nestedKey.split('/', 2);
const result = await oneHandler(createCtx({ namespace, sub }), noopNext);
expect(result).toBe(namespaces[nestedKey]);
});
it('serves a single namespace over HTTP', async () => {
expect(namespaces.github).toBeDefined();
const response = await api.request('/namespace/github');
expect(response.status).toBe(200);
expect(await response.json()).toEqual(namespaces.github);
});
it('serves a nested namespace over HTTP', async () => {
expect(nestedKey).toBeDefined();
const response = await api.request(`/namespace/${nestedKey}`);
expect(response.status).toBe(200);
expect(await response.json()).toEqual(namespaces[nestedKey]);
});
});