'use strict';

const request = require('supertest');
const should = require('should');
const Server = require('../lib/Server');
const DataStore = require('../lib/stores/DataStore');

describe('Server', () => {
    const server = new Server();
    server.datastore = new DataStore({
        path: '/files'
    });

    it('should allow for method overriding', (done) => {
        
        request(server.listen())
          .get('/')
          .set('X-HTTP-Method-Override', 'POST')
          .expect(204, '', done);
    });

    it('should 204 !GET requests without the Tus header', (done) => {
        request(server.listen())
          .post('/')
          .expect(204, '', done);
    });

    it('should return a location for file create api', (done) => {
        request(server.listen())
          .post('/files')
          .set('Tus-Resumable', '1.0.0')
          .set('Upload-Length', '1234')
          .expect(201, done)
          .end((err, res) => {
              res.headers.should.have.property('location');
              done();
          });
    });
});

@@ -76,24 +76,58 @@
 ('should');%0A
+const assert = require('assert');%0A
 const Server
@@ -245,37 +245,155 @@
     
-const server = new Server();%0A
+it('setting the DataStore should attach handlers', (done) =%3E %7B%0A        const server = new Server();%0A        server.handlers.should.be.empty();%0A    
     
@@ -435,16 +435,20 @@
         
+    
 path: '/
@@ -462,714 +462,1428 @@
     
+   
+ 
 %7D);%0A
-%0A
+  
     
-it('should allow for method overriding', (done) =%3E %7B%0A        %0A        request(server.listen())%0A          .get('/')%0A          .set('X-HTTP-Method-Override', 'POST')%0A          .expect(204, '', done);%0A    %7D);%0A%0A    it('should 204 !GET requests without the Tus header', (done) =%3E %7B%0A        request(server.listen())%0A          .post('/')%0A          .expect(204, '', done);%0A    %7D);%0A%0A    it('should return a location for file create api', (done) =%3E %7B%0A        request(server.listen())%0A          .post('/files')%0A          .set('Tus-Resumable', '1.0.0')%0A          .set('Upload-Length', '1234')%0A          .expect(201, done)%0A          .end((err, res) =%3E %7B%0A              res.headers.should.have.property('location
+  server.handlers.should.have.property('HEAD');%0A        server.handlers.should.have.property('OPTIONS');%0A        server.handlers.should.have.property('POST');%0A        server.handlers.should.have.property('PATCH');%0A        done();%0A    %7D);%0A%0A    const server = new Server();%0A    server.datastore = new DataStore(%7B%0A        path: '/files'%0A    %7D);%0A%0A    it('should 204 !GET requests without the Tus header', (done) =%3E %7B%0A        request(server.listen())%0A          .post('/')%0A          .expect(204, '', done);%0A    %7D);%0A%0A    it('should 404 other requests', (done) =%3E %7B%0A        request(server.listen())%0A          .get('/')%0A          .set('Tus-Resumable', '1.0.0')%0A          .expect(404, 'Not found', done)%0A    %7D);%0A%0A    it('should implement creation extension', (done) =%3E %7B%0A        request(server.listen())%0A          .post('/files')%0A          .set('Tus-Resumable', '1.0.0')%0A          .set('Upload-Length', '1234')%0A          .expect(201, done)%0A          .end((err, res) =%3E %7B%0A              res.headers.should.have.property('location');%0A              done();%0A          %7D);%0A    %7D);%0A%0A    it('should respond the tus header', (done) =%3E %7B%0A        request(server.listen())%0A          .head('/')%0A          .set('Tus-Resumable', '1.0.0')%0A          .expect(204, null, done)%0A          .end((err, res) =%3E %7B%0A              res.headers.should.have.property('tus-resumable');%0A              res.headers%5B'tus-resumable'%5D.should.equal('1.0.0
 ');%0A

Update server tests