From 70fe3574a82219f5cd8347a1db8a454fe085505c Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Tue, 2 Jul 2024 18:44:57 +0900 Subject: [PATCH] fix test --- packages/backend/test/e2e/endpoints.ts | 12 ++++++++++-- packages/backend/test/e2e/users.ts | 7 ++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/backend/test/e2e/endpoints.ts b/packages/backend/test/e2e/endpoints.ts index de5e8ba95e..d3861051b5 100644 --- a/packages/backend/test/e2e/endpoints.ts +++ b/packages/backend/test/e2e/endpoints.ts @@ -117,12 +117,20 @@ describe('Endpoints', () => { assert.strictEqual(res.body.birthday, myBirthday); }); - test('名前を空白にできる', async () => { + test('名前を空白のみにした場合nullになる', async () => { const res = await api('i/update', { name: ' ', }, alice); 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 () => { diff --git a/packages/backend/test/e2e/users.ts b/packages/backend/test/e2e/users.ts index 5fb9642367..3458e06384 100644 --- a/packages/backend/test/e2e/users.ts +++ b/packages/backend/test/e2e/users.ts @@ -409,9 +409,6 @@ describe('ユーザー', () => { { parameters: () => ({ name: 'x'.repeat(50) }) }, { parameters: () => ({ name: 'x' }) }, { 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: 'x'.repeat(1500) }) }, { parameters: () => ({ description: 'x' }) }, @@ -468,9 +465,9 @@ describe('ユーザー', () => { { parameters: () => ({ notificationRecieveConfig: {} }) }, { parameters: () => ({ emailNotificationTypes: ['mention', 'reply', 'quote', 'follow', 'receiveFollowRequest'] }) }, { parameters: () => ({ emailNotificationTypes: [] }) }, - ] as const)('を書き換えることができる($#)', async ({ parameters, expect }) => { + ] as const)('を書き換えることができる($#)', async ({ parameters }) => { 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())); });