add otm tes box
This commit is contained in:
parent
405dcaeba9
commit
70fa338f2f
@ -1,7 +1,7 @@
|
|||||||
import request from "supertest";
|
import request from "supertest"
|
||||||
import app from "../src/app";
|
import app from "../src/app"
|
||||||
import { Server, IncomingMessage, ServerResponse } from "http";
|
import { Server, IncomingMessage, ServerResponse } from "http"
|
||||||
import * as dotenv from "dotenv";
|
import * as dotenv from "dotenv"
|
||||||
|
|
||||||
dotenv.config({path: '../../.env'})
|
dotenv.config({path: '../../.env'})
|
||||||
const port = parseInt(process.env.BAR_PORT || '3000')
|
const port = parseInt(process.env.BAR_PORT || '3000')
|
||||||
@ -15,10 +15,10 @@ describe("Test the otm city path", () => {
|
|||||||
.get("/otm/city")
|
.get("/otm/city")
|
||||||
.query({'name':'La roche sur yon'})
|
.query({'name':'La roche sur yon'})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
expect(response.statusCode).toBe(200);
|
expect(response.statusCode).toBe(200)
|
||||||
done();
|
done()
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
|
||||||
test("It should response the GET method with content", done => {
|
test("It should response the GET method with content", done => {
|
||||||
const out = {
|
const out = {
|
||||||
@ -50,48 +50,48 @@ describe("Test the otm city path", () => {
|
|||||||
.then(response => {
|
.then(response => {
|
||||||
console.log(response.text)
|
console.log(response.text)
|
||||||
expect(response.text).toEqual(JSON.stringify(out))
|
expect(response.text).toEqual(JSON.stringify(out))
|
||||||
done();
|
done()
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
|
||||||
test("It should response the 400 code for GET method", done => {
|
test("It should response the 400 code for GET method", done => {
|
||||||
request(app)
|
request(app)
|
||||||
.get("/otm/city")
|
.get("/otm/city")
|
||||||
.then(response => {
|
.then(response => {
|
||||||
console.log(response.text)
|
console.log(response.text)
|
||||||
expect(response.statusCode).toBe(400);
|
expect(response.statusCode).toBe(400)
|
||||||
done();
|
done()
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
|
||||||
test("It should response the 200 code for GET method", done => {
|
test("It should response the 200 code for GET method", done => {
|
||||||
request(app)
|
request(app)
|
||||||
.get("/otm/radius")
|
.get("/otm/radius")
|
||||||
.query({'lon':'-1.4344594', 'lat' : '46.6686478', 'radius': '10'})
|
.query({'lon':'-1.4344594', 'lat' : '46.6686478', 'radius': '10'})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
expect(response.statusCode).toBe(200);
|
expect(response.statusCode).toBe(200)
|
||||||
done();
|
done()
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
|
||||||
test("It should response the 200 code for GET method (default radius)", done => {
|
test("It should response the 200 code for GET method (default radius)", done => {
|
||||||
request(app)
|
request(app)
|
||||||
.get("/otm/radius")
|
.get("/otm/radius")
|
||||||
.query({'lon':'-1.4344594', 'lat' : '46.6686478'})
|
.query({'lon':'-1.4344594', 'lat' : '46.6686478'})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
expect(response.statusCode).toBe(200);
|
expect(response.statusCode).toBe(200)
|
||||||
done();
|
done()
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
|
||||||
test("It should response the 400 code for GET method (missing lon and lat)", done => {
|
test("It should response the 400 code for GET method (missing lon and lat)", done => {
|
||||||
request(app)
|
request(app)
|
||||||
.get("/otm/radius")
|
.get("/otm/radius")
|
||||||
.then(response => {
|
.then(response => {
|
||||||
expect(response.statusCode).toBe(400);
|
expect(response.statusCode).toBe(400)
|
||||||
done();
|
done()
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
|
||||||
|
|
||||||
test("Get bar in radius from API", done => {
|
test("Get bar in radius from API", done => {
|
||||||
@ -121,9 +121,9 @@ describe("Test the otm city path", () => {
|
|||||||
.get("/otm/radius")
|
.get("/otm/radius")
|
||||||
.query({'lon':'-1.4344594', 'lat' : '46.6686478', 'radius': '10'})
|
.query({'lon':'-1.4344594', 'lat' : '46.6686478', 'radius': '10'})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
expect(response.text).toEqual(JSON.stringify(out));
|
expect(response.text).toEqual(JSON.stringify(out))
|
||||||
done();
|
done()
|
||||||
});
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
test("It should response the 200 code for GET method", done => {
|
test("It should response the 200 code for GET method", done => {
|
||||||
@ -131,10 +131,10 @@ describe("Test the otm city path", () => {
|
|||||||
.get("/otm/poidetaill")
|
.get("/otm/poidetaill")
|
||||||
.query({'id':'562635'})
|
.query({'id':'562635'})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
expect(response.statusCode).toBe(200);
|
expect(response.statusCode).toBe(200)
|
||||||
done();
|
done()
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
|
||||||
test("Get bar in radius from API", done => {
|
test("Get bar in radius from API", done => {
|
||||||
const out = {
|
const out = {
|
||||||
@ -171,17 +171,102 @@ describe("Test the otm city path", () => {
|
|||||||
.get("/otm/poidetaill")
|
.get("/otm/poidetaill")
|
||||||
.query({'id':'562635'})
|
.query({'id':'562635'})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
expect(response.text).toEqual(JSON.stringify(out));
|
expect(response.text).toEqual(JSON.stringify(out))
|
||||||
done();
|
done()
|
||||||
});
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
test("It should response the 400 code for GET method (no id)", done => {
|
||||||
|
request(app)
|
||||||
|
.get("/otm/poidetaill")
|
||||||
|
.then(response => {
|
||||||
|
expect(response.statusCode).toBe(400)
|
||||||
|
done()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
test("It should response the 200 code for GET method", done => {
|
test("It should response the 200 code for GET method", done => {
|
||||||
request(app)
|
request(app)
|
||||||
.get("/otm/poidetaill")
|
.get("/otm/box")
|
||||||
|
.query({'lon1':'-1.435199','lon2':'-1.43519', 'lat1':'46.668460', 'lat2':'46.668461'})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
expect(response.statusCode).toBe(400);
|
expect(response.statusCode).toBe(200)
|
||||||
done();
|
done()
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
});
|
|
||||||
|
test("Get bar in box from API", done => {
|
||||||
|
const out = {
|
||||||
|
"type": "FeatureCollection",
|
||||||
|
"features": [
|
||||||
|
{
|
||||||
|
"type": "Feature",
|
||||||
|
"id": "562633",
|
||||||
|
"geometry": {
|
||||||
|
"type": "Point",
|
||||||
|
"coordinates": [
|
||||||
|
-1.435197,
|
||||||
|
46.6684608
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"xid": "N4032296323",
|
||||||
|
"name": "Le Cube",
|
||||||
|
"rate": 1,
|
||||||
|
"osm": "node/4032296323",
|
||||||
|
"kinds": "foods,cafes,tourist_facilities"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
request(app)
|
||||||
|
.get("/otm/box")
|
||||||
|
.query({'lon1':'-1.435199','lon2':'-1.43519', 'lat1':'46.668460', 'lat2':'46.668461'})
|
||||||
|
.then(response => {
|
||||||
|
expect(response.text).toEqual(JSON.stringify(out))
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
test("Get bar in box from API lat reversed", done => {
|
||||||
|
const out = {
|
||||||
|
"type": "FeatureCollection",
|
||||||
|
"features": [
|
||||||
|
{
|
||||||
|
"type": "Feature",
|
||||||
|
"id": "562633",
|
||||||
|
"geometry": {
|
||||||
|
"type": "Point",
|
||||||
|
"coordinates": [
|
||||||
|
-1.435197,
|
||||||
|
46.6684608
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"xid": "N4032296323",
|
||||||
|
"name": "Le Cube",
|
||||||
|
"rate": 1,
|
||||||
|
"osm": "node/4032296323",
|
||||||
|
"kinds": "foods,cafes,tourist_facilities"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
request(app)
|
||||||
|
.get("/otm/box")
|
||||||
|
.query({'lon1':'-1.435199','lon2':'-1.43519', 'lat2':'46.668460', 'lat1':'46.668461'})
|
||||||
|
.then(response => {
|
||||||
|
expect(response.text).toEqual(JSON.stringify(out))
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
test("It should response the 400 code for GET method (no coordonaite)", done => {
|
||||||
|
request(app)
|
||||||
|
.get("/otm/box")
|
||||||
|
.then(response => {
|
||||||
|
expect(response.statusCode).toBe(400)
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
Loading…
x
Reference in New Issue
Block a user