123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- process.env.NODE_ENV = 'test'
- let chai = require('chai')
- let server = require('../server')
- let should = chai.should()
- let { sequelize } = require('../models')
- const Errors = require('../lib/errors.js')
- chai.use(require('chai-http'))
- chai.use(require('chai-things'))
- describe('Thread and post', () => {
- let userAgent
- //Wait for app to start before commencing
- before((done) => {
- if(server.locals.appStarted) createUser()
- server.on('appStarted', () => {
- createUser()
- })
- function createUser() {
- userAgent = chai.request.agent(server)
- userAgent
- .post('/api/v1/user')
- .set('content-type', 'application/json')
- .send({
- username: 'username',
- password: 'password',
- })
- .then(() => {
- done()
- })
- .catch(done)
- }
- })
- //Delete all rows in table after
- //tests completed
- after(() => {
- sequelize.sync({ force: true })
- })
- describe('POST /thread', () => {
- it('should create a thread if logged in', async () => {})
- it('should return an error if not logged in', async () => {})
- it('should return an error if missing parameters', async () => {})
- it('should return an error if invalid types', async () => {})
- it('should return an error if category does not exist', async () => {})
- })
- describe('GET /thread/:id', () => {
- it('should return the thread and corresponding posts', async () => {})
- it('should return an error if :id is invalid', async () => {})
- })
- describe('POST /post', () => {
- it('should create a post if logged in', async () => {})
- it('should return an error if not logged in', async () => {})
- it('should return an error if missing parameters', async () => {})
- it('should return an error if invalid types', async () => {})
- it('should return an error if thread id does not exist', async () => {})
- it('should be able to reply to a post', async () => {})
- it('should return an error if reply id does not exist', async () => {})
- it('should return an error if post reply not in same thread', async () => {})
- })
- describe('GET /post/:id', () => {
- it('should return the post', async () => {})
- it('should return an error if invalid post id', async () => {})
- })
- })
|