mirror of
https://github.com/xfarrow/blink
synced 2025-03-23 13:20:04 +01:00
add test file
This commit is contained in:
parent
cfdac4872e
commit
b1e41237a4
17
backend/apis/nodejs/package.json
Normal file
17
backend/apis/nodejs/package.json
Normal file
@ -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('*')
|
||||
|
30
backend/apis/nodejs/tests/person.test.js
Normal file
30
backend/apis/nodejs/tests/person.test.js
Normal file
@ -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…
x
Reference in New Issue
Block a user