Skip to content

Commit

Permalink
Merge pull request #11 from Build-Week-African-Marketplace-II/neel-ma…
Browse files Browse the repository at this point in the history
…zumdar

Neel mazumdar
  • Loading branch information
neel7777 authored May 29, 2020
2 parents 69b9af6 + fd39580 commit 0f079b6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
23 changes: 23 additions & 0 deletions __test__/product.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const supertest = require('supertest')
const server = require('../api/server')
const db = require('../data/db-Config')
describe('Products test', () => {
it('Products add sucessfully', async () => {
const res = await supertest(server).post('/api/products')
.send({
name: 'orange',
description: 'Its orange',
market_location: 'trees',
quantity: '10',
price: '25',
user_id: 1
})
expect(res.status).toBe(200)
})
it("should return json", async () => {
const res = await supertest(server)
.post("/api/products")
.send({ name: "grapes", description: "theyre sweet", quantity: "35", price:"10", user_id: 1 });
expect(res.type).toBe("application/json");
});
})
6 changes: 3 additions & 3 deletions __test__/user.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('register', () => {
it("register success", async () => {
const res = await supertest(server).post('/api/auth/register')
.send({
username: 'john1',
username: 'john2',
password: 'test',
email: '[email protected]'
})
Expand All @@ -34,7 +34,7 @@ describe('login', () => {
it('login success', async () => {
const res = await supertest(server).post('/api/auth/login')
.send({
username: 'john1',
username: 'john2',
password: 'test',
email: '[email protected]'
})
Expand All @@ -44,7 +44,7 @@ describe('login', () => {
it('login fail', async () => {
const res = await supertest(server).post('/api/auth/login')
.send({
username: 'john1',
username: 'john2',
password: 't3st',
email: '[email protected]'
})
Expand Down
Binary file modified data/auth.db3
Binary file not shown.
2 changes: 1 addition & 1 deletion products/products-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ router.get('/', (req, res) => {
res.status(200).json(product)
})
.catch(err => {
res.status(500).json({ error: 'Something went wrong'})
res.status(500).json({ error: 'Something went wrong', err})
})
})

Expand Down

0 comments on commit 0f079b6

Please sign in to comment.