<commit_before>import { expect } from 'chai'
import startServer from '../src/server'

let server

describe('server', () => {
  before((done) => {
    startServer(9999, (err, serverInstant) => {
      server = serverInstant
      done()
    })
  })

  after((done) => {
    server.root.stop(() => {
      done()
    })
  })

  describe('serving content', () => {
    it('server response to GET request on root path', (done) => {
      const options = {
        method: 'GET',
        url: '/'
      }
      server.inject(options, (response) => {
        expect(response.statusCode).to.equal(200)
        expect(response.headers['content-type']).to.include('html')
        done()
      })
    })

    it('server response to GET request on bundle.js', (done) => {
      const options = {
        method: 'GET',
        url: '/static/bundle.js'
      }
      server.inject(options, (response) => {
        expect(response.statusCode).to.equal(200)
        expect(response.headers['content-type']).to.include('javascript')
        done()
      })
    })
  })

  //
  // Still don't know how to handle server instant when testing seperate file.
  // So put them all in this file for now.
  //

  describe('auth api', () => {
    let ssid

    it('allow user to login', (done) => {
      const options = {
        method: 'POST',
        url: '/api/auth/login',
        payload: {
          email: '<EMAIL>',
          password: '<PASSWORD>'
        }
      }
      server.inject(options, (response) => {
        expect(response.statusCode).to.equal(200)
        expect(response.result.message).to.equal('success')
        expect(response.result.ssid).to.exist
        ssid = response.result.ssid
        done()
      })
    })

    it('login with invalid password', (done) => {
      const options = {
        method: 'POST',
        url: '/api/auth/login',
        payload: {<commit_msg>cleanup<commit_after>import { expect } from 'chai'
import startServer from '../src/server'

let server

describe('server', () => {
  before((done) => {
    startServer(9999, (err, serverInstant) => {
      server = serverInstant
      done()
    })
  })

  after((done) => {
    server.root.stop(() => {
      done()
    })
  })

  describe('serving content', () => {
    it('server response to GET request on root path', (done) => {
      const options = {
        method: 'GET',
        url: '/'
      }
      server.inject(options, (response) => {
        expect(response.statusCode).to.equal(200)
        expect(response.headers['content-type']).to.include('html')
        done()
      })
    })

    it('server response to GET request on bundle.js', (done) => {
      const options = {
        method: 'GET',
        url: '/static/bundle.js'
      }
      server.inject(options, (response) => {
        expect(response.statusCode).to.equal(200)
        expect(response.headers['content-type']).to.include('javascript')
        done()
      })
    })
  })

  //
  // Still don't know how to handle server instant when testing on a seperate file.
  // So put them all in this file for now.
  //

  describe('auth api', () => {
    let ssid

    it('allow user to login', (done) => {
      const options = {
        method: 'POST',
        url: '/api/auth/login',
        payload: {
          email: '<EMAIL>',
          password: '<PASSWORD>'
        }
      }
      server.inject(options, (response) => {
        expect(response.statusCode).to.equal(200)
        expect(response.result.message).to.equal('success')
        expect(response.result.ssid).to.exist
        ssid = response.result.ssid
        done()
      })
    })

    it('login with invalid password', (done) => {
      const options = {
        method: 'POST',
        url: '/api/auth/login',
        payload: {
{'fraction_non_alphanumeric': 0.16369917618921073, 'fraction_numerical': 0.006909380813180973, 'mean_word_length': 2.057676685621446, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6570154', 'n_tokens_mistral': 1165, 'n_tokens_neox': 1126, 'n_words': 246}