This commit is contained in:
syuilo 2017-01-17 16:26:21 +09:00
parent c282fefe00
commit 437283fd95

View File

@ -147,9 +147,28 @@ 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', () => {
@ -165,3 +184,12 @@ async function insertSakurako() {
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
});
}