|
@@ -9,7 +9,6 @@ let { sequelize } = require('../models')
|
|
|
|
|
|
const Errors = require('../lib/errors.js')
|
|
const Errors = require('../lib/errors.js')
|
|
let PAGINATION_THREAD_ID
|
|
let PAGINATION_THREAD_ID
|
|
-let MID_PAGINATION_POST_ID
|
|
|
|
|
|
|
|
chai.use(require('chai-http'))
|
|
chai.use(require('chai-http'))
|
|
chai.use(require('chai-things'))
|
|
chai.use(require('chai-things'))
|
|
@@ -178,7 +177,7 @@ describe('Thread and post', () => {
|
|
res.should.be.json
|
|
res.should.be.json
|
|
res.should.have.status(200)
|
|
res.should.have.status(200)
|
|
res.body.should.have.property('content', '<p>content</p>\n')
|
|
res.body.should.have.property('content', '<p>content</p>\n')
|
|
- res.body.should.have.property('postNumber', 1)
|
|
|
|
|
|
+ res.body.should.have.property('postNumber', 0)
|
|
res.body.should.have.deep.property('User.username', 'username')
|
|
res.body.should.have.deep.property('User.username', 'username')
|
|
res.body.should.have.deep.property('Thread.name', 'thread')
|
|
res.body.should.have.deep.property('Thread.name', 'thread')
|
|
res.body.should.have.deep.property('Thread.postsCount', 1)
|
|
res.body.should.have.deep.property('Thread.postsCount', 1)
|
|
@@ -281,7 +280,7 @@ describe('Thread and post', () => {
|
|
|
|
|
|
res.should.be.json
|
|
res.should.be.json
|
|
res.should.have.status(200)
|
|
res.should.have.status(200)
|
|
- res.body.should.have.property('postNumber', 2)
|
|
|
|
|
|
+ res.body.should.have.property('postNumber', 1)
|
|
res.body.should.have.property('content', '<p>another post</p>\n')
|
|
res.body.should.have.property('content', '<p>another post</p>\n')
|
|
res.body.should.have.deep.property('User.username', 'username1')
|
|
res.body.should.have.deep.property('User.username', 'username1')
|
|
res.body.should.have.deep.property('Thread.name', 'thread')
|
|
res.body.should.have.deep.property('Thread.name', 'thread')
|
|
@@ -391,14 +390,12 @@ describe('Thread and post', () => {
|
|
.set('content-type', 'application/json')
|
|
.set('content-type', 'application/json')
|
|
.send({ threadId: threadOther.body.id, content: `POST OTHER ${i}` })
|
|
.send({ threadId: threadOther.body.id, content: `POST OTHER ${i}` })
|
|
}
|
|
}
|
|
-
|
|
|
|
- if(i === 15) MID_PAGINATION_POST_ID = post.body.id
|
|
|
|
}
|
|
}
|
|
|
|
|
|
let pageOne = await userAgent.get('/api/v1/thread/' + thread.body.id)
|
|
let pageOne = await userAgent.get('/api/v1/thread/' + thread.body.id)
|
|
let pageTwo = await userAgent.get(pageOne.body.meta.nextURL)
|
|
let pageTwo = await userAgent.get(pageOne.body.meta.nextURL)
|
|
let pageThree = await userAgent.get(pageTwo.body.meta.nextURL)
|
|
let pageThree = await userAgent.get(pageTwo.body.meta.nextURL)
|
|
- let pageInvalid = await userAgent.get('/api/v1/thread/' + thread.body.id + '?lastId=' + 100)
|
|
|
|
|
|
+ let pageInvalid = await userAgent.get('/api/v1/thread/' + thread.body.id + '?from=' + 100)
|
|
|
|
|
|
pageOne.body.Posts.should.have.length(10)
|
|
pageOne.body.Posts.should.have.length(10)
|
|
pageOne.body.meta.should.have.property('previousURL', null)
|
|
pageOne.body.meta.should.have.property('previousURL', null)
|
|
@@ -418,7 +415,8 @@ describe('Thread and post', () => {
|
|
it('should allow you to get an individual and surrounding posts', async () => {
|
|
it('should allow you to get an individual and surrounding posts', async () => {
|
|
let http = chai.request(server)
|
|
let http = chai.request(server)
|
|
|
|
|
|
- let pageOne = await http.get(`/api/v1/thread/${PAGINATION_THREAD_ID}?postId=${MID_PAGINATION_POST_ID}`)
|
|
|
|
|
|
+ let pageOne = await http.get(`/api/v1/thread/${PAGINATION_THREAD_ID}?postNumber=15`)
|
|
|
|
+
|
|
let pageZero = await http.get(pageOne.body.meta.previousURL)
|
|
let pageZero = await http.get(pageOne.body.meta.previousURL)
|
|
let pageTwo = await http.get(pageOne.body.meta.nextURL)
|
|
let pageTwo = await http.get(pageOne.body.meta.nextURL)
|
|
|
|
|