const chai = require('chai');
const chaiHttp = require('chai-http');
const server = require('../app');
const should = [Link]();
const BlueBird = require('bluebird');
const Trades = require('../models/trades');
[Link](chaiHttp);
const setup = (...userObjects) => {
return [Link](userObjects, user => {
return [Link](server)
.post('/trades')
.send(user)
.then(response => {
return [Link];
})
})
}
describe('stock_trades_api_easy_sequelize', () => {
const user23ABX = {
"type": "buy",
"user_id": 23,
"symbol": "ABX",
"shares": 30,
"price": 134,
"timestamp": 1591522701000
}
const user23AAC = {
"type": "buy",
"user_id": 23,
"symbol": "AAC",
"shares": 12,
"price": 133,
"timestamp": 1591572701000
};
beforeEach(async () => {
await [Link]();
})
afterEach(async () => {
await [Link]();
})
it('should create a new trade', async () => {
const response1 = await
[Link](server).post('/trades').send(user23ABX)
[Link](201);
delete [Link];
[Link](user23ABX)
const response2 = await
[Link](server).post('/trades').send(user23AAC)
[Link](201);
delete [Link];
[Link](user23AAC)
});
it('should fetch all the trades', async () => {
const results = await setup(user23AAC, user23ABX);
const response = await [Link](server).get('/trades')
[Link](200);
[Link](results);
})
it('should fetch a single trade', async () => {
const [trade] = await setup(user23AAC);
const response = await [Link](server).get(`/trades/${[Link]}`)
[Link](200);
[Link](trade);
})
it('should get 404 if the trade ID does not exist', async () => {
const response = await [Link](server).get(`/trades/32323`)
[Link](404);
[Link]('ID not found');
})
it('should get 405 for a put request to /trades/:id', async () => {
const [trade] = await setup(user23AAC);
const response = await [Link](server).put(`/trades/$
{[Link]}`).send(user23ABX)
[Link](405);
})
it('should get 405 for a patch request to /trades/:id', async () => {
const [trade] = await setup(user23AAC);
const response = await [Link](server).patch(`/trades/$
{[Link]}`).send(user23ABX)
[Link](405);
})
it('should get 405 for a delete request to /trades/:id', async () => {
const [trade] = await setup(user23AAC);
const response = await [Link](server).delete(`/trades/${[Link]}`)
[Link](405);
})
});