{"size": 988, "ext": "js", "max_stars_repo_path": "__test__/auth-routes.test.js", "max_stars_repo_name": "evan-woodworth/riddleMeThis", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "__test__/auth-routes.test.js", "max_issues_repo_name": "evan-woodworth/riddleMeThis", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "__test__/auth-routes.test.js", "max_forks_repo_name": "evan-woodworth/riddleMeThis", "max_forks_repo_forks_event_min_datetime": "2021-10-29T20:55:03.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-29T20:55:03.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 21.9555555556, "max_line_length": 62, "alphanum_fraction": 0.6174089069}
'use strict';

require('dotenv');
const SECRET = process.env.SECRET;
const supertest = require('supertest');
const { server } = require('../src/server.js');
const { db } = require('../src/models/index.js');
const base64 = require('base-64');
const { expect } = require('@jest/globals')

const authRequest = supertest(server);

beforeAll(async (done) => {
  await db.sync();
  done();
});
afterAll(async (done) => {
  await db.drop();
  done();
});

describe('Testing Auth Routes', () => {
  
  it('Should create a new user on POST /signup', async () => {
    let response = await authRequest.post('/signup').send({
      username: 'Joe',
      password: 'test',
    });

    expect(response.status).toBe(201);
  })

  it('Should login a user on POST /signin', async () => {
    let encodedString = base64.encode('Joe:test');

    let response = await authRequest.post('/signin').set({
      Authorization: `Basic ${encodedString}`
    });

    expect(response.status).toBe(200)
  })

})

