auth init
This commit is contained in:
1 parent
faa2e70e08
commit
413aeedadf
29 files changed
+2854
-649
No files matched your search
@@ -0,0 +1,48 @@
|
||||
import assert from 'assert/strict';
|
||||
import axios from 'axios';
|
||||
|
||||
import createServices from './services';
|
||||
import createLog from './log';
|
||||
|
||||
const log = createLog();
|
||||
log.level('error');
|
||||
const services = createServices(log);
|
||||
|
||||
const HOST = 'http://localhost:41337';
|
||||
|
||||
before(function setup() {
|
||||
console.log('setup')
|
||||
services.api.listen();
|
||||
});
|
||||
|
||||
after(function teardown(done) {
|
||||
services.api.server.close(done)
|
||||
});
|
||||
|
||||
describe('api', function apiTests() {
|
||||
it('listens', async function listenTest() {
|
||||
const res = await axios.get(`${HOST}/health`);
|
||||
assert.equal(res.status, 200);
|
||||
});
|
||||
|
||||
it('register', async function register() {
|
||||
const body = {
|
||||
email: `test+${Date.now()}@user.com`,
|
||||
password: 'woaaah theres no limit',
|
||||
};
|
||||
const { data } = await axios.post(`${HOST}/auth/register`, body);
|
||||
assert.equal(data.email, body.email);
|
||||
});
|
||||
|
||||
it('login', async function login() {
|
||||
const body = {
|
||||
email: `test+${Date.now()}@user.com`,
|
||||
password: 'woaaah theres no limit',
|
||||
};
|
||||
await axios.post(`${HOST}/auth/register`, body);
|
||||
const res = await axios.post(`${HOST}/auth/login`, body);
|
||||
assert(res.headers['set-cookie']);
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user