test(backend): refactor tests (#13499)

* test(backend): refactor tests

* fix: failed test
This commit is contained in:
zyoshoka
2024-03-03 20:15:35 +09:00
committed by GitHub
parent efda2e9baa
commit 38837bd388
24 changed files with 1270 additions and 1297 deletions

View File

@@ -79,6 +79,7 @@ describe('Endpoints', () => {
test('クエリをインジェクションできない', async () => {
const res = await api('signin', {
username: 'test1',
// @ts-expect-error password must be string
password: {
$gt: '',
},
@@ -103,7 +104,7 @@ describe('Endpoints', () => {
const myLocation = '七森中';
const myBirthday = '2000-09-07';
const res = await api('/i/update', {
const res = await api('i/update', {
name: myName,
location: myLocation,
birthday: myBirthday,
@@ -117,7 +118,7 @@ describe('Endpoints', () => {
});
test('名前を空白にできる', async () => {
const res = await api('/i/update', {
const res = await api('i/update', {
name: ' ',
}, alice);
assert.strictEqual(res.status, 200);
@@ -125,11 +126,11 @@ describe('Endpoints', () => {
});
test('誕生日の設定を削除できる', async () => {
await api('/i/update', {
await api('i/update', {
birthday: '2000-09-07',
}, alice);
const res = await api('/i/update', {
const res = await api('i/update', {
birthday: null,
}, alice);
@@ -139,7 +140,7 @@ describe('Endpoints', () => {
});
test('不正な誕生日の形式で怒られる', async () => {
const res = await api('/i/update', {
const res = await api('i/update', {
birthday: '2000/09/07',
}, alice);
assert.strictEqual(res.status, 400);
@@ -148,7 +149,7 @@ describe('Endpoints', () => {
describe('users/show', () => {
test('ユーザーが取得できる', async () => {
const res = await api('/users/show', {
const res = await api('users/show', {
userId: alice.id,
}, alice);
@@ -158,14 +159,14 @@ describe('Endpoints', () => {
});
test('ユーザーが存在しなかったら怒る', async () => {
const res = await api('/users/show', {
const res = await api('users/show', {
userId: '000000000000000000000000',
});
assert.strictEqual(res.status, 404);
});
test('間違ったIDで怒られる', async () => {
const res = await api('/users/show', {
const res = await api('users/show', {
userId: 'kyoppie',
});
assert.strictEqual(res.status, 404);
@@ -178,7 +179,7 @@ describe('Endpoints', () => {
text: 'test',
});
const res = await api('/notes/show', {
const res = await api('notes/show', {
noteId: myPost.id,
}, alice);
@@ -189,14 +190,14 @@ describe('Endpoints', () => {
});
test('投稿が存在しなかったら怒る', async () => {
const res = await api('/notes/show', {
const res = await api('notes/show', {
noteId: '000000000000000000000000',
});
assert.strictEqual(res.status, 400);
});
test('間違ったIDで怒られる', async () => {
const res = await api('/notes/show', {
const res = await api('notes/show', {
noteId: 'kyoppie',
});
assert.strictEqual(res.status, 400);
@@ -207,14 +208,14 @@ describe('Endpoints', () => {
test('リアクションできる', async () => {
const bobPost = await post(bob, { text: 'hi' });
const res = await api('/notes/reactions/create', {
const res = await api('notes/reactions/create', {
noteId: bobPost.id,
reaction: '🚀',
}, alice);
assert.strictEqual(res.status, 204);
const resNote = await api('/notes/show', {
const resNote = await api('notes/show', {
noteId: bobPost.id,
}, alice);
@@ -225,7 +226,7 @@ describe('Endpoints', () => {
test('自分の投稿にもリアクションできる', async () => {
const myPost = await post(alice, { text: 'hi' });
const res = await api('/notes/reactions/create', {
const res = await api('notes/reactions/create', {
noteId: myPost.id,
reaction: '🚀',
}, alice);
@@ -236,19 +237,19 @@ describe('Endpoints', () => {
test('二重にリアクションすると上書きされる', async () => {
const bobPost = await post(bob, { text: 'hi' });
await api('/notes/reactions/create', {
await api('notes/reactions/create', {
noteId: bobPost.id,
reaction: '🥰',
}, alice);
const res = await api('/notes/reactions/create', {
const res = await api('notes/reactions/create', {
noteId: bobPost.id,
reaction: '🚀',
}, alice);
assert.strictEqual(res.status, 204);
const resNote = await api('/notes/show', {
const resNote = await api('notes/show', {
noteId: bobPost.id,
}, alice);
@@ -257,7 +258,7 @@ describe('Endpoints', () => {
});
test('存在しない投稿にはリアクションできない', async () => {
const res = await api('/notes/reactions/create', {
const res = await api('notes/reactions/create', {
noteId: '000000000000000000000000',
reaction: '🚀',
}, alice);
@@ -266,13 +267,14 @@ describe('Endpoints', () => {
});
test('空のパラメータで怒られる', async () => {
const res = await api('/notes/reactions/create', {}, alice);
// @ts-expect-error param must not be empty
const res = await api('notes/reactions/create', {}, alice);
assert.strictEqual(res.status, 400);
});
test('間違ったIDで怒られる', async () => {
const res = await api('/notes/reactions/create', {
const res = await api('notes/reactions/create', {
noteId: 'kyoppie',
reaction: '🚀',
}, alice);
@@ -283,7 +285,7 @@ describe('Endpoints', () => {
describe('following/create', () => {
test('フォローできる', async () => {
const res = await api('/following/create', {
const res = await api('following/create', {
userId: alice.id,
}, bob);
@@ -301,7 +303,7 @@ describe('Endpoints', () => {
});
test('既にフォローしている場合は怒る', async () => {
const res = await api('/following/create', {
const res = await api('following/create', {
userId: alice.id,
}, bob);
@@ -309,7 +311,7 @@ describe('Endpoints', () => {
});
test('存在しないユーザーはフォローできない', async () => {
const res = await api('/following/create', {
const res = await api('following/create', {
userId: '000000000000000000000000',
}, alice);
@@ -317,7 +319,7 @@ describe('Endpoints', () => {
});
test('自分自身はフォローできない', async () => {
const res = await api('/following/create', {
const res = await api('following/create', {
userId: alice.id,
}, alice);
@@ -325,13 +327,14 @@ describe('Endpoints', () => {
});
test('空のパラメータで怒られる', async () => {
const res = await api('/following/create', {}, alice);
// @ts-expect-error params must not be empty
const res = await api('following/create', {}, alice);
assert.strictEqual(res.status, 400);
});
test('間違ったIDで怒られる', async () => {
const res = await api('/following/create', {
const res = await api('following/create', {
userId: 'foo',
}, alice);
@@ -341,11 +344,11 @@ describe('Endpoints', () => {
describe('following/delete', () => {
test('フォロー解除できる', async () => {
await api('/following/create', {
await api('following/create', {
userId: alice.id,
}, bob);
const res = await api('/following/delete', {
const res = await api('following/delete', {
userId: alice.id,
}, bob);
@@ -363,7 +366,7 @@ describe('Endpoints', () => {
});
test('フォローしていない場合は怒る', async () => {
const res = await api('/following/delete', {
const res = await api('following/delete', {
userId: alice.id,
}, bob);
@@ -371,7 +374,7 @@ describe('Endpoints', () => {
});
test('存在しないユーザーはフォロー解除できない', async () => {
const res = await api('/following/delete', {
const res = await api('following/delete', {
userId: '000000000000000000000000',
}, alice);
@@ -379,7 +382,7 @@ describe('Endpoints', () => {
});
test('自分自身はフォロー解除できない', async () => {
const res = await api('/following/delete', {
const res = await api('following/delete', {
userId: alice.id,
}, alice);
@@ -387,13 +390,14 @@ describe('Endpoints', () => {
});
test('空のパラメータで怒られる', async () => {
const res = await api('/following/delete', {}, alice);
// @ts-expect-error params must not be empty
const res = await api('following/delete', {}, alice);
assert.strictEqual(res.status, 400);
});
test('間違ったIDで怒られる', async () => {
const res = await api('/following/delete', {
const res = await api('following/delete', {
userId: 'kyoppie',
}, alice);
@@ -403,20 +407,20 @@ describe('Endpoints', () => {
describe('channels/search', () => {
test('空白検索で一覧を取得できる', async () => {
await api('/channels/create', {
await api('channels/create', {
name: 'aaa',
description: 'bbb',
}, bob);
await api('/channels/create', {
await api('channels/create', {
name: 'ccc1',
description: 'ddd1',
}, bob);
await api('/channels/create', {
await api('channels/create', {
name: 'ccc2',
description: 'ddd2',
}, bob);
const res = await api('/channels/search', {
const res = await api('channels/search', {
query: '',
}, bob);
@@ -425,7 +429,7 @@ describe('Endpoints', () => {
assert.strictEqual(res.body.length, 3);
});
test('名前のみの検索で名前を検索できる', async () => {
const res = await api('/channels/search', {
const res = await api('channels/search', {
query: 'aaa',
type: 'nameOnly',
}, bob);
@@ -436,7 +440,7 @@ describe('Endpoints', () => {
assert.strictEqual(res.body[0].name, 'aaa');
});
test('名前のみの検索で名前を複数検索できる', async () => {
const res = await api('/channels/search', {
const res = await api('channels/search', {
query: 'ccc',
type: 'nameOnly',
}, bob);
@@ -446,7 +450,7 @@ describe('Endpoints', () => {
assert.strictEqual(res.body.length, 2);
});
test('名前のみの検索で説明は検索できない', async () => {
const res = await api('/channels/search', {
const res = await api('channels/search', {
query: 'bbb',
type: 'nameOnly',
}, bob);
@@ -456,7 +460,7 @@ describe('Endpoints', () => {
assert.strictEqual(res.body.length, 0);
});
test('名前と説明の検索で名前を検索できる', async () => {
const res = await api('/channels/search', {
const res = await api('channels/search', {
query: 'ccc1',
}, bob);
@@ -466,7 +470,7 @@ describe('Endpoints', () => {
assert.strictEqual(res.body[0].name, 'ccc1');
});
test('名前と説明での検索で説明を検索できる', async () => {
const res = await api('/channels/search', {
const res = await api('channels/search', {
query: 'ddd1',
}, bob);
@@ -476,7 +480,7 @@ describe('Endpoints', () => {
assert.strictEqual(res.body[0].name, 'ccc1');
});
test('名前と説明の検索で名前を複数検索できる', async () => {
const res = await api('/channels/search', {
const res = await api('channels/search', {
query: 'ccc',
}, bob);
@@ -485,7 +489,7 @@ describe('Endpoints', () => {
assert.strictEqual(res.body.length, 2);
});
test('名前と説明での検索で説明を複数検索できる', async () => {
const res = await api('/channels/search', {
const res = await api('channels/search', {
query: 'ddd',
}, bob);
@@ -506,7 +510,7 @@ describe('Endpoints', () => {
await uploadFile(alice, {
blob: new Blob([new Uint8Array(1024)]),
});
const res = await api('/drive', {}, alice);
const res = await api('drive', {}, alice);
assert.strictEqual(res.status, 200);
assert.strictEqual(typeof res.body === 'object' && !Array.isArray(res.body), true);
expect(res.body).toHaveProperty('usage', 1792);
@@ -519,7 +523,7 @@ describe('Endpoints', () => {
assert.strictEqual(res.status, 200);
assert.strictEqual(typeof res.body === 'object' && !Array.isArray(res.body), true);
assert.strictEqual(res.body.name, 'Lenna.jpg');
assert.strictEqual(res.body!.name, 'Lenna.jpg');
});
test('ファイルに名前を付けられる', async () => {
@@ -527,7 +531,7 @@ describe('Endpoints', () => {
assert.strictEqual(res.status, 200);
assert.strictEqual(typeof res.body === 'object' && !Array.isArray(res.body), true);
assert.strictEqual(res.body.name, 'Belmond.jpg');
assert.strictEqual(res.body!.name, 'Belmond.jpg');
});
test('ファイルに名前を付けられるが、拡張子は正しいものになる', async () => {
@@ -535,11 +539,12 @@ describe('Endpoints', () => {
assert.strictEqual(res.status, 200);
assert.strictEqual(typeof res.body === 'object' && !Array.isArray(res.body), true);
assert.strictEqual(res.body.name, 'Belmond.png.jpg');
assert.strictEqual(res.body!.name, 'Belmond.png.jpg');
});
test('ファイル無しで怒られる', async () => {
const res = await api('/drive/files/create', {}, alice);
// @ts-expect-error params must not be empty
const res = await api('drive/files/create', {}, alice);
assert.strictEqual(res.status, 400);
});
@@ -549,14 +554,14 @@ describe('Endpoints', () => {
assert.strictEqual(res.status, 200);
assert.strictEqual(typeof res.body === 'object' && !Array.isArray(res.body), true);
assert.strictEqual(res.body.name, 'image.svg');
assert.strictEqual(res.body.type, 'image/svg+xml');
assert.strictEqual(res.body!.name, 'image.svg');
assert.strictEqual(res.body!.type, 'image/svg+xml');
});
for (const type of ['webp', 'avif']) {
const mediaType = `image/${type}`;
const getWebpublicType = async (user: any, fileId: string): Promise<string> => {
const getWebpublicType = async (user: misskey.entities.SignupResponse, fileId: string): Promise<string> => {
// drive/files/create does not expose webpublicType directly, so get it by posting it
const res = await post(user, {
text: mediaType,
@@ -573,10 +578,10 @@ describe('Endpoints', () => {
const res = await uploadFile(alice, { path });
assert.strictEqual(res.status, 200);
assert.strictEqual(res.body.name, path);
assert.strictEqual(res.body.type, mediaType);
assert.strictEqual(res.body!.name, path);
assert.strictEqual(res.body!.type, mediaType);
const webpublicType = await getWebpublicType(alice, res.body.id);
const webpublicType = await getWebpublicType(alice, res.body!.id);
assert.strictEqual(webpublicType, 'image/webp');
});
@@ -584,10 +589,10 @@ describe('Endpoints', () => {
const path = `without-alpha.${type}`;
const res = await uploadFile(alice, { path });
assert.strictEqual(res.status, 200);
assert.strictEqual(res.body.name, path);
assert.strictEqual(res.body.type, mediaType);
assert.strictEqual(res.body!.name, path);
assert.strictEqual(res.body!.type, mediaType);
const webpublicType = await getWebpublicType(alice, res.body.id);
const webpublicType = await getWebpublicType(alice, res.body!.id);
assert.strictEqual(webpublicType, 'image/webp');
});
}
@@ -598,8 +603,8 @@ describe('Endpoints', () => {
const file = (await uploadFile(alice)).body;
const newName = 'いちごパスタ.png';
const res = await api('/drive/files/update', {
fileId: file.id,
const res = await api('drive/files/update', {
fileId: file!.id,
name: newName,
}, alice);
@@ -611,8 +616,8 @@ describe('Endpoints', () => {
test('他人のファイルは更新できない', async () => {
const file = (await uploadFile(alice)).body;
const res = await api('/drive/files/update', {
fileId: file.id,
const res = await api('drive/files/update', {
fileId: file!.id,
name: 'いちごパスタ.png',
}, bob);
@@ -621,12 +626,12 @@ describe('Endpoints', () => {
test('親フォルダを更新できる', async () => {
const file = (await uploadFile(alice)).body;
const folder = (await api('/drive/folders/create', {
const folder = (await api('drive/folders/create', {
name: 'test',
}, alice)).body;
const res = await api('/drive/files/update', {
fileId: file.id,
const res = await api('drive/files/update', {
fileId: file!.id,
folderId: folder.id,
}, alice);
@@ -638,17 +643,17 @@ describe('Endpoints', () => {
test('親フォルダを無しにできる', async () => {
const file = (await uploadFile(alice)).body;
const folder = (await api('/drive/folders/create', {
const folder = (await api('drive/folders/create', {
name: 'test',
}, alice)).body;
await api('/drive/files/update', {
fileId: file.id,
await api('drive/files/update', {
fileId: file!.id,
folderId: folder.id,
}, alice);
const res = await api('/drive/files/update', {
fileId: file.id,
const res = await api('drive/files/update', {
fileId: file!.id,
folderId: null,
}, alice);
@@ -659,12 +664,12 @@ describe('Endpoints', () => {
test('他人のフォルダには入れられない', async () => {
const file = (await uploadFile(alice)).body;
const folder = (await api('/drive/folders/create', {
const folder = (await api('drive/folders/create', {
name: 'test',
}, bob)).body;
const res = await api('/drive/files/update', {
fileId: file.id,
const res = await api('drive/files/update', {
fileId: file!.id,
folderId: folder.id,
}, alice);
@@ -674,8 +679,8 @@ describe('Endpoints', () => {
test('存在しないフォルダで怒られる', async () => {
const file = (await uploadFile(alice)).body;
const res = await api('/drive/files/update', {
fileId: file.id,
const res = await api('drive/files/update', {
fileId: file!.id,
folderId: '000000000000000000000000',
}, alice);
@@ -685,8 +690,8 @@ describe('Endpoints', () => {
test('不正なフォルダIDで怒られる', async () => {
const file = (await uploadFile(alice)).body;
const res = await api('/drive/files/update', {
fileId: file.id,
const res = await api('drive/files/update', {
fileId: file!.id,
folderId: 'foo',
}, alice);
@@ -694,7 +699,7 @@ describe('Endpoints', () => {
});
test('ファイルが存在しなかったら怒る', async () => {
const res = await api('/drive/files/update', {
const res = await api('drive/files/update', {
fileId: '000000000000000000000000',
name: 'いちごパスタ.png',
}, alice);
@@ -706,8 +711,8 @@ describe('Endpoints', () => {
const file = (await uploadFile(alice)).body;
const newName = '';
const res = await api('/drive/files/update', {
fileId: file.id,
const res = await api('drive/files/update', {
fileId: file!.id,
name: newName,
}, alice);
@@ -715,7 +720,7 @@ describe('Endpoints', () => {
});
test('間違ったIDで怒られる', async () => {
const res = await api('/drive/files/update', {
const res = await api('drive/files/update', {
fileId: 'kyoppie',
name: 'いちごパスタ.png',
}, alice);
@@ -726,7 +731,7 @@ describe('Endpoints', () => {
describe('drive/folders/create', () => {
test('フォルダを作成できる', async () => {
const res = await api('/drive/folders/create', {
const res = await api('drive/folders/create', {
name: 'test',
}, alice);
@@ -738,11 +743,11 @@ describe('Endpoints', () => {
describe('drive/folders/update', () => {
test('名前を更新できる', async () => {
const folder = (await api('/drive/folders/create', {
const folder = (await api('drive/folders/create', {
name: 'test',
}, alice)).body;
const res = await api('/drive/folders/update', {
const res = await api('drive/folders/update', {
folderId: folder.id,
name: 'new name',
}, alice);
@@ -753,11 +758,11 @@ describe('Endpoints', () => {
});
test('他人のフォルダを更新できない', async () => {
const folder = (await api('/drive/folders/create', {
const folder = (await api('drive/folders/create', {
name: 'test',
}, bob)).body;
const res = await api('/drive/folders/update', {
const res = await api('drive/folders/update', {
folderId: folder.id,
name: 'new name',
}, alice);
@@ -766,14 +771,14 @@ describe('Endpoints', () => {
});
test('親フォルダを更新できる', async () => {
const folder = (await api('/drive/folders/create', {
const folder = (await api('drive/folders/create', {
name: 'test',
}, alice)).body;
const parentFolder = (await api('/drive/folders/create', {
const parentFolder = (await api('drive/folders/create', {
name: 'parent',
}, alice)).body;
const res = await api('/drive/folders/update', {
const res = await api('drive/folders/update', {
folderId: folder.id,
parentId: parentFolder.id,
}, alice);
@@ -784,18 +789,18 @@ describe('Endpoints', () => {
});
test('親フォルダを無しに更新できる', async () => {
const folder = (await api('/drive/folders/create', {
const folder = (await api('drive/folders/create', {
name: 'test',
}, alice)).body;
const parentFolder = (await api('/drive/folders/create', {
const parentFolder = (await api('drive/folders/create', {
name: 'parent',
}, alice)).body;
await api('/drive/folders/update', {
await api('drive/folders/update', {
folderId: folder.id,
parentId: parentFolder.id,
}, alice);
const res = await api('/drive/folders/update', {
const res = await api('drive/folders/update', {
folderId: folder.id,
parentId: null,
}, alice);
@@ -806,14 +811,14 @@ describe('Endpoints', () => {
});
test('他人のフォルダを親フォルダに設定できない', async () => {
const folder = (await api('/drive/folders/create', {
const folder = (await api('drive/folders/create', {
name: 'test',
}, alice)).body;
const parentFolder = (await api('/drive/folders/create', {
const parentFolder = (await api('drive/folders/create', {
name: 'parent',
}, bob)).body;
const res = await api('/drive/folders/update', {
const res = await api('drive/folders/update', {
folderId: folder.id,
parentId: parentFolder.id,
}, alice);
@@ -822,18 +827,18 @@ describe('Endpoints', () => {
});
test('フォルダが循環するような構造にできない', async () => {
const folder = (await api('/drive/folders/create', {
const folder = (await api('drive/folders/create', {
name: 'test',
}, alice)).body;
const parentFolder = (await api('/drive/folders/create', {
const parentFolder = (await api('drive/folders/create', {
name: 'parent',
}, alice)).body;
await api('/drive/folders/update', {
await api('drive/folders/update', {
folderId: parentFolder.id,
parentId: folder.id,
}, alice);
const res = await api('/drive/folders/update', {
const res = await api('drive/folders/update', {
folderId: folder.id,
parentId: parentFolder.id,
}, alice);
@@ -842,25 +847,25 @@ describe('Endpoints', () => {
});
test('フォルダが循環するような構造にできない(再帰的)', async () => {
const folderA = (await api('/drive/folders/create', {
const folderA = (await api('drive/folders/create', {
name: 'test',
}, alice)).body;
const folderB = (await api('/drive/folders/create', {
const folderB = (await api('drive/folders/create', {
name: 'test',
}, alice)).body;
const folderC = (await api('/drive/folders/create', {
const folderC = (await api('drive/folders/create', {
name: 'test',
}, alice)).body;
await api('/drive/folders/update', {
await api('drive/folders/update', {
folderId: folderB.id,
parentId: folderA.id,
}, alice);
await api('/drive/folders/update', {
await api('drive/folders/update', {
folderId: folderC.id,
parentId: folderB.id,
}, alice);
const res = await api('/drive/folders/update', {
const res = await api('drive/folders/update', {
folderId: folderA.id,
parentId: folderC.id,
}, alice);
@@ -869,11 +874,11 @@ describe('Endpoints', () => {
});
test('フォルダが循環するような構造にできない(自身)', async () => {
const folderA = (await api('/drive/folders/create', {
const folderA = (await api('drive/folders/create', {
name: 'test',
}, alice)).body;
const res = await api('/drive/folders/update', {
const res = await api('drive/folders/update', {
folderId: folderA.id,
parentId: folderA.id,
}, alice);
@@ -882,11 +887,11 @@ describe('Endpoints', () => {
});
test('存在しない親フォルダを設定できない', async () => {
const folder = (await api('/drive/folders/create', {
const folder = (await api('drive/folders/create', {
name: 'test',
}, alice)).body;
const res = await api('/drive/folders/update', {
const res = await api('drive/folders/update', {
folderId: folder.id,
parentId: '000000000000000000000000',
}, alice);
@@ -895,11 +900,11 @@ describe('Endpoints', () => {
});
test('不正な親フォルダIDで怒られる', async () => {
const folder = (await api('/drive/folders/create', {
const folder = (await api('drive/folders/create', {
name: 'test',
}, alice)).body;
const res = await api('/drive/folders/update', {
const res = await api('drive/folders/update', {
folderId: folder.id,
parentId: 'foo',
}, alice);
@@ -908,7 +913,7 @@ describe('Endpoints', () => {
});
test('存在しないフォルダを更新できない', async () => {
const res = await api('/drive/folders/update', {
const res = await api('drive/folders/update', {
folderId: '000000000000000000000000',
}, alice);
@@ -916,7 +921,7 @@ describe('Endpoints', () => {
});
test('不正なフォルダIDで怒られる', async () => {
const res = await api('/drive/folders/update', {
const res = await api('drive/folders/update', {
folderId: 'foo',
}, alice);
@@ -937,7 +942,7 @@ describe('Endpoints', () => {
visibleUserIds: [alice.id],
});
const res = await api('/notes/replies', {
const res = await api('notes/replies', {
noteId: alicePost.id,
}, carol);
@@ -949,7 +954,7 @@ describe('Endpoints', () => {
describe('notes/timeline', () => {
test('フォロワー限定投稿が含まれる', async () => {
await api('/following/create', {
await api('following/create', {
userId: carol.id,
}, dave);
@@ -958,7 +963,7 @@ describe('Endpoints', () => {
visibility: 'followers',
});
const res = await api('/notes/timeline', {}, dave);
const res = await api('notes/timeline', {}, dave);
assert.strictEqual(res.status, 200);
assert.strictEqual(Array.isArray(res.body), true);
@@ -979,12 +984,12 @@ describe('Endpoints', () => {
test('他者に関するメモを更新できる', async () => {
const memo = '10月まで低浮上とのこと。';
const res1 = await api('/users/update-memo', {
const res1 = await api('users/update-memo', {
memo,
userId: bob.id,
}, alice);
const res2 = await api('/users/show', {
const res2 = await api('users/show', {
userId: bob.id,
}, alice);
assert.strictEqual(res1.status, 204);
@@ -994,12 +999,12 @@ describe('Endpoints', () => {
test('自分に関するメモを更新できる', async () => {
const memo = 'チケットを月末までに買う。';
const res1 = await api('/users/update-memo', {
const res1 = await api('users/update-memo', {
memo,
userId: alice.id,
}, alice);
const res2 = await api('/users/show', {
const res2 = await api('users/show', {
userId: alice.id,
}, alice);
assert.strictEqual(res1.status, 204);
@@ -1009,17 +1014,17 @@ describe('Endpoints', () => {
test('メモを削除できる', async () => {
const memo = '10月まで低浮上とのこと。';
await api('/users/update-memo', {
await api('users/update-memo', {
memo,
userId: bob.id,
}, alice);
await api('/users/update-memo', {
await api('users/update-memo', {
memo: '',
userId: bob.id,
}, alice);
const res = await api('/users/show', {
const res = await api('users/show', {
userId: bob.id,
}, alice);
@@ -1032,21 +1037,21 @@ describe('Endpoints', () => {
const memoCarolToBob = '例の件について今度問いただす。';
await Promise.all([
api('/users/update-memo', {
api('users/update-memo', {
memo: memoAliceToBob,
userId: bob.id,
}, alice),
api('/users/update-memo', {
api('users/update-memo', {
memo: memoCarolToBob,
userId: bob.id,
}, carol),
]);
const [resAlice, resCarol] = await Promise.all([
api('/users/show', {
api('users/show', {
userId: bob.id,
}, alice),
api('/users/show', {
api('users/show', {
userId: bob.id,
}, carol),
]);