mirror of
https://codeberg.org/yeentown/barkey
synced 2024-11-21 17:55:11 +00:00
fix unit tests
This commit is contained in:
parent
a6befca845
commit
10d3d9f382
5 changed files with 36 additions and 25 deletions
|
@ -168,13 +168,13 @@ id: 'aidx'
|
|||
#outgoingAddressFamily: ipv4
|
||||
|
||||
# Amount of characters that can be used when writing notes. Longer notes will be rejected. (minimum: 1)
|
||||
maxNoteLength: 3000
|
||||
#maxNoteLength: 3000
|
||||
# Amount of characters that will be saved for remote notes. Longer notes will be truncated to this length. (minimum: 1)
|
||||
maxRemoteNoteLength: 100000
|
||||
#maxRemoteNoteLength: 100000
|
||||
# Amount of characters that can be used when writing media descriptions (alt text). Longer descriptions will be rejected. (minimum: 1)
|
||||
maxAltTextLength: 20000
|
||||
#maxAltTextLength: 20000
|
||||
# Amount of characters that will be saved for remote media descriptions (alt text). Longer descriptions will be truncated to this length. (minimum: 1)
|
||||
maxRemoteAltTextLength: 100000
|
||||
#maxRemoteAltTextLength: 100000
|
||||
|
||||
# Proxy for HTTP/HTTPS
|
||||
#proxy: http://127.0.0.1:3128
|
||||
|
|
|
@ -179,6 +179,15 @@ id: 'aidx'
|
|||
# IP address family used for outgoing request (ipv4, ipv6 or dual)
|
||||
#outgoingAddressFamily: ipv4
|
||||
|
||||
# Amount of characters that can be used when writing notes. Longer notes will be rejected. (minimum: 1)
|
||||
#maxNoteLength: 3000
|
||||
# Amount of characters that will be saved for remote notes. Longer notes will be truncated to this length. (minimum: 1)
|
||||
#maxRemoteNoteLength: 100000
|
||||
# Amount of characters that can be used when writing media descriptions (alt text). Longer descriptions will be rejected. (minimum: 1)
|
||||
#maxAltTextLength: 20000
|
||||
# Amount of characters that will be saved for remote media descriptions (alt text). Longer descriptions will be truncated to this length. (minimum: 1)
|
||||
#maxRemoteAltTextLength: 100000
|
||||
|
||||
# Proxy for HTTP/HTTPS
|
||||
#proxy: http://127.0.0.1:3128
|
||||
|
||||
|
|
|
@ -250,14 +250,14 @@ id: 'aidx'
|
|||
# IP address family used for outgoing request (ipv4, ipv6 or dual)
|
||||
#outgoingAddressFamily: ipv4
|
||||
|
||||
# Amount of characters that can be used when writing notes. Longer notes will be rejected. (maximum: 100000, minimum: 1)
|
||||
maxNoteLength: 3000
|
||||
# Amount of characters that will be saved for remote notes. Longer notes will be truncated to this length. (maximum: 100000, minimum: 1)
|
||||
maxRemoteNoteLength: 100000
|
||||
# Amount of characters that can be used when writing notes. Longer notes will be rejected. (minimum: 1)
|
||||
#maxNoteLength: 3000
|
||||
# Amount of characters that will be saved for remote notes. Longer notes will be truncated to this length. (minimum: 1)
|
||||
#maxRemoteNoteLength: 100000
|
||||
# Amount of characters that can be used when writing media descriptions (alt text). Longer descriptions will be rejected. (minimum: 1)
|
||||
maxAltTextLength: 20000
|
||||
#maxAltTextLength: 20000
|
||||
# Amount of characters that will be saved for remote media descriptions (alt text). Longer descriptions will be truncated to this length. (minimum: 1)
|
||||
maxRemoteAltTextLength: 100000
|
||||
#maxRemoteAltTextLength: 100000
|
||||
|
||||
# Proxy for HTTP/HTTPS
|
||||
#proxy: http://127.0.0.1:3128
|
||||
|
|
|
@ -261,14 +261,14 @@ id: 'aidx'
|
|||
# IP address family used for outgoing request (ipv4, ipv6 or dual)
|
||||
#outgoingAddressFamily: ipv4
|
||||
|
||||
# Amount of characters that can be used when writing notes. Longer notes will be rejected. (maximum: 100000, minimum: 1)
|
||||
maxNoteLength: 3000
|
||||
# Amount of characters that will be saved for remote notes. Longer notes will be truncated to this length. (maximum: 100000, minimum: 1)
|
||||
maxRemoteNoteLength: 100000
|
||||
# Amount of characters that can be used when writing notes. Longer notes will be rejected. (minimum: 1)
|
||||
#maxNoteLength: 3000
|
||||
# Amount of characters that will be saved for remote notes. Longer notes will be truncated to this length. (minimum: 1)
|
||||
#maxRemoteNoteLength: 100000
|
||||
# Amount of characters that can be used when writing media descriptions (alt text). Longer descriptions will be rejected. (minimum: 1)
|
||||
maxAltTextLength: 20000
|
||||
#maxAltTextLength: 20000
|
||||
# Amount of characters that will be saved for remote media descriptions (alt text). Longer descriptions will be truncated to this length. (minimum: 1)
|
||||
maxRemoteAltTextLength: 100000
|
||||
#maxRemoteAltTextLength: 100000
|
||||
|
||||
# Proxy for HTTP/HTTPS
|
||||
#proxy: http://127.0.0.1:3128
|
||||
|
|
|
@ -5,15 +5,12 @@
|
|||
|
||||
process.env.NODE_ENV = 'test';
|
||||
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { dirname } from 'node:path';
|
||||
import { describe, test, expect } from '@jest/globals';
|
||||
import { loadConfig } from '@/config.js';
|
||||
import { getValidator } from '../../../../../test/prelude/get-api-validator.js';
|
||||
import { paramDef } from './create.js';
|
||||
|
||||
const _filename = fileURLToPath(import.meta.url);
|
||||
const _dirname = dirname(_filename);
|
||||
const config = loadConfig();
|
||||
|
||||
const VALID = true;
|
||||
const INVALID = false;
|
||||
|
@ -21,7 +18,12 @@ const INVALID = false;
|
|||
describe('api:notes/create', () => {
|
||||
describe('validation', () => {
|
||||
const v = getValidator(paramDef);
|
||||
const tooLong = readFile(_dirname + '/../../../../../test/resources/misskey.svg', 'utf-8');
|
||||
const tooLong = (limit: number) => {
|
||||
const arr: string[] = [''];
|
||||
arr.length = limit + 1;
|
||||
arr.fill('a');
|
||||
return arr.join('');
|
||||
};
|
||||
|
||||
test('reject empty', () => {
|
||||
const valid = v({ });
|
||||
|
@ -71,8 +73,8 @@ describe('api:notes/create', () => {
|
|||
.toBe(INVALID);
|
||||
});
|
||||
|
||||
test('over 500 characters cw', async () => {
|
||||
expect(v({ text: 'Body', cw: await tooLong }))
|
||||
test('over max characters cw', async () => {
|
||||
expect(v({ text: '', cw: tooLong(config.maxNoteLength) }))
|
||||
.toBe(INVALID);
|
||||
});
|
||||
});
|
||||
|
@ -220,7 +222,7 @@ describe('api:notes/create', () => {
|
|||
});
|
||||
|
||||
test('reject poll with too long choice', async () => {
|
||||
expect(v({ poll: { choices: [await tooLong, '2'] } }))
|
||||
expect(v({ poll: { choices: [tooLong(config.maxNoteLength), '2'] } }))
|
||||
.toBe(INVALID);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue