mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-30 10:53:11 +02:00
[Test] Add some tests
This commit is contained in:
parent
21f1da39c6
commit
0c7406f8ba
1 changed files with 64 additions and 0 deletions
64
test/api.js
64
test/api.js
|
@ -341,6 +341,70 @@ describe('API', () => {
|
|||
}));
|
||||
});
|
||||
|
||||
describe('posts/likes/create', () => {
|
||||
it('いいねできる', () => new Promise(async (done) => {
|
||||
const hima = await insertHimawari();
|
||||
const himaPost = await db.get('posts').insert({
|
||||
user_id: hima._id,
|
||||
text: 'ひま'
|
||||
});
|
||||
|
||||
const me = await insertSakurako();
|
||||
request('/posts/likes/create', {
|
||||
post_id: himaPost._id.toString()
|
||||
}, me).then(res => {
|
||||
res.should.have.status(200);
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('自分の投稿にはいいねできない', () => new Promise(async (done) => {
|
||||
const me = await insertSakurako();
|
||||
const myPost = await db.get('posts').insert({
|
||||
user_id: me._id,
|
||||
text: 'お腹ペコい'
|
||||
});
|
||||
|
||||
request('/posts/likes/create', {
|
||||
post_id: myPost._id.toString()
|
||||
}, me).then(res => {
|
||||
res.should.have.status(400);
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('二重にいいねできない', () => new Promise(async (done) => {
|
||||
const hima = await insertHimawari();
|
||||
const himaPost = await db.get('posts').insert({
|
||||
user_id: hima._id,
|
||||
text: 'ひま'
|
||||
});
|
||||
|
||||
await db.get('likes').insert({
|
||||
user_id: me._id,
|
||||
post_id: himaPost._id
|
||||
});
|
||||
|
||||
const me = await insertSakurako();
|
||||
request('/posts/likes/create', {
|
||||
post_id: himaPost._id.toString()
|
||||
}, me).then(res => {
|
||||
res.should.have.status(400);
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('存在しない投稿にはいいねできない', () => new Promise(async (done) => {
|
||||
const me = await insertSakurako();
|
||||
request('/posts/likes/create', {
|
||||
post_id: '000000000000000000000000'
|
||||
}, me).then(res => {
|
||||
res.should.have.status(400);
|
||||
done();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
describe('following/create', () => {
|
||||
it('フォローできる', () => new Promise(async (done) => {
|
||||
const hima = await insertHimawari();
|
||||
|
|
Loading…
Reference in a new issue