Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
340CT-Acer-Reseller-software-quality-and-process-management-/abdos-2018-master/BackEnd/__test__/app.test.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
78 lines (65 sloc)
1.8 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const app = require('../app') | |
const request = require('supertest') | |
const databaseData = { | |
host: 'localhost', | |
user: 'root', | |
password: '55', | |
database: 'acerreseller' | |
}; | |
describe("Computer", () => { | |
test('/computers should return 201', (done) => { | |
request(app).get('/api/v1.0/computers').then((response) => { | |
expect(response.statusCode).toBe(201) | |
done(); | |
}) | |
}); | |
}) | |
describe("purchase", () => { | |
const itemData = { | |
userID: 5, | |
title: "acer aspire 3", | |
device: "laptop", | |
type: "Gaming", | |
CPU: "i7", | |
RAM: "16GB", | |
GPU: "GTX 1080", | |
storage: "SSD", | |
size: "500GB", | |
price: 500 | |
} | |
test('/purchase should return 201', async () => { | |
const response = await request(app).post('/api/v1.0/purchase') | |
.send(itemData) | |
expect(response.statusCode).toBe(201) | |
}) | |
}) | |
describe("User", () => { | |
let userData = { | |
firstName: "Skengdo", | |
surname: "jaabir", | |
email: "twobunny@hotmail.co.uk", | |
username: "code", | |
password: "Password01." | |
} | |
test('/purchase should return 201', async () => { | |
const response = await request(app).post('/api/v1.0/users') | |
.send(userData) | |
expect(response.statusCode).toBe(201) | |
}) | |
test('/users should return 201', (done) => { | |
request(app).get('/api/v1.0/users').then((response) => { | |
expect(response.statusCode).toBe(201) | |
done(); | |
}) | |
}); | |
}); | |
describe("Login", () => { | |
const loginData = { | |
username: "abdos", | |
password: "Password01." | |
} | |
test('/login should return 401', async () => { | |
const response = await request(app).post('/api/v1.0/login') | |
expect(response.statusCode).toBe(401) | |
}) | |
}) |