mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-20 05:55:29 +02:00
fix(backend): correct invalid schema format specifying only required for anyOf (#16089)
* fix(backend): correct invalid schema format specifying only `required` for `anyOf` * refactor(backend): make types derived from `allOf` or `anyOf` more strong
This commit is contained in:
23
packages/backend/src/server/api/endpoints/users/show.test.ts
Normal file
23
packages/backend/src/server/api/endpoints/users/show.test.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
process.env.NODE_ENV = 'test';
|
||||
|
||||
import { getValidator } from '../../../../../test/prelude/get-api-validator.js';
|
||||
import { paramDef } from './show.js';
|
||||
|
||||
const VALID = true;
|
||||
const INVALID = false;
|
||||
|
||||
describe('api:users/show', () => {
|
||||
describe('validation', () => {
|
||||
const v = getValidator(paramDef);
|
||||
|
||||
test('Reject empty', () => expect(v({})).toBe(INVALID));
|
||||
test('Reject host only', () => expect(v({ host: 'misskey.test' })).toBe(INVALID));
|
||||
test('Accept userId only', () => expect(v({ userId: '1' })).toBe(VALID));
|
||||
test('Accept username and host', () => expect(v({ username: 'alice', host: 'misskey.test' })).toBe(VALID));
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user