This commit is contained in:
syuilo 2022-05-21 22:21:41 +09:00
parent 6adc5a33fe
commit 5ad66d3ddd
14 changed files with 201 additions and 201 deletions

View file

@ -1,7 +1,7 @@
process.env.NODE_ENV = 'test'; process.env.NODE_ENV = 'test';
import rndstr from 'rndstr';
import * as assert from 'assert'; import * as assert from 'assert';
import rndstr from 'rndstr';
import { initTestDb } from './utils.js'; import { initTestDb } from './utils.js';
describe('ActivityPub', () => { describe('ActivityPub', () => {
@ -57,8 +57,8 @@ describe('ActivityPub', () => {
const note = await createNote(post.id, resolver, true); const note = await createNote(post.id, resolver, true);
assert.deepStrictEqual(note?.uri, post.id); assert.deepStrictEqual(note?.uri, post.id);
assert.deepStrictEqual(note?.visibility, 'public'); assert.deepStrictEqual(note.visibility, 'public');
assert.deepStrictEqual(note?.text, post.content); assert.deepStrictEqual(note.text, post.content);
}); });
}); });

View file

@ -1,7 +1,7 @@
import * as assert from 'assert'; import * as assert from 'assert';
import httpSignature from 'http-signature';
import { genRsaKeyPair } from '../src/misc/gen-key-pair.js'; import { genRsaKeyPair } from '../src/misc/gen-key-pair.js';
import { createSignedPost, createSignedGet } from '../src/remote/activitypub/ap-request.js'; import { createSignedPost, createSignedGet } from '../src/remote/activitypub/ap-request.js';
import httpSignature from 'http-signature';
export const buildParsedSignature = (signingString: string, signature: string, algorithm: string) => { export const buildParsedSignature = (signingString: string, signature: string, algorithm: string) => {
return { return {
@ -13,7 +13,7 @@ export const buildParsedSignature = (signingString: string, signature: string, a
signature: signature, signature: signature,
}, },
signingString: signingString, signingString: signingString,
algorithm: algorithm?.toUpperCase(), algorithm: algorithm.toUpperCase(),
keyId: 'KeyID', // dummy, not used for verify keyId: 'KeyID', // dummy, not used for verify
}; };
}; };
@ -26,7 +26,7 @@ describe('ap-request', () => {
const activity = { a: 1 }; const activity = { a: 1 };
const body = JSON.stringify(activity); const body = JSON.stringify(activity);
const headers = { const headers = {
'User-Agent': 'UA' 'User-Agent': 'UA',
}; };
const req = createSignedPost({ key, url, body, additionalHeaders: headers }); const req = createSignedPost({ key, url, body, additionalHeaders: headers });
@ -42,7 +42,7 @@ describe('ap-request', () => {
const key = { keyId: 'x', 'privateKeyPem': keypair.privateKey }; const key = { keyId: 'x', 'privateKeyPem': keypair.privateKey };
const url = 'https://example.com/outbox'; const url = 'https://example.com/outbox';
const headers = { const headers = {
'User-Agent': 'UA' 'User-Agent': 'UA',
}; };
const req = createSignedGet({ key, url, additionalHeaders: headers }); const req = createSignedGet({ key, url, additionalHeaders: headers });

View file

@ -61,7 +61,7 @@ describe('API visibility', () => {
const show = async (noteId: any, by: any) => { const show = async (noteId: any, by: any) => {
return await request('/notes/show', { return await request('/notes/show', {
noteId noteId,
}, by); }, by);
}; };

View file

@ -25,7 +25,7 @@ describe('Block', () => {
it('Block作成', async(async () => { it('Block作成', async(async () => {
const res = await request('/blocking/create', { const res = await request('/blocking/create', {
userId: bob.id userId: bob.id,
}, alice); }, alice);
assert.strictEqual(res.status, 200); assert.strictEqual(res.status, 200);

View file

@ -2,7 +2,6 @@ process.env.NODE_ENV = 'test';
import * as assert from 'assert'; import * as assert from 'assert';
import * as lolex from '@sinonjs/fake-timers'; import * as lolex from '@sinonjs/fake-timers';
import { async, initTestDb } from './utils.js';
import TestChart from '../src/services/chart/charts/test.js'; import TestChart from '../src/services/chart/charts/test.js';
import TestGroupedChart from '../src/services/chart/charts/test-grouped.js'; import TestGroupedChart from '../src/services/chart/charts/test-grouped.js';
import TestUniqueChart from '../src/services/chart/charts/test-unique.js'; import TestUniqueChart from '../src/services/chart/charts/test-unique.js';
@ -11,6 +10,7 @@ import * as _TestChart from '../src/services/chart/charts/entities/test.js';
import * as _TestGroupedChart from '../src/services/chart/charts/entities/test-grouped.js'; import * as _TestGroupedChart from '../src/services/chart/charts/entities/test-grouped.js';
import * as _TestUniqueChart from '../src/services/chart/charts/entities/test-unique.js'; import * as _TestUniqueChart from '../src/services/chart/charts/entities/test-unique.js';
import * as _TestIntersectionChart from '../src/services/chart/charts/entities/test-intersection.js'; import * as _TestIntersectionChart from '../src/services/chart/charts/entities/test-intersection.js';
import { async, initTestDb } from './utils.js';
describe('Chart', () => { describe('Chart', () => {
let testChart: TestChart; let testChart: TestChart;
@ -33,7 +33,7 @@ describe('Chart', () => {
testIntersectionChart = new TestIntersectionChart(); testIntersectionChart = new TestIntersectionChart();
clock = lolex.install({ clock = lolex.install({
now: new Date(Date.UTC(2000, 0, 1, 0, 0, 0)) now: new Date(Date.UTC(2000, 0, 1, 0, 0, 0)),
}); });
})); }));
@ -52,7 +52,7 @@ describe('Chart', () => {
foo: { foo: {
dec: [0, 0, 0], dec: [0, 0, 0],
inc: [1, 0, 0], inc: [1, 0, 0],
total: [1, 0, 0] total: [1, 0, 0],
}, },
}); });
@ -60,7 +60,7 @@ describe('Chart', () => {
foo: { foo: {
dec: [0, 0, 0], dec: [0, 0, 0],
inc: [1, 0, 0], inc: [1, 0, 0],
total: [1, 0, 0] total: [1, 0, 0],
}, },
}); });
})); }));
@ -76,7 +76,7 @@ describe('Chart', () => {
foo: { foo: {
dec: [1, 0, 0], dec: [1, 0, 0],
inc: [0, 0, 0], inc: [0, 0, 0],
total: [-1, 0, 0] total: [-1, 0, 0],
}, },
}); });
@ -84,7 +84,7 @@ describe('Chart', () => {
foo: { foo: {
dec: [1, 0, 0], dec: [1, 0, 0],
inc: [0, 0, 0], inc: [0, 0, 0],
total: [-1, 0, 0] total: [-1, 0, 0],
}, },
}); });
})); }));
@ -97,7 +97,7 @@ describe('Chart', () => {
foo: { foo: {
dec: [0, 0, 0], dec: [0, 0, 0],
inc: [0, 0, 0], inc: [0, 0, 0],
total: [0, 0, 0] total: [0, 0, 0],
}, },
}); });
@ -105,7 +105,7 @@ describe('Chart', () => {
foo: { foo: {
dec: [0, 0, 0], dec: [0, 0, 0],
inc: [0, 0, 0], inc: [0, 0, 0],
total: [0, 0, 0] total: [0, 0, 0],
}, },
}); });
})); }));
@ -123,7 +123,7 @@ describe('Chart', () => {
foo: { foo: {
dec: [0, 0, 0], dec: [0, 0, 0],
inc: [3, 0, 0], inc: [3, 0, 0],
total: [3, 0, 0] total: [3, 0, 0],
}, },
}); });
@ -131,7 +131,7 @@ describe('Chart', () => {
foo: { foo: {
dec: [0, 0, 0], dec: [0, 0, 0],
inc: [3, 0, 0], inc: [3, 0, 0],
total: [3, 0, 0] total: [3, 0, 0],
}, },
}); });
})); }));
@ -149,7 +149,7 @@ describe('Chart', () => {
foo: { foo: {
dec: [0, 0, 0], dec: [0, 0, 0],
inc: [1, 0, 0], inc: [1, 0, 0],
total: [1, 0, 0] total: [1, 0, 0],
}, },
}); });
@ -157,7 +157,7 @@ describe('Chart', () => {
foo: { foo: {
dec: [0, 0, 0], dec: [0, 0, 0],
inc: [1, 0, 0], inc: [1, 0, 0],
total: [1, 0, 0] total: [1, 0, 0],
}, },
}); });
})); }));
@ -178,7 +178,7 @@ describe('Chart', () => {
foo: { foo: {
dec: [0, 0, 0], dec: [0, 0, 0],
inc: [1, 1, 0], inc: [1, 1, 0],
total: [2, 1, 0] total: [2, 1, 0],
}, },
}); });
@ -186,7 +186,7 @@ describe('Chart', () => {
foo: { foo: {
dec: [0, 0, 0], dec: [0, 0, 0],
inc: [2, 0, 0], inc: [2, 0, 0],
total: [2, 0, 0] total: [2, 0, 0],
}, },
}); });
})); }));
@ -238,7 +238,7 @@ describe('Chart', () => {
foo: { foo: {
dec: [0, 0, 0], dec: [0, 0, 0],
inc: [1, 0, 1], inc: [1, 0, 1],
total: [2, 1, 1] total: [2, 1, 1],
}, },
}); });
@ -246,7 +246,7 @@ describe('Chart', () => {
foo: { foo: {
dec: [0, 0, 0], dec: [0, 0, 0],
inc: [2, 0, 0], inc: [2, 0, 0],
total: [2, 0, 0] total: [2, 0, 0],
}, },
}); });
})); }));
@ -265,7 +265,7 @@ describe('Chart', () => {
foo: { foo: {
dec: [0, 0, 0], dec: [0, 0, 0],
inc: [0, 0, 0], inc: [0, 0, 0],
total: [1, 1, 1] total: [1, 1, 1],
}, },
}); });
@ -273,7 +273,7 @@ describe('Chart', () => {
foo: { foo: {
dec: [0, 0, 0], dec: [0, 0, 0],
inc: [1, 0, 0], inc: [1, 0, 0],
total: [1, 0, 0] total: [1, 0, 0],
}, },
}); });
})); }));
@ -296,7 +296,7 @@ describe('Chart', () => {
foo: { foo: {
dec: [0, 0, 0], dec: [0, 0, 0],
inc: [1, 0, 0], inc: [1, 0, 0],
total: [2, 1, 1] total: [2, 1, 1],
}, },
}); });
@ -304,7 +304,7 @@ describe('Chart', () => {
foo: { foo: {
dec: [0, 0, 0], dec: [0, 0, 0],
inc: [2, 0, 0], inc: [2, 0, 0],
total: [2, 0, 0] total: [2, 0, 0],
}, },
}); });
})); }));
@ -325,7 +325,7 @@ describe('Chart', () => {
foo: { foo: {
dec: [0, 0, 0], dec: [0, 0, 0],
inc: [1, 0, 0], inc: [1, 0, 0],
total: [1, 0, 0] total: [1, 0, 0],
}, },
}); });
@ -333,7 +333,7 @@ describe('Chart', () => {
foo: { foo: {
dec: [0, 0, 0], dec: [0, 0, 0],
inc: [2, 0, 0], inc: [2, 0, 0],
total: [2, 0, 0] total: [2, 0, 0],
}, },
}); });
})); }));
@ -356,7 +356,7 @@ describe('Chart', () => {
foo: { foo: {
dec: [0, 0, 0], dec: [0, 0, 0],
inc: [1, 0, 0], inc: [1, 0, 0],
total: [1, 0, 0] total: [1, 0, 0],
}, },
}); });
@ -364,7 +364,7 @@ describe('Chart', () => {
foo: { foo: {
dec: [0, 0, 0], dec: [0, 0, 0],
inc: [2, 0, 0], inc: [2, 0, 0],
total: [2, 0, 0] total: [2, 0, 0],
}, },
}); });
})); }));
@ -383,7 +383,7 @@ describe('Chart', () => {
foo: { foo: {
dec: [0, 0, 0], dec: [0, 0, 0],
inc: [1, 0, 0], inc: [1, 0, 0],
total: [1, 0, 0] total: [1, 0, 0],
}, },
}); });
@ -391,7 +391,7 @@ describe('Chart', () => {
foo: { foo: {
dec: [0, 0, 0], dec: [0, 0, 0],
inc: [1, 0, 0], inc: [1, 0, 0],
total: [1, 0, 0] total: [1, 0, 0],
}, },
}); });
@ -399,7 +399,7 @@ describe('Chart', () => {
foo: { foo: {
dec: [0, 0, 0], dec: [0, 0, 0],
inc: [0, 0, 0], inc: [0, 0, 0],
total: [0, 0, 0] total: [0, 0, 0],
}, },
}); });
@ -407,7 +407,7 @@ describe('Chart', () => {
foo: { foo: {
dec: [0, 0, 0], dec: [0, 0, 0],
inc: [0, 0, 0], inc: [0, 0, 0],
total: [0, 0, 0] total: [0, 0, 0],
}, },
}); });
})); }));
@ -493,7 +493,7 @@ describe('Chart', () => {
foo: { foo: {
dec: [0, 0, 0], dec: [0, 0, 0],
inc: [0, 0, 0], inc: [0, 0, 0],
total: [1, 0, 0] total: [1, 0, 0],
}, },
}); });
@ -501,7 +501,7 @@ describe('Chart', () => {
foo: { foo: {
dec: [0, 0, 0], dec: [0, 0, 0],
inc: [0, 0, 0], inc: [0, 0, 0],
total: [1, 0, 0] total: [1, 0, 0],
}, },
}); });
})); }));
@ -523,7 +523,7 @@ describe('Chart', () => {
foo: { foo: {
dec: [0, 0, 0], dec: [0, 0, 0],
inc: [0, 1, 0], inc: [0, 1, 0],
total: [100, 1, 0] total: [100, 1, 0],
}, },
}); });
@ -531,7 +531,7 @@ describe('Chart', () => {
foo: { foo: {
dec: [0, 0, 0], dec: [0, 0, 0],
inc: [1, 0, 0], inc: [1, 0, 0],
total: [100, 0, 0] total: [100, 0, 0],
}, },
}); });
})); }));

View file

@ -1,7 +1,7 @@
import * as assert from 'assert'; import * as assert from 'assert';
import { extractMentions } from '../src/misc/extract-mentions.js';
import { parse } from 'mfm-js'; import { parse } from 'mfm-js';
import { extractMentions } from '../src/misc/extract-mentions.js';
describe('Extract mentions', () => { describe('Extract mentions', () => {
it('simple', () => { it('simple', () => {
@ -10,15 +10,15 @@ describe('Extract mentions', () => {
assert.deepStrictEqual(mentions, [{ assert.deepStrictEqual(mentions, [{
username: 'foo', username: 'foo',
acct: '@foo', acct: '@foo',
host: null host: null,
}, { }, {
username: 'bar', username: 'bar',
acct: '@bar', acct: '@bar',
host: null host: null,
}, { }, {
username: 'baz', username: 'baz',
acct: '@baz', acct: '@baz',
host: null host: null,
}]); }]);
}); });
@ -28,15 +28,15 @@ describe('Extract mentions', () => {
assert.deepStrictEqual(mentions, [{ assert.deepStrictEqual(mentions, [{
username: 'foo', username: 'foo',
acct: '@foo', acct: '@foo',
host: null host: null,
}, { }, {
username: 'bar', username: 'bar',
acct: '@bar', acct: '@bar',
host: null host: null,
}, { }, {
username: 'baz', username: 'baz',
acct: '@baz', acct: '@baz',
host: null host: null,
}]); }]);
}); });
}); });

View file

@ -2,8 +2,8 @@ process.env.NODE_ENV = 'test';
import * as assert from 'assert'; import * as assert from 'assert';
import * as childProcess from 'child_process'; import * as childProcess from 'child_process';
import { async, startServer, signup, post, request, simpleGet, port, shutdownServer } from './utils.js';
import * as openapi from '@redocly/openapi-core'; import * as openapi from '@redocly/openapi-core';
import { async, startServer, signup, post, request, simpleGet, port, shutdownServer } from './utils.js';
// Request Accept // Request Accept
const ONLY_AP = 'application/activity+json'; const ONLY_AP = 'application/activity+json';
@ -26,7 +26,7 @@ describe('Fetch resource', () => {
p = await startServer(); p = await startServer();
alice = await signup({ username: 'alice' }); alice = await signup({ username: 'alice' });
alicesPost = await post(alice, { alicesPost = await post(alice, {
text: 'test' text: 'test',
}); });
}); });
@ -70,7 +70,7 @@ describe('Fetch resource', () => {
const config = await openapi.loadConfig(); const config = await openapi.loadConfig();
const result = await openapi.bundle({ const result = await openapi.bundle({
config, config,
ref: `http://localhost:${port}/api.json` ref: `http://localhost:${port}/api.json`,
}); });
for (const problem of result.problems) { for (const problem of result.problems) {

View file

@ -18,7 +18,7 @@ describe('Get file info', () => {
md5: 'd41d8cd98f00b204e9800998ecf8427e', md5: 'd41d8cd98f00b204e9800998ecf8427e',
type: { type: {
mime: 'application/octet-stream', mime: 'application/octet-stream',
ext: null ext: null,
}, },
width: undefined, width: undefined,
height: undefined, height: undefined,
@ -36,7 +36,7 @@ describe('Get file info', () => {
md5: '091b3f259662aa31e2ffef4519951168', md5: '091b3f259662aa31e2ffef4519951168',
type: { type: {
mime: 'image/jpeg', mime: 'image/jpeg',
ext: 'jpg' ext: 'jpg',
}, },
width: 512, width: 512,
height: 512, height: 512,
@ -54,7 +54,7 @@ describe('Get file info', () => {
md5: '08189c607bea3b952704676bb3c979e0', md5: '08189c607bea3b952704676bb3c979e0',
type: { type: {
mime: 'image/apng', mime: 'image/apng',
ext: 'apng' ext: 'apng',
}, },
width: 256, width: 256,
height: 256, height: 256,
@ -72,7 +72,7 @@ describe('Get file info', () => {
md5: '32c47a11555675d9267aee1a86571e7e', md5: '32c47a11555675d9267aee1a86571e7e',
type: { type: {
mime: 'image/gif', mime: 'image/gif',
ext: 'gif' ext: 'gif',
}, },
width: 256, width: 256,
height: 256, height: 256,
@ -90,7 +90,7 @@ describe('Get file info', () => {
md5: 'f73535c3e1e27508885b69b10cf6e991', md5: 'f73535c3e1e27508885b69b10cf6e991',
type: { type: {
mime: 'image/png', mime: 'image/png',
ext: 'png' ext: 'png',
}, },
width: 256, width: 256,
height: 256, height: 256,
@ -108,7 +108,7 @@ describe('Get file info', () => {
md5: 'b6f52b4b021e7b92cdd04509c7267965', md5: 'b6f52b4b021e7b92cdd04509c7267965',
type: { type: {
mime: 'image/svg+xml', mime: 'image/svg+xml',
ext: 'svg' ext: 'svg',
}, },
width: 256, width: 256,
height: 256, height: 256,
@ -127,7 +127,7 @@ describe('Get file info', () => {
md5: '4b7a346cde9ccbeb267e812567e33397', md5: '4b7a346cde9ccbeb267e812567e33397',
type: { type: {
mime: 'image/svg+xml', mime: 'image/svg+xml',
ext: 'svg' ext: 'svg',
}, },
width: 256, width: 256,
height: 256, height: 256,
@ -145,7 +145,7 @@ describe('Get file info', () => {
md5: '268c5dde99e17cf8fe09f1ab3f97df56', md5: '268c5dde99e17cf8fe09f1ab3f97df56',
type: { type: {
mime: 'application/octet-stream', // do not treat as image mime: 'application/octet-stream', // do not treat as image
ext: null ext: null,
}, },
width: 25000, width: 25000,
height: 25000, height: 25000,
@ -163,7 +163,7 @@ describe('Get file info', () => {
md5: '68d5b2d8d1d1acbbce99203e3ec3857e', md5: '68d5b2d8d1d1acbbce99203e3ec3857e',
type: { type: {
mime: 'image/jpeg', mime: 'image/jpeg',
ext: 'jpg' ext: 'jpg',
}, },
width: 512, width: 512,
height: 256, height: 256,

View file

@ -11,7 +11,7 @@ export class MockResolver extends Resolver {
public async _register(uri: string, content: string | Record<string, any>, type = 'application/activity+json') { public async _register(uri: string, content: string | Record<string, any>, type = 'application/activity+json') {
this._rs.set(uri, { this._rs.set(uri, {
type, type,
content: typeof content === 'string' ? content : JSON.stringify(content) content: typeof content === 'string' ? content : JSON.stringify(content),
}); });
} }
@ -22,9 +22,9 @@ export class MockResolver extends Resolver {
if (!r) { if (!r) {
throw { throw {
name: `StatusError`, name: 'StatusError',
statusCode: 404, statusCode: 404,
message: `Not registed for mock` message: 'Not registed for mock',
}; };
} }

View file

@ -25,7 +25,7 @@ describe('Mute', () => {
it('ミュート作成', async(async () => { it('ミュート作成', async(async () => {
const res = await request('/mute/create', { const res = await request('/mute/create', {
userId: carol.id userId: carol.id,
}, alice); }, alice);
assert.strictEqual(res.status, 204); assert.strictEqual(res.status, 204);
@ -117,7 +117,7 @@ describe('Mute', () => {
const aliceNote = await post(alice); const aliceNote = await post(alice);
const carolNote = await post(carol); const carolNote = await post(carol);
const bobNote = await post(bob, { const bobNote = await post(bob, {
renoteId: carolNote.id renoteId: carolNote.id,
}); });
const res = await request('/notes/local-timeline', {}, alice); const res = await request('/notes/local-timeline', {}, alice);

View file

@ -2,8 +2,8 @@ process.env.NODE_ENV = 'test';
import * as assert from 'assert'; import * as assert from 'assert';
import * as childProcess from 'child_process'; import * as childProcess from 'child_process';
import { async, signup, request, post, uploadFile, startServer, shutdownServer, initTestDb } from './utils.js';
import { Note } from '../src/models/entities/note.js'; import { Note } from '../src/models/entities/note.js';
import { async, signup, request, post, uploadFile, startServer, shutdownServer, initTestDb } from './utils.js';
describe('Note', () => { describe('Note', () => {
let p: childProcess.ChildProcess; let p: childProcess.ChildProcess;
@ -26,7 +26,7 @@ describe('Note', () => {
it('投稿できる', async(async () => { it('投稿できる', async(async () => {
const post = { const post = {
text: 'test' text: 'test',
}; };
const res = await request('/notes/create', post, alice); const res = await request('/notes/create', post, alice);
@ -40,7 +40,7 @@ describe('Note', () => {
const file = await uploadFile(alice); const file = await uploadFile(alice);
const res = await request('/notes/create', { const res = await request('/notes/create', {
fileIds: [file.id] fileIds: [file.id],
}, alice); }, alice);
assert.strictEqual(res.status, 200); assert.strictEqual(res.status, 200);
@ -53,7 +53,7 @@ describe('Note', () => {
const res = await request('/notes/create', { const res = await request('/notes/create', {
text: 'test', text: 'test',
fileIds: [file.id] fileIds: [file.id],
}, alice); }, alice);
assert.strictEqual(res.status, 200); assert.strictEqual(res.status, 200);
@ -64,7 +64,7 @@ describe('Note', () => {
it('存在しないファイルは無視', async(async () => { it('存在しないファイルは無視', async(async () => {
const res = await request('/notes/create', { const res = await request('/notes/create', {
text: 'test', text: 'test',
fileIds: ['000000000000000000000000'] fileIds: ['000000000000000000000000'],
}, alice); }, alice);
assert.strictEqual(res.status, 200); assert.strictEqual(res.status, 200);
@ -74,19 +74,19 @@ describe('Note', () => {
it('不正なファイルIDで怒られる', async(async () => { it('不正なファイルIDで怒られる', async(async () => {
const res = await request('/notes/create', { const res = await request('/notes/create', {
fileIds: ['kyoppie'] fileIds: ['kyoppie'],
}, alice); }, alice);
assert.strictEqual(res.status, 400); assert.strictEqual(res.status, 400);
})); }));
it('返信できる', async(async () => { it('返信できる', async(async () => {
const bobPost = await post(bob, { const bobPost = await post(bob, {
text: 'foo' text: 'foo',
}); });
const alicePost = { const alicePost = {
text: 'bar', text: 'bar',
replyId: bobPost.id replyId: bobPost.id,
}; };
const res = await request('/notes/create', alicePost, alice); const res = await request('/notes/create', alicePost, alice);
@ -100,11 +100,11 @@ describe('Note', () => {
it('renoteできる', async(async () => { it('renoteできる', async(async () => {
const bobPost = await post(bob, { const bobPost = await post(bob, {
text: 'test' text: 'test',
}); });
const alicePost = { const alicePost = {
renoteId: bobPost.id renoteId: bobPost.id,
}; };
const res = await request('/notes/create', alicePost, alice); const res = await request('/notes/create', alicePost, alice);
@ -117,12 +117,12 @@ describe('Note', () => {
it('引用renoteできる', async(async () => { it('引用renoteできる', async(async () => {
const bobPost = await post(bob, { const bobPost = await post(bob, {
text: 'test' text: 'test',
}); });
const alicePost = { const alicePost = {
text: 'test', text: 'test',
renoteId: bobPost.id renoteId: bobPost.id,
}; };
const res = await request('/notes/create', alicePost, alice); const res = await request('/notes/create', alicePost, alice);
@ -136,7 +136,7 @@ describe('Note', () => {
it('文字数ぎりぎりで怒られない', async(async () => { it('文字数ぎりぎりで怒られない', async(async () => {
const post = { const post = {
text: '!'.repeat(500) text: '!'.repeat(500),
}; };
const res = await request('/notes/create', post, alice); const res = await request('/notes/create', post, alice);
assert.strictEqual(res.status, 200); assert.strictEqual(res.status, 200);
@ -144,7 +144,7 @@ describe('Note', () => {
it('文字数オーバーで怒られる', async(async () => { it('文字数オーバーで怒られる', async(async () => {
const post = { const post = {
text: '!'.repeat(501) text: '!'.repeat(501),
}; };
const res = await request('/notes/create', post, alice); const res = await request('/notes/create', post, alice);
assert.strictEqual(res.status, 400); assert.strictEqual(res.status, 400);
@ -153,7 +153,7 @@ describe('Note', () => {
it('存在しないリプライ先で怒られる', async(async () => { it('存在しないリプライ先で怒られる', async(async () => {
const post = { const post = {
text: 'test', text: 'test',
replyId: '000000000000000000000000' replyId: '000000000000000000000000',
}; };
const res = await request('/notes/create', post, alice); const res = await request('/notes/create', post, alice);
assert.strictEqual(res.status, 400); assert.strictEqual(res.status, 400);
@ -161,7 +161,7 @@ describe('Note', () => {
it('存在しないrenote対象で怒られる', async(async () => { it('存在しないrenote対象で怒られる', async(async () => {
const post = { const post = {
renoteId: '000000000000000000000000' renoteId: '000000000000000000000000',
}; };
const res = await request('/notes/create', post, alice); const res = await request('/notes/create', post, alice);
assert.strictEqual(res.status, 400); assert.strictEqual(res.status, 400);
@ -170,7 +170,7 @@ describe('Note', () => {
it('不正なリプライ先IDで怒られる', async(async () => { it('不正なリプライ先IDで怒られる', async(async () => {
const post = { const post = {
text: 'test', text: 'test',
replyId: 'foo' replyId: 'foo',
}; };
const res = await request('/notes/create', post, alice); const res = await request('/notes/create', post, alice);
assert.strictEqual(res.status, 400); assert.strictEqual(res.status, 400);
@ -178,7 +178,7 @@ describe('Note', () => {
it('不正なrenote対象IDで怒られる', async(async () => { it('不正なrenote対象IDで怒られる', async(async () => {
const post = { const post = {
renoteId: 'foo' renoteId: 'foo',
}; };
const res = await request('/notes/create', post, alice); const res = await request('/notes/create', post, alice);
assert.strictEqual(res.status, 400); assert.strictEqual(res.status, 400);
@ -186,7 +186,7 @@ describe('Note', () => {
it('存在しないユーザーにメンションできる', async(async () => { it('存在しないユーザーにメンションできる', async(async () => {
const post = { const post = {
text: '@ghost yo' text: '@ghost yo',
}; };
const res = await request('/notes/create', post, alice); const res = await request('/notes/create', post, alice);
@ -198,7 +198,7 @@ describe('Note', () => {
it('同じユーザーに複数メンションしても内部的にまとめられる', async(async () => { it('同じユーザーに複数メンションしても内部的にまとめられる', async(async () => {
const post = { const post = {
text: '@bob @bob @bob yo' text: '@bob @bob @bob yo',
}; };
const res = await request('/notes/create', post, alice); const res = await request('/notes/create', post, alice);
@ -216,8 +216,8 @@ describe('Note', () => {
const res = await request('/notes/create', { const res = await request('/notes/create', {
text: 'test', text: 'test',
poll: { poll: {
choices: ['foo', 'bar'] choices: ['foo', 'bar'],
} },
}, alice); }, alice);
assert.strictEqual(res.status, 200); assert.strictEqual(res.status, 200);
@ -227,7 +227,7 @@ describe('Note', () => {
it('投票の選択肢が無くて怒られる', async(async () => { it('投票の選択肢が無くて怒られる', async(async () => {
const res = await request('/notes/create', { const res = await request('/notes/create', {
poll: {} poll: {},
}, alice); }, alice);
assert.strictEqual(res.status, 400); assert.strictEqual(res.status, 400);
})); }));
@ -235,8 +235,8 @@ describe('Note', () => {
it('投票の選択肢が無くて怒られる (空の配列)', async(async () => { it('投票の選択肢が無くて怒られる (空の配列)', async(async () => {
const res = await request('/notes/create', { const res = await request('/notes/create', {
poll: { poll: {
choices: [] choices: [],
} },
}, alice); }, alice);
assert.strictEqual(res.status, 400); assert.strictEqual(res.status, 400);
})); }));
@ -244,8 +244,8 @@ describe('Note', () => {
it('投票の選択肢が1つで怒られる', async(async () => { it('投票の選択肢が1つで怒られる', async(async () => {
const res = await request('/notes/create', { const res = await request('/notes/create', {
poll: { poll: {
choices: ['Strawberry Pasta'] choices: ['Strawberry Pasta'],
} },
}, alice); }, alice);
assert.strictEqual(res.status, 400); assert.strictEqual(res.status, 400);
})); }));
@ -254,13 +254,13 @@ describe('Note', () => {
const { body } = await request('/notes/create', { const { body } = await request('/notes/create', {
text: 'test', text: 'test',
poll: { poll: {
choices: ['sakura', 'izumi', 'ako'] choices: ['sakura', 'izumi', 'ako'],
} },
}, alice); }, alice);
const res = await request('/notes/polls/vote', { const res = await request('/notes/polls/vote', {
noteId: body.createdNote.id, noteId: body.createdNote.id,
choice: 1 choice: 1,
}, alice); }, alice);
assert.strictEqual(res.status, 204); assert.strictEqual(res.status, 204);
@ -270,18 +270,18 @@ describe('Note', () => {
const { body } = await request('/notes/create', { const { body } = await request('/notes/create', {
text: 'test', text: 'test',
poll: { poll: {
choices: ['sakura', 'izumi', 'ako'] choices: ['sakura', 'izumi', 'ako'],
} },
}, alice); }, alice);
await request('/notes/polls/vote', { await request('/notes/polls/vote', {
noteId: body.createdNote.id, noteId: body.createdNote.id,
choice: 0 choice: 0,
}, alice); }, alice);
const res = await request('/notes/polls/vote', { const res = await request('/notes/polls/vote', {
noteId: body.createdNote.id, noteId: body.createdNote.id,
choice: 2 choice: 2,
}, alice); }, alice);
assert.strictEqual(res.status, 400); assert.strictEqual(res.status, 400);
@ -292,23 +292,23 @@ describe('Note', () => {
text: 'test', text: 'test',
poll: { poll: {
choices: ['sakura', 'izumi', 'ako'], choices: ['sakura', 'izumi', 'ako'],
multiple: true multiple: true,
} },
}, alice); }, alice);
await request('/notes/polls/vote', { await request('/notes/polls/vote', {
noteId: body.createdNote.id, noteId: body.createdNote.id,
choice: 0 choice: 0,
}, alice); }, alice);
await request('/notes/polls/vote', { await request('/notes/polls/vote', {
noteId: body.createdNote.id, noteId: body.createdNote.id,
choice: 1 choice: 1,
}, alice); }, alice);
const res = await request('/notes/polls/vote', { const res = await request('/notes/polls/vote', {
noteId: body.createdNote.id, noteId: body.createdNote.id,
choice: 2 choice: 2,
}, alice); }, alice);
assert.strictEqual(res.status, 204); assert.strictEqual(res.status, 204);
@ -319,15 +319,15 @@ describe('Note', () => {
text: 'test', text: 'test',
poll: { poll: {
choices: ['sakura', 'izumi', 'ako'], choices: ['sakura', 'izumi', 'ako'],
expiredAfter: 1 expiredAfter: 1,
} },
}, alice); }, alice);
await new Promise(x => setTimeout(x, 2)); await new Promise(x => setTimeout(x, 2));
const res = await request('/notes/polls/vote', { const res = await request('/notes/polls/vote', {
noteId: body.createdNote.id, noteId: body.createdNote.id,
choice: 1 choice: 1,
}, alice); }, alice);
assert.strictEqual(res.status, 400); assert.strictEqual(res.status, 400);
@ -341,11 +341,11 @@ describe('Note', () => {
}, alice); }, alice);
const replyOneRes = await request('/notes/create', { const replyOneRes = await request('/notes/create', {
text: 'reply one', text: 'reply one',
replyId: mainNoteRes.body.createdNote.id replyId: mainNoteRes.body.createdNote.id,
}, alice); }, alice);
const replyTwoRes = await request('/notes/create', { const replyTwoRes = await request('/notes/create', {
text: 'reply two', text: 'reply two',
replyId: mainNoteRes.body.createdNote.id replyId: mainNoteRes.body.createdNote.id,
}, alice); }, alice);
const deleteOneRes = await request('/notes/delete', { const deleteOneRes = await request('/notes/delete', {

View file

@ -6,7 +6,7 @@ describe('url', () => {
const s = query({ const s = query({
foo: 'ふぅ', foo: 'ふぅ',
bar: 'b a r', bar: 'b a r',
baz: undefined baz: undefined,
}); });
assert.deepStrictEqual(s, 'foo=%E3%81%B5%E3%81%85&bar=b%20a%20r'); assert.deepStrictEqual(s, 'foo=%E3%81%B5%E3%81%85&bar=b%20a%20r');
}); });

View file

@ -2,8 +2,8 @@ process.env.NODE_ENV = 'test';
import * as assert from 'assert'; import * as assert from 'assert';
import * as childProcess from 'child_process'; import * as childProcess from 'child_process';
import { connectStream, signup, request, post, startServer, shutdownServer, initTestDb } from './utils.js';
import { Following } from '../src/models/entities/following.js'; import { Following } from '../src/models/entities/following.js';
import { connectStream, signup, request, post, startServer, shutdownServer, initTestDb } from './utils.js';
describe('Streaming', () => { describe('Streaming', () => {
let p: childProcess.ChildProcess; let p: childProcess.ChildProcess;
@ -30,7 +30,7 @@ describe('Streaming', () => {
followerSharedInbox: null, followerSharedInbox: null,
followeeHost: followee.host, followeeHost: followee.host,
followeeInbox: null, followeeInbox: null,
followeeSharedInbox: null followeeSharedInbox: null,
}); });
}; };
@ -47,7 +47,7 @@ describe('Streaming', () => {
}); });
post(alice, { post(alice, {
text: 'foo @bob bar' text: 'foo @bob bar',
}); });
})); }));
@ -55,7 +55,7 @@ describe('Streaming', () => {
const alice = await signup({ username: 'alice' }); const alice = await signup({ username: 'alice' });
const bob = await signup({ username: 'bob' }); const bob = await signup({ username: 'bob' });
const bobNote = await post(bob, { const bobNote = await post(bob, {
text: 'foo' text: 'foo',
}); });
const ws = await connectStream(bob, 'main', ({ type, body }) => { const ws = await connectStream(bob, 'main', ({ type, body }) => {
@ -67,14 +67,14 @@ describe('Streaming', () => {
}); });
post(alice, { post(alice, {
renoteId: bobNote.id renoteId: bobNote.id,
}); });
})); }));
describe('Home Timeline', () => { describe('Home Timeline', () => {
it('自分の投稿が流れる', () => new Promise(async done => { it('自分の投稿が流れる', () => new Promise(async done => {
const post = { const post = {
text: 'foo' text: 'foo',
}; };
const me = await signup(); const me = await signup();
@ -96,7 +96,7 @@ describe('Streaming', () => {
// Alice が Bob をフォロー // Alice が Bob をフォロー
await request('/following/create', { await request('/following/create', {
userId: bob.id userId: bob.id,
}, alice); }, alice);
const ws = await connectStream(alice, 'homeTimeline', ({ type, body }) => { const ws = await connectStream(alice, 'homeTimeline', ({ type, body }) => {
@ -108,7 +108,7 @@ describe('Streaming', () => {
}); });
post(bob, { post(bob, {
text: 'foo' text: 'foo',
}); });
})); }));
@ -125,7 +125,7 @@ describe('Streaming', () => {
}); });
post(bob, { post(bob, {
text: 'foo' text: 'foo',
}); });
setTimeout(() => { setTimeout(() => {
@ -141,7 +141,7 @@ describe('Streaming', () => {
// Alice が Bob をフォロー // Alice が Bob をフォロー
await request('/following/create', { await request('/following/create', {
userId: bob.id userId: bob.id,
}, alice); }, alice);
const ws = await connectStream(alice, 'homeTimeline', ({ type, body }) => { const ws = await connectStream(alice, 'homeTimeline', ({ type, body }) => {
@ -157,7 +157,7 @@ describe('Streaming', () => {
post(bob, { post(bob, {
text: 'foo', text: 'foo',
visibility: 'specified', visibility: 'specified',
visibleUserIds: [alice.id] visibleUserIds: [alice.id],
}); });
})); }));
@ -168,7 +168,7 @@ describe('Streaming', () => {
// Alice が Bob をフォロー // Alice が Bob をフォロー
await request('/following/create', { await request('/following/create', {
userId: bob.id userId: bob.id,
}, alice); }, alice);
let fired = false; let fired = false;
@ -183,7 +183,7 @@ describe('Streaming', () => {
post(bob, { post(bob, {
text: 'foo', text: 'foo',
visibility: 'specified', visibility: 'specified',
visibleUserIds: [carol.id] visibleUserIds: [carol.id],
}); });
setTimeout(() => { setTimeout(() => {
@ -207,7 +207,7 @@ describe('Streaming', () => {
}); });
post(me, { post(me, {
text: 'foo' text: 'foo',
}); });
})); }));
@ -224,7 +224,7 @@ describe('Streaming', () => {
}); });
post(bob, { post(bob, {
text: 'foo' text: 'foo',
}); });
})); }));
@ -241,7 +241,7 @@ describe('Streaming', () => {
}); });
post(bob, { post(bob, {
text: 'foo' text: 'foo',
}); });
setTimeout(() => { setTimeout(() => {
@ -257,7 +257,7 @@ describe('Streaming', () => {
// Alice が Bob をフォロー // Alice が Bob をフォロー
await request('/following/create', { await request('/following/create', {
userId: bob.id userId: bob.id,
}, alice); }, alice);
let fired = false; let fired = false;
@ -269,7 +269,7 @@ describe('Streaming', () => {
}); });
post(bob, { post(bob, {
text: 'foo' text: 'foo',
}); });
setTimeout(() => { setTimeout(() => {
@ -294,7 +294,7 @@ describe('Streaming', () => {
// ホーム指定 // ホーム指定
post(bob, { post(bob, {
text: 'foo', text: 'foo',
visibility: 'home' visibility: 'home',
}); });
setTimeout(() => { setTimeout(() => {
@ -310,7 +310,7 @@ describe('Streaming', () => {
// Alice が Bob をフォロー // Alice が Bob をフォロー
await request('/following/create', { await request('/following/create', {
userId: bob.id userId: bob.id,
}, alice); }, alice);
let fired = false; let fired = false;
@ -325,7 +325,7 @@ describe('Streaming', () => {
post(bob, { post(bob, {
text: 'foo', text: 'foo',
visibility: 'specified', visibility: 'specified',
visibleUserIds: [alice.id] visibleUserIds: [alice.id],
}); });
setTimeout(() => { setTimeout(() => {
@ -350,7 +350,7 @@ describe('Streaming', () => {
// フォロワー宛て投稿 // フォロワー宛て投稿
post(bob, { post(bob, {
text: 'foo', text: 'foo',
visibility: 'followers' visibility: 'followers',
}); });
setTimeout(() => { setTimeout(() => {
@ -374,7 +374,7 @@ describe('Streaming', () => {
}); });
post(me, { post(me, {
text: 'foo' text: 'foo',
}); });
})); }));
@ -391,7 +391,7 @@ describe('Streaming', () => {
}); });
post(bob, { post(bob, {
text: 'foo' text: 'foo',
}); });
})); }));
@ -411,7 +411,7 @@ describe('Streaming', () => {
}); });
post(bob, { post(bob, {
text: 'foo' text: 'foo',
}); });
})); }));
@ -428,7 +428,7 @@ describe('Streaming', () => {
}); });
post(bob, { post(bob, {
text: 'foo' text: 'foo',
}); });
setTimeout(() => { setTimeout(() => {
@ -444,7 +444,7 @@ describe('Streaming', () => {
// Alice が Bob をフォロー // Alice が Bob をフォロー
await request('/following/create', { await request('/following/create', {
userId: bob.id userId: bob.id,
}, alice); }, alice);
const ws = await connectStream(alice, 'hybridTimeline', ({ type, body }) => { const ws = await connectStream(alice, 'hybridTimeline', ({ type, body }) => {
@ -460,7 +460,7 @@ describe('Streaming', () => {
post(bob, { post(bob, {
text: 'foo', text: 'foo',
visibility: 'specified', visibility: 'specified',
visibleUserIds: [alice.id] visibleUserIds: [alice.id],
}); });
})); }));
@ -470,7 +470,7 @@ describe('Streaming', () => {
// Alice が Bob をフォロー // Alice が Bob をフォロー
await request('/following/create', { await request('/following/create', {
userId: bob.id userId: bob.id,
}, alice); }, alice);
const ws = await connectStream(alice, 'hybridTimeline', ({ type, body }) => { const ws = await connectStream(alice, 'hybridTimeline', ({ type, body }) => {
@ -485,7 +485,7 @@ describe('Streaming', () => {
// ホーム投稿 // ホーム投稿
post(bob, { post(bob, {
text: 'foo', text: 'foo',
visibility: 'home' visibility: 'home',
}); });
})); }));
@ -504,7 +504,7 @@ describe('Streaming', () => {
// ホーム投稿 // ホーム投稿
post(bob, { post(bob, {
text: 'foo', text: 'foo',
visibility: 'home' visibility: 'home',
}); });
setTimeout(() => { setTimeout(() => {
@ -529,7 +529,7 @@ describe('Streaming', () => {
// フォロワー宛て投稿 // フォロワー宛て投稿
post(bob, { post(bob, {
text: 'foo', text: 'foo',
visibility: 'followers' visibility: 'followers',
}); });
setTimeout(() => { setTimeout(() => {
@ -554,7 +554,7 @@ describe('Streaming', () => {
}); });
post(bob, { post(bob, {
text: 'foo' text: 'foo',
}); });
})); }));
@ -571,7 +571,7 @@ describe('Streaming', () => {
}); });
post(bob, { post(bob, {
text: 'foo' text: 'foo',
}); });
})); }));
@ -590,7 +590,7 @@ describe('Streaming', () => {
// ホーム投稿 // ホーム投稿
post(bob, { post(bob, {
text: 'foo', text: 'foo',
visibility: 'home' visibility: 'home',
}); });
setTimeout(() => { setTimeout(() => {
@ -608,13 +608,13 @@ describe('Streaming', () => {
// リスト作成 // リスト作成
const list = await request('/users/lists/create', { const list = await request('/users/lists/create', {
name: 'my list' name: 'my list',
}, alice).then(x => x.body); }, alice).then(x => x.body);
// Alice が Bob をリスイン // Alice が Bob をリスイン
await request('/users/lists/push', { await request('/users/lists/push', {
listId: list.id, listId: list.id,
userId: bob.id userId: bob.id,
}, alice); }, alice);
const ws = await connectStream(alice, 'userList', ({ type, body }) => { const ws = await connectStream(alice, 'userList', ({ type, body }) => {
@ -624,11 +624,11 @@ describe('Streaming', () => {
done(); done();
} }
}, { }, {
listId: list.id listId: list.id,
}); });
post(bob, { post(bob, {
text: 'foo' text: 'foo',
}); });
})); }));
@ -638,7 +638,7 @@ describe('Streaming', () => {
// リスト作成 // リスト作成
const list = await request('/users/lists/create', { const list = await request('/users/lists/create', {
name: 'my list' name: 'my list',
}, alice).then(x => x.body); }, alice).then(x => x.body);
let fired = false; let fired = false;
@ -648,11 +648,11 @@ describe('Streaming', () => {
fired = true; fired = true;
} }
}, { }, {
listId: list.id listId: list.id,
}); });
post(bob, { post(bob, {
text: 'foo' text: 'foo',
}); });
setTimeout(() => { setTimeout(() => {
@ -669,13 +669,13 @@ describe('Streaming', () => {
// リスト作成 // リスト作成
const list = await request('/users/lists/create', { const list = await request('/users/lists/create', {
name: 'my list' name: 'my list',
}, alice).then(x => x.body); }, alice).then(x => x.body);
// Alice が Bob をリスイン // Alice が Bob をリスイン
await request('/users/lists/push', { await request('/users/lists/push', {
listId: list.id, listId: list.id,
userId: bob.id userId: bob.id,
}, alice); }, alice);
const ws = await connectStream(alice, 'userList', ({ type, body }) => { const ws = await connectStream(alice, 'userList', ({ type, body }) => {
@ -686,14 +686,14 @@ describe('Streaming', () => {
done(); done();
} }
}, { }, {
listId: list.id listId: list.id,
}); });
// Bob が Alice 宛てのダイレクト投稿 // Bob が Alice 宛てのダイレクト投稿
post(bob, { post(bob, {
text: 'foo', text: 'foo',
visibility: 'specified', visibility: 'specified',
visibleUserIds: [alice.id] visibleUserIds: [alice.id],
}); });
})); }));
@ -704,13 +704,13 @@ describe('Streaming', () => {
// リスト作成 // リスト作成
const list = await request('/users/lists/create', { const list = await request('/users/lists/create', {
name: 'my list' name: 'my list',
}, alice).then(x => x.body); }, alice).then(x => x.body);
// Alice が Bob をリスイン // Alice が Bob をリスイン
await request('/users/lists/push', { await request('/users/lists/push', {
listId: list.id, listId: list.id,
userId: bob.id userId: bob.id,
}, alice); }, alice);
let fired = false; let fired = false;
@ -720,13 +720,13 @@ describe('Streaming', () => {
fired = true; fired = true;
} }
}, { }, {
listId: list.id listId: list.id,
}); });
// フォロワー宛て投稿 // フォロワー宛て投稿
post(bob, { post(bob, {
text: 'foo', text: 'foo',
visibility: 'followers' visibility: 'followers',
}); });
setTimeout(() => { setTimeout(() => {
@ -749,12 +749,12 @@ describe('Streaming', () => {
} }
}, { }, {
q: [ q: [
['foo'] ['foo'],
] ],
}); });
post(me, { post(me, {
text: '#foo' text: '#foo',
}); });
})); }));
@ -773,20 +773,20 @@ describe('Streaming', () => {
} }
}, { }, {
q: [ q: [
['foo', 'bar'] ['foo', 'bar'],
] ],
}); });
post(me, { post(me, {
text: '#foo' text: '#foo',
}); });
post(me, { post(me, {
text: '#bar' text: '#bar',
}); });
post(me, { post(me, {
text: '#foo #bar' text: '#foo #bar',
}); });
setTimeout(() => { setTimeout(() => {
@ -816,24 +816,24 @@ describe('Streaming', () => {
}, { }, {
q: [ q: [
['foo'], ['foo'],
['bar'] ['bar'],
] ],
}); });
post(me, { post(me, {
text: '#foo' text: '#foo',
}); });
post(me, { post(me, {
text: '#bar' text: '#bar',
}); });
post(me, { post(me, {
text: '#foo #bar' text: '#foo #bar',
}); });
post(me, { post(me, {
text: '#piyo' text: '#piyo',
}); });
setTimeout(() => { setTimeout(() => {
@ -866,28 +866,28 @@ describe('Streaming', () => {
}, { }, {
q: [ q: [
['foo', 'bar'], ['foo', 'bar'],
['piyo'] ['piyo'],
] ],
}); });
post(me, { post(me, {
text: '#foo' text: '#foo',
}); });
post(me, { post(me, {
text: '#bar' text: '#bar',
}); });
post(me, { post(me, {
text: '#foo #bar' text: '#foo #bar',
}); });
post(me, { post(me, {
text: '#piyo' text: '#piyo',
}); });
post(me, { post(me, {
text: '#waaa' text: '#waaa',
}); });
setTimeout(() => { setTimeout(() => {

View file

@ -23,13 +23,13 @@ describe('users/notes', () => {
const jpg = await uploadFile(alice, _dirname + '/resources/Lenna.jpg'); const jpg = await uploadFile(alice, _dirname + '/resources/Lenna.jpg');
const png = await uploadFile(alice, _dirname + '/resources/Lenna.png'); const png = await uploadFile(alice, _dirname + '/resources/Lenna.png');
jpgNote = await post(alice, { jpgNote = await post(alice, {
fileIds: [jpg.id] fileIds: [jpg.id],
}); });
pngNote = await post(alice, { pngNote = await post(alice, {
fileIds: [png.id] fileIds: [png.id],
}); });
jpgPngNote = await post(alice, { jpgPngNote = await post(alice, {
fileIds: [jpg.id, png.id] fileIds: [jpg.id, png.id],
}); });
}); });
@ -40,7 +40,7 @@ describe('users/notes', () => {
it('ファイルタイプ指定 (jpg)', async(async () => { it('ファイルタイプ指定 (jpg)', async(async () => {
const res = await request('/users/notes', { const res = await request('/users/notes', {
userId: alice.id, userId: alice.id,
fileType: ['image/jpeg'] fileType: ['image/jpeg'],
}, alice); }, alice);
assert.strictEqual(res.status, 200); assert.strictEqual(res.status, 200);
@ -53,7 +53,7 @@ describe('users/notes', () => {
it('ファイルタイプ指定 (jpg or png)', async(async () => { it('ファイルタイプ指定 (jpg or png)', async(async () => {
const res = await request('/users/notes', { const res = await request('/users/notes', {
userId: alice.id, userId: alice.id,
fileType: ['image/jpeg', 'image/png'] fileType: ['image/jpeg', 'image/png'],
}, alice); }, alice);
assert.strictEqual(res.status, 200); assert.strictEqual(res.status, 200);