mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-23 08:30:54 +01:00
[Test] Add some messaging tests
This commit is contained in:
parent
df3440633a
commit
76aaa340a3
1 changed files with 72 additions and 0 deletions
72
test/api.ts
72
test/api.ts
|
@ -1193,6 +1193,78 @@ describe('API', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('messaging/messages/create', () => {
|
||||
it('メッセージを送信できる', () => async (done) => {
|
||||
const me = await insertSakurako();
|
||||
const hima = await insertHimawari();
|
||||
request('/messaging/messages/create', {
|
||||
user_id: hima._id.toString(),
|
||||
text: 'Hey hey ひまわり'
|
||||
}).then(res => {
|
||||
res.should.have.status(200);
|
||||
res.body.should.be.a('object');
|
||||
res.body.should.have.property('text').eql('Hey hey ひまわり');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('自分自身にはメッセージを送信できない', () => async (done) => {
|
||||
const me = await insertSakurako();
|
||||
request('/messaging/messages/create', {
|
||||
user_id: me._id.toString(),
|
||||
text: 'Yo'
|
||||
}).then(res => {
|
||||
res.should.have.status(400);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('存在しないユーザーにはメッセージを送信できない', () => async (done) => {
|
||||
const me = await insertSakurako();
|
||||
request('/messaging/messages/create', {
|
||||
user_id: '000000000000000000000000',
|
||||
text: 'Yo'
|
||||
}).then(res => {
|
||||
res.should.have.status(400);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('不正なユーザーIDで怒られる', () => async (done) => {
|
||||
const me = await insertSakurako();
|
||||
request('/messaging/messages/create', {
|
||||
user_id: 'kyoppie',
|
||||
text: 'Yo'
|
||||
}).then(res => {
|
||||
res.should.have.status(400);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('テキストが無くて怒られる', () => async (done) => {
|
||||
const me = await insertSakurako();
|
||||
const hima = await insertHimawari();
|
||||
request('/messaging/messages/create', {
|
||||
user_id: hima._id.toString()
|
||||
}).then(res => {
|
||||
res.should.have.status(400);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('文字数オーバーで怒られる', () => async (done) => {
|
||||
const me = await insertSakurako();
|
||||
const hima = await insertHimawari();
|
||||
request('/messaging/messages/create', {
|
||||
user_id: hima._id.toString(),
|
||||
text: '!'.repeat(501)
|
||||
}).then(res => {
|
||||
res.should.have.status(400);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('auth/session/generate', () => {
|
||||
it('認証セッションを作成できる', () => async (done) => {
|
||||
const app = await insertApp();
|
||||
|
|
Loading…
Reference in a new issue