<commit_before>import mongoose from 'mongoose';
import request from 'supertest-as-promised';
import httpStatus from 'http-status';
import chai, { expect } from 'chai';

import config from '../config/config';
import app from '../index';

chai.config.includeStack = true;

after((done) =>  {
  mongoose.models = {};
  mongoose.modelSchemas = {};
  mongoose.connection.close();
  done();
});

describe('## Server APIs', () => {
  let server = {
    domain: 'testdomain.xyz',
    name: 'testServer',
    description: 'The first server\'s description',
    keypair: {
      public: 'xxxxxx'
    },
    authoritative: true
  }

  let server2 = {
    domain: 'testdomain2.xyz',
    name: 'testServer2',
    description: 'The second server\'s description',
    keypair: {
      public: 'xxxxxx'
    },
    authoritative: true
  }

  describe('# POST /api/servers', () => {
    it('should create a new server', (done) => {
     request(app)
       .post('/api/servers')
       .send(server)
       .expect(httpStatus.OK)
       .then((res) => {
         expect(res.body.name).to.equal(server.name);
         server = res.body;
       })
       .catch(done);

     request(app)
       .post('/api/servers')
       .send(server2)
       .expect(httpStatus.OK)
       .then((res) => {
         expect(res.body.name).to.equal(server2.name);
         server2 = res.body;
         done();
       })
       .catch(done);

    });
  });
  
  describe('# GET /api/servers/:serverId', () => {
    it('should get server details', (done) => {
     request(app)
        .get(`/api/servers/${server.id}`)
        .expect(httpStatus.OK)
        .then((res) => {
          expect(res.body.name).to.equal(server.name);
          expect(res.body.domain).to.equal(server.domain);
          done();
        })
        .catch(done);
    });
  });

  describe('# PUT /api/servers/:serverId', () => {
    it('should update server details', (done) => {
      server.name = 'New Server name';
      request(app)
        .put(`/api/servers/${server.id}`)
        .send(server)
        .expect(httpStatus.OK)
        .then((res) => {
          expect(res.body.name).to.equal(server.name);
          expect(res.body.domain).to.equal(server.domain);
          done();
        })
        .catch(done);
    });

    describe('# GET /api/servers', () => {
      it('should get all servers', (done) => {
        request(app)
          .get('/api/servers')
          .expect(httpStatus.OK)
          .then((res) => {
            expect(res.body).to.be.an('array');
            done();
          })
          .catch(done);
      });
    });
    
    describe('# DELETE /api/servers/:serverId', () => {
      it('should delete server', (done) => {
        request(app)
          .delete(`/api/servers/${server.id}`)
          .expect(httpStatus.OK)
          .then((res) => {
            expect(res.body.name).to.equal(server.name);
            expect(res.body.domain).to.equal(server.domain);
          })
          .catch(done);

        request(app)
          .delete(`/api/servers/${server2.id}`)
          .expect(httpStatus.OK)
          .then((res) => {
            expect(res.body.name).to.equal(server2.name);
            expect(res.body.domain).to.equal(server2.domain);
            done();
          })
          .catch(done);

      });
    });
  });

});<commit_msg>syntax fixes<commit_after>import mongoose from 'mongoose';
import request from 'supertest-as-promised';
import httpStatus from 'http-status';
import chai, { expect } from 'chai';

import app from '../index';

chai.config.includeStack = true;

after((done) => {
  mongoose.models = {};
  mongoose.modelSchemas = {};
  mongoose.connection.close();
  done();
});

describe('## Server APIs', () => {
  let server = {
    domain: 'testdomain.xyz',
    name: 'testServer',
    description: 'The first server\'s description',
    keypair: {
      public: 'xxxxxx'
    },
    authoritative: true
  };

  let server2 = {
    domain: 'testdomain2.xyz',
    name: 'testServer2',
    description: 'The second server\'s description',
    keypair: {
      public: 'xxxxxx'
    },
    authoritative: true
  };

  describe('# POST /api/servers', () => {
    it('should create a new server', (done) => {
      request(app)
        .post('/api/servers')
        .send(server)
        .expect(httpStatus.OK)
        .then((res) => {
           expect(res.body.name).to.equal(server.name);
           server = res.body;
         })
         .catch(done);

      request(app)
        .post('/api/servers')
        .send(server2)
        .expect(httpStatus.OK)
        .then((res) => {
           expect(res.body.name).to.equal(server2.name);
           server2 = res.body;
           done();
         })
         .catch(done);
    });
  });

  describe('# GET /api/servers/:serverId', () => {
    it('should get server details', (done) => {
      request(app)
        .get(`/api/servers/${server.id}`)
        .expect(httpStatus.OK)
        .then((res) => {
          expect(res.body.name).to.equal(server.name);
          expect(res.body.domain).to.equal(server.domain);
          done();
        })
        .catch(done);
    });
  });

  describe('# PUT /api/servers/:serverId', () => {
    it('should update server details', (done) => {
      server.name = 'New Server name';
      request(app)
        .put(`/api/servers/${server.id}`)
        .send(server)
        .expect(httpStatus.OK)
        .then((res) => {
          expect(res.body.name).to.equal(server.name);
          expect(res.body.domain).to.equal(server.domain);
          done();
        })
        .catch(done);
    });

    describe('# GET /api/servers', () => {
      it('should get all servers', (done) => {
        request(app)
          .get('/api/servers')
          .expect(httpStatus.OK)
          .then((res) => {
            expect(res.body).to.be.an('array');
            done();
          })
          .catch(done);
      });
    });
 
    describe('# DELETE /api/servers/:serverId', () => {
      it('should delete server', (done) => {
        request(app)
          .delete(`/api/servers/${server.id}`)
          .expect(httpStatus.OK)
          .then((res) => {
            expect(res.body.name).to.equal(server.name);
            expect(res.body.domain).to.equal(server.domain);
          })
          .catch(done);

        request(app)
          .delete(`/api/servers/${server2.id}`)
          .expect(httpStatus.OK)
          .then((res) => {
            expect(res.body.name).to.equal(server2.name);
            expect(res.body.domain).to.equal(server2.domain);
            done();
          })
          .catch(done);

      });
    });
  });
});
{'fraction_non_alphanumeric': 0.18568636295293942, 'fraction_numerical': 0.0027063599458728013, 'mean_word_length': 1.9060725207514198, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 41, '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': '3059165', 'n_tokens_mistral': 2117, 'n_tokens_neox': 2126, 'n_words': 335}