forked from FoundKeyGang/FoundKey
test
This commit is contained in:
parent
c282fefe00
commit
437283fd95
1 changed files with 30 additions and 2 deletions
32
test/api.js
32
test/api.js
|
@ -147,10 +147,29 @@ describe('API', () => {
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('reply', () => {
|
it('reply', () => new Promise(async (done) => {
|
||||||
|
const hima = await insertHimawari();
|
||||||
|
const himaPost = await db.get('posts').insert({
|
||||||
|
user_id: hima._id,
|
||||||
|
text: 'ひま'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const me = await insertSakurako();
|
||||||
|
const post = {
|
||||||
|
text: 'さく',
|
||||||
|
reply_to_id: himaPost._id.toString()
|
||||||
|
};
|
||||||
|
request('/posts/create', post, me).then(res => {
|
||||||
|
res.should.have.status(200);
|
||||||
|
res.body.should.be.a('object');
|
||||||
|
res.body.should.have.property('text').eql(post.text);
|
||||||
|
res.body.should.have.property('reply_to_id').eql(post.reply_to_id);
|
||||||
|
res.body.should.have.property('reply_to');
|
||||||
|
res.body.reply_to.should.have.property('text').eql(himaPost.text;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
it('repost', () => {
|
it('repost', () => {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -165,3 +184,12 @@ async function insertSakurako() {
|
||||||
password: '$2a$14$wlDw/gDIEE7hHpkJA4yZE.bRUZc.ykHhPfVXPaw2cfOldyParYM76' // HimawariDaisuki06160907
|
password: '$2a$14$wlDw/gDIEE7hHpkJA4yZE.bRUZc.ykHhPfVXPaw2cfOldyParYM76' // HimawariDaisuki06160907
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function insertHimawari() {
|
||||||
|
return await db.get('users').insert({
|
||||||
|
token: '!00000000000000000000000000000001',
|
||||||
|
username: 'himawari',
|
||||||
|
username_lower: 'himawari',
|
||||||
|
password: '$2a$14$8kwC/akV/Gzk58vsTDAate2ixGjQRtC1j3c4IQAqZ7QLvawRMQsPO' // ilovesakurako
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue