<commit_before>const server = require('../src/server/index.js');
const expect = require('chai').expect;
const request = require('supertest')('http://localhost:3000');

describe('Server tests', () => {
	const VERSION_RESPONSE = "Version:1"
	const NAME_1 = 'lola'
	const NAME_2 = 'buffy'
	const NAME_3 = 'sasha'

	it('should get'+ VERSION_RESPONSE, (done) => {
		request.
		get('/').
		expect(200, VERSION_RESPONSE, done)
	})

	it('should get list of names', (done) =>{
		request.
		get('/names').
		expect(200).
		end((err, response) =>{
			if (err) {
				throw err
			}
			expect(response.body).to.be.instanceof(Array)
			expect(response.body[0]).to.be.an('string')
			done()	
		})

	})

	it('should add a name', (done) => {
		request.
		post('/names').
		send({name: NAME_1}).
		expect(201).
		end((err, response) => {
			if (err) {
				throw err
			}
			expect(response.header).to.have.property('location','/names/'+ NAME_1)
			done()
		})
		
	})

	it('should give error for trying to add same resource more then once', (done) => {
		request.
		post('/names').
		send({name: NAME_1}).
		expect(409,'', done)
	})

	it('should add value using PUT as well', (done) => {
		request.
		put(/names/+ NAME_2).
		send({name: NAME_2}).
		expect(204, '', done)
	})

	it('should allow to put same value', (done) => {
		request.
		put(/names/+ NAME_2).
		send({name: NAME_2}).
		expect(204, '', done)
	})

	it('should update value', (done) => {
		request.
		put(/names/+ NAME_2).
		send({name: NAME_3}).
		expect(204, '', done)
	})

	it('should delete value',(done) => {
		request.
		delete(/names/+ NAME_3).
		send().
		expect(200,'', done)
	})

	it('should fail to delete not existing value',(done) => {
		request.
		delete(/names/+ NAME_3).
		send().
		expect(404,'', done)
	})

//end of tests
})<commit_msg>server complete<commit_after>const server = require('../src/server/index.js');
const expect = require('chai').expect;
const request = require('supertest')('http://localhost:3000');

describe('Server tests', () => {
	const VERSION_RESPONSE = "Version:1"
	const NAME_1 = 'lola'
	const NAME_2 = 'buffy'
	const NAME_3 = 'sasha'
	const BASE = ["Fortuna", "Moka", "Karashindo" , "Tyron"]

	it('should get'+ VERSION_RESPONSE, (done) => {
		request.
		get('/').
		expect(200, VERSION_RESPONSE, done)
	})

	it('should get list of names', (done) =>{
		request.
		get('/names').
		expect(200).
		end((err, response) =>{
			if (err) {
				throw err
			}
			expect(response.body).to.be.instanceof(Array)
			expect(response.body[0]).to.be.an('string')
			done()	
		})

	})

	it('should add a name', (done) => {
		request.
		post('/names').
		send({name: NAME_1}).
		expect(201).
		end((err, response) => {
			if (err) {
				throw err
			}
			expect(response.header).to.have.property('location','/names/'+ NAME_1)
			done()
		})
		
	})

	it('should give error for trying to add same resource more then once', (done) => {
		request.
		post('/names').
		send({name: NAME_1}).
		expect(409,'', done)
	})

	it('should add value using PUT as well', (done) => {
		request.
		put(/names/+ NAME_2).
		send({name: NAME_2}).
		expect(204, '', done)
	})

	it('should allow to put same value', (done) => {
		request.
		put(/names/+ NAME_2).
		send({name: NAME_2}).
		expect(204, '', done)
	})

	it('should update value', (done) => {
		request.
		put(/names/+ NAME_2).
		send({name: NAME_3}).
		expect(204, '', done)
	})

	it('should delete value',(done) => {
		request.
		delete(/names/+ NAME_3).
		send().
		expect(200,'', done)
	})

	it('should fail to delete not existing value',(done) => {
		request.
		delete(/names/+ NAME_3).
		send().
		expect(404,'', done)
	})

	it('check server state', (done) =>{
		request.
		get('/names').
		expect(200).
		end((err, response) =>{
			if (err) {
				throw err
			}
			expect(response.body).to.be.instanceof(Array)
			expect(response.body).to.have.members(BASE.concat(NAME_1))
			done()	
		})

	})	

//end of tests
})
{'fraction_non_alphanumeric': 0.20722095092804474, 'fraction_numerical': 0.024917365878464277, 'mean_word_length': 3.308871851040526, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 29, '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': '2076529', 'n_tokens_mistral': 1710, 'n_tokens_neox': 1462, 'n_words': 329}