-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added more tests with auth - bug fix broadcast
- Loading branch information
Showing
8 changed files
with
79 additions
and
18 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,22 @@ const { expect } = require("expect") | |
const supertest = require('supertest') | ||
const {app} = require('./server/test_server.js') | ||
|
||
async function logAndToken(){ | ||
const response = await supertest(app).post("/api/consumer/login/") | ||
.send({ | ||
email: "[email protected]", | ||
password: "abCD12#$" | ||
}) | ||
.set('Accept', 'application/json') | ||
.set('Content-Type', 'application/json') | ||
|
||
return response._body.data | ||
} | ||
|
||
|
||
|
||
|
||
|
||
test('demo testing for sum', () => { | ||
expect(1 + 2).toBe(3) | ||
}) | ||
|
@@ -13,4 +29,50 @@ test('testing get all services', async () => { | |
return | ||
}) | ||
|
||
test('testing login user', async () => { | ||
const response = await supertest(app).post("/api/consumer/login/") | ||
.send({ | ||
email: "[email protected]", | ||
password: "abCD12#$" | ||
}) | ||
.set('Accept', 'application/json') | ||
.set('Content-Type', 'application/json') | ||
expect(response._body.data).not.toBe(null) | ||
}) | ||
|
||
test('getting profile data', async () => { | ||
const tokn = await logAndToken() | ||
const response = await supertest(app).get("/api/consumer/profile") | ||
.set('Accept', 'application/json') | ||
.set('Content-Type', 'application/json') | ||
.set("Authorization", `Bearer ${tokn}`) | ||
// console.log(response) | ||
expect(response._body.data).not.toBe(null) | ||
}) | ||
|
||
test('getting list of broadcast', async () => { | ||
const tkn = await logAndToken(); | ||
const response = await supertest(app).get("/api/consumer/viewbroadcast") | ||
.set('Accept', 'application/json') | ||
.set('Content-Type', 'application/json') | ||
.set("Authorization", `Bearer ${tkn}`) | ||
|
||
console.log(response._body) | ||
expect(response._body.data).not.toBe(null) | ||
}) | ||
|
||
test('fetching seller details for customer', async () => { | ||
const tkn = await logAndToken(); | ||
const response = await supertest(app).post("/api/consumer/sellerprofileview") | ||
.send({ | ||
pointer: "seller-id" | ||
}) | ||
.set('Accept', 'application/json') | ||
.set('Content-Type', 'application/json') | ||
.set("Authorization", `Bearer ${tkn}`) | ||
|
||
// console.log(response._body) | ||
expect(response._body.data).toBe(undefined) | ||
}) | ||
|
||
// Finalise |
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
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
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
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
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
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
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