-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadd.js
48 lines (42 loc) · 959 Bytes
/
add.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const { prisma, app, run } = require('./index')
const supertest = require('supertest')
const request = supertest(app)
beforeAll((done) => {
done();
})
afterAll(async (done) => {
await prisma.inventory.deleteMany()
await prisma.$disconnect()
run.close()
done()
})
const item1 = {
product: 'Test Item',
product_category: 'Test Category',
qty: '30',
price: '27.99',
vendor: 'Test Vendor',
location: 'Test Location'
}
const item2 = {
product: 'Test Item 2',
product_category: 'Test Category',
qty: '30.o',
price: '27.adj',
vendor: 'Test Vendor',
location: 'Test Location'
}
it("creates an item", async done => {
const response = await request
.post("/create")
.send(item1)
.expect(302)
done()
})
it("creates an item with wrong data", async () => {
const response = await request
.post("/create")
.send(item2)
.expect(400)
expect(response.body).toEqual({"error": "Wrong data entered"})
})