mirror of https://github.com/xfarrow/blink
add test file
This commit is contained in:
parent
cfdac4872e
commit
b1e41237a4
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "blink_api",
|
||||
"version": "1.0.0",
|
||||
"description": "APIs for the Blink service",
|
||||
"main": "./src/app.js",
|
||||
"directories": {
|
||||
"test": "tests"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jest"
|
||||
},
|
||||
"author": "xfarrow",
|
||||
"license": "GPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"path": "^0.12.7"
|
||||
}
|
||||
}
|
|
@ -49,6 +49,11 @@ async function getPersonByEmail(email){
|
|||
.first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Person by Id
|
||||
* @param {*} id - The id to look the person for
|
||||
* @returns
|
||||
*/
|
||||
async function getPersonById(id){
|
||||
return await knex('Person')
|
||||
.select('*')
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
// Run me with "npm test"
|
||||
|
||||
const request = require('supertest');
|
||||
const app = require('../src/app');
|
||||
require('dotenv').config({ path: '../src/.env' });
|
||||
|
||||
describe('Person Tests', () => {
|
||||
test('Correct registration', async () => {
|
||||
const response = await request(app)
|
||||
.post('/api/register')
|
||||
.send({
|
||||
email : "johntestdoe@mail.org",
|
||||
password : "password",
|
||||
display_name : "John Doe"
|
||||
})
|
||||
expect(response.status).toBe(200);
|
||||
expect(response.body).toEqual({ activationLink: expect.any(String) });
|
||||
});
|
||||
|
||||
test('Incorrect registration', async () => {
|
||||
const response = await request(app)
|
||||
.post('/api/register')
|
||||
.send({
|
||||
email : "this is not an email",
|
||||
password : "password",
|
||||
display_name : "John Doe"
|
||||
})
|
||||
expect(response.status).toBe(400);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue