summaryrefslogtreecommitdiff
path: root/test/api.js
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-01-21 07:34:04 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-01-21 07:34:04 +0900
commit48822506f27bf98d3ed49c2f0de39ef8877b9793 (patch)
tree97218dbc6c3d66b0ac0a4f539fbc9971c977168b /test/api.js
parent[API] Fix: Validate id (diff)
downloadmisskey-48822506f27bf98d3ed49c2f0de39ef8877b9793.tar.gz
misskey-48822506f27bf98d3ed49c2f0de39ef8877b9793.tar.bz2
misskey-48822506f27bf98d3ed49c2f0de39ef8877b9793.zip
[Test] Add some tests
Diffstat (limited to 'test/api.js')
-rw-r--r--test/api.js67
1 files changed, 67 insertions, 0 deletions
diff --git a/test/api.js b/test/api.js
index c5e6476cfa..5a2a86930d 100644
--- a/test/api.js
+++ b/test/api.js
@@ -423,6 +423,73 @@ describe('API', () => {
}));
});
+ describe('posts/likes/delete', () => {
+ 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();
+ await db.get('likes').insert({
+ user_id: me._id,
+ post_id: himaPost._id
+ });
+
+ request('/posts/likes/delete', {
+ post_id: himaPost._id.toString()
+ }, me).then(res => {
+ res.should.have.status(204);
+ done();
+ });
+ }));
+
+ 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/delete', {
+ 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/delete', {
+ post_id: '000000000000000000000000'
+ }, me).then(res => {
+ res.should.have.status(400);
+ done();
+ });
+ }));
+
+ it('空のパラメータで怒られる', () => new Promise(async (done) => {
+ const me = await insertSakurako();
+ request('/posts/likes/delete', {}, me).then(res => {
+ res.should.have.status(400);
+ done();
+ });
+ }));
+
+ it('間違ったIDで怒られる', () => new Promise(async (done) => {
+ const me = await insertSakurako();
+ request('/posts/likes/delete', {
+ post_id: 'kyoppie'
+ }, me).then(res => {
+ res.should.have.status(400);
+ done();
+ });
+ }));
+ });
+
describe('following/create', () => {
it('フォローできる', () => new Promise(async (done) => {
const hima = await insertHimawari();