This commit is contained in:
kakkokari-gtyih 2024-07-02 18:44:57 +09:00
parent 646750cd98
commit 70fe3574a8
2 changed files with 12 additions and 7 deletions

View File

@ -117,12 +117,20 @@ describe('Endpoints', () => {
assert.strictEqual(res.body.birthday, myBirthday); assert.strictEqual(res.body.birthday, myBirthday);
}); });
test('名前を空白にできる', async () => { test('名前を空白のみにした場合nullになる', async () => {
const res = await api('i/update', { const res = await api('i/update', {
name: ' ', name: ' ',
}, alice); }, alice);
assert.strictEqual(res.status, 200); assert.strictEqual(res.status, 200);
assert.strictEqual(res.body.name, ' '); assert.strictEqual(res.body.name, null);
});
test('名前の前後に空白を入れてもトリムされる', async () => {
const res = await api('i/update', {
name: ' あ い う ',
}, alice);
assert.strictEqual(res.status, 200);
assert.strictEqual(res.body.name, 'あ い う');
}); });
test('誕生日の設定を削除できる', async () => { test('誕生日の設定を削除できる', async () => {

View File

@ -409,9 +409,6 @@ describe('ユーザー', () => {
{ parameters: () => ({ name: 'x'.repeat(50) }) }, { parameters: () => ({ name: 'x'.repeat(50) }) },
{ parameters: () => ({ name: 'x' }) }, { parameters: () => ({ name: 'x' }) },
{ parameters: () => ({ name: 'My name' }) }, { parameters: () => ({ name: 'My name' }) },
{ parameters: () => ({ name: '' }), expect: { name: null } },
{ parameters: () => ({ name: ' name with spaces ' }), expect: { name: 'name with spaces' } },
{ parameters: () => ({ name: ' ' }), expect: { name: null } },
{ parameters: () => ({ description: null }) }, { parameters: () => ({ description: null }) },
{ parameters: () => ({ description: 'x'.repeat(1500) }) }, { parameters: () => ({ description: 'x'.repeat(1500) }) },
{ parameters: () => ({ description: 'x' }) }, { parameters: () => ({ description: 'x' }) },
@ -468,9 +465,9 @@ describe('ユーザー', () => {
{ parameters: () => ({ notificationRecieveConfig: {} }) }, { parameters: () => ({ notificationRecieveConfig: {} }) },
{ parameters: () => ({ emailNotificationTypes: ['mention', 'reply', 'quote', 'follow', 'receiveFollowRequest'] }) }, { parameters: () => ({ emailNotificationTypes: ['mention', 'reply', 'quote', 'follow', 'receiveFollowRequest'] }) },
{ parameters: () => ({ emailNotificationTypes: [] }) }, { parameters: () => ({ emailNotificationTypes: [] }) },
] as const)('を書き換えることができる($#)', async ({ parameters, expect }) => { ] as const)('を書き換えることができる($#)', async ({ parameters }) => {
const response = await successfulApiCall({ endpoint: 'i/update', parameters: parameters(), user: alice }); const response = await successfulApiCall({ endpoint: 'i/update', parameters: parameters(), user: alice });
const expected = { ...meDetailed(alice, true), ...parameters(), ...expect }; const expected = { ...meDetailed(alice, true), ...parameters() };
assert.deepStrictEqual(response, expected, inspect(parameters())); assert.deepStrictEqual(response, expected, inspect(parameters()));
}); });