'use strict';

import test from 'ava';
const app = require('./server.js');
const request = require('supertest');


test('foo', t => {
  t.pass();
});

test('bar', async t => {
  const bar = Promise.resolve('bar');

  t.is(await bar, 'bar');
});

test.skip('after succesfull login it returns 200 status and an object', async t => {
  t.plan(2);

  const res = await request(app)
      .post('/api/login')
      .send({ email: 'a@a.hu', password: 'a' });

  t.is(res.status, 200);
  t.true(typeof res.body === 'object');
});

test.skip('after unsuccesfull login it returns 401', async t => {
  t.plan(1);

  const res = await request(app)
      .post('/api/login')
      .send({ email: 'a@a.hu', password: 'aaa' });

  t.is(res.status, 401);
});

test('after register it returns 200 status and an object', async t => {
  t.plan(2);

  const res = await request(app)
      .post('/api/register')
      .send({ email: 'a@a.hu', password: 'aaa' });

  t.is(res.status, 200);
  t.true(typeof res.body === 'object');
});


test('wrong endpoint returns 404', async t => {
  t.plan(1);

  const res = await request(app)
    .get('/signupdfsd');

  t.is(res.status, 404);
});

@@ -38,19 +38,22 @@
 ;%0Aconst 
-app
+server
  = requi
@@ -106,24 +106,54 @@
 pertest');%0A%0A
+const myServer = server('');%0A%0A
 %0Atest('foo',
@@ -391,35 +391,40 @@
 = await request(
-app
+myServer
 )%0A      .post('/
@@ -655,35 +655,40 @@
 = await request(
-app
+myServer
 )%0A      .post('/
@@ -891,27 +891,32 @@
 ait request(
-app
+myServer
 )%0A      .pos
@@ -1151,11 +1151,16 @@
 est(
-app
+myServer
 )%0A  

test fixed