/* * SPDX-FileCopyrightText: syuilo and misskey-project * SPDX-License-Identifier: AGPL-3.0-only */ process.env.NODE_ENV = 'test'; import * as assert from 'assert'; import { describe, beforeAll, test } from 'vitest'; import { api, castAsError, signup } from '../utils.js'; import type * as misskey from 'misskey-js'; describe('Channel', () => { let alice: misskey.entities.SignupResponse; beforeAll(async () => { alice = await signup({ username: 'alice' }); }); describe('Follow', () => { let channel: misskey.entities.ChannelsCreateResponse; beforeAll(async () => { const res = await api('channels/create', { name: 'follow-test-channel' }, alice); channel = res.body; }); test('フォローしているチャンネルを再度フォローするとALREADY_FOLLOWINGエラーになる', async () => { const res1 = await api('channels/follow', { channelId: channel.id }, alice); assert.strictEqual(res1.status, 204); const res2 = await api('channels/follow', { channelId: channel.id }, alice); assert.strictEqual(res2.status, 400); assert.strictEqual(castAsError(res2.body as any).error.code, 'ALREADY_FOLLOWING'); }); }); });