✌️
This commit is contained in:
parent
b01a6cbbb7
commit
6b82d3a1d4
2 changed files with 26 additions and 10 deletions
|
|
@ -4,8 +4,9 @@ import * as assert from 'assert';
|
|||
// node-fetch only supports it's own Blob yet
|
||||
// https://github.com/node-fetch/node-fetch/pull/1664
|
||||
import { Blob } from 'node-fetch';
|
||||
import { startServer, signup, post, api, uploadFile, simpleGet } from '../utils.js';
|
||||
import { startServer, signup, post, api, uploadFile, simpleGet, initTestDb } from '../utils.js';
|
||||
import type { INestApplicationContext } from '@nestjs/common';
|
||||
import { User } from '@/models/index.js';
|
||||
|
||||
describe('Endpoints', () => {
|
||||
let app: INestApplicationContext;
|
||||
|
|
@ -289,6 +290,16 @@ describe('Endpoints', () => {
|
|||
}, bob);
|
||||
|
||||
assert.strictEqual(res.status, 200);
|
||||
|
||||
const connection = await initTestDb(false);
|
||||
const Users = connection.getRepository(User);
|
||||
const newBob = await Users.findOneByOrFail({ id: bob.id });
|
||||
assert.strictEqual(newBob.followersCount, 0);
|
||||
assert.strictEqual(newBob.followingCount, 1);
|
||||
const newAlice = await Users.findOneByOrFail({ id: alice.id });
|
||||
assert.strictEqual(newAlice.followersCount, 1);
|
||||
assert.strictEqual(newAlice.followingCount, 0);
|
||||
connection.destroy();
|
||||
});
|
||||
|
||||
test('既にフォローしている場合は怒る', async () => {
|
||||
|
|
@ -341,6 +352,16 @@ describe('Endpoints', () => {
|
|||
}, bob);
|
||||
|
||||
assert.strictEqual(res.status, 200);
|
||||
|
||||
const connection = await initTestDb(false);
|
||||
const Users = connection.getRepository(User);
|
||||
const newBob = await Users.findOneByOrFail({ id: bob.id });
|
||||
assert.strictEqual(newBob.followersCount, 0);
|
||||
assert.strictEqual(newBob.followingCount, 0);
|
||||
const newAlice = await Users.findOneByOrFail({ id: alice.id });
|
||||
assert.strictEqual(newAlice.followersCount, 0);
|
||||
assert.strictEqual(newAlice.followingCount, 0);
|
||||
connection.destroy();
|
||||
});
|
||||
|
||||
test('フォローしていない場合は怒る', async () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue