import {apiAjax, expectBadRequest} from './test-utils';

function testVehicles() {
    describe('/vehicles', function() {
        this.timeout(5000);

        it('topLeft without bottomRight should not be accepted', (done) => {
            _expectBadVehiclesRequest({
                query: {
                    topLeft: '123.122:123.22'
                }
            }, done);
        });

        it('bottomRight without topLeft should not be accepted', (done) => {
            _expectBadVehiclesRequest({
                query: {
                    bottomRight: '123.122:123.22'
                }
            }, done);
        });

        it('invalid bottomRight should not be accepted', (done) => {
            _expectBadVehiclesRequest({
                query: {
                    bottomRight: '123.122'
                }
            }, done);
        });

        it('invalid line should not be accepted', (done) => {
            _expectBadVehiclesRequest({
                query: {
                    line: 'helsinkinotvalid.line'
                }
            }, done);
        });
    });
}

function _expectBadVehiclesRequest(ajaxOpts, done) {
    expectBadRequest(apiAjax('/vehicles', ajaxOpts)).nodeify(done);
}

export default testVehicles;

@@ -160,536 +160,44 @@
 it('
-topLeft without bottomRight should not be accepted', (done) =%3E %7B%0A            _expectBadVehiclesRequest(%7B%0A                query: %7B%0A                    topLeft: '123.122:123.22'%0A                %7D%0A            %7D, done);%0A        %7D);%0A%0A        it('bottomRight without topLeft should not be accepted', (done) =%3E %7B%0A            _expectBadVehiclesRequest(%7B%0A                query: %7B%0A                    bottomRight: '123.122:123.22'%0A                %7D%0A            %7D, done);%0A        %7D);%0A%0A        it('invalid bottomRight should not be accepted
+bounds with lower than 3 coordinates
 ', (
@@ -298,27 +298,23 @@
   bo
-ttomRight
+unds
 : 
+%5B
 '123.122
 '%0A  
@@ -309,17 +309,43 @@
 '123.122
-'
+:123.22', '123.122:123.22'%5D
 %0A       

Fix tests