From bfb63ec91251b5c2ac98519ee91563b81d9d151c Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Thu, 17 Sep 2015 20:26:36 +0200 Subject: [PATCH] update ciao tests, update ciao itself --- package.json | 2 +- test/ciao/404.coffee | 4 +- .../autocomplete/basic_autocomplete.coffee | 10 +++-- test/ciao/autocomplete/null_island.coffee | 13 ++++-- test/ciao/index.coffee | 2 +- test/ciao/place/basic_place.coffee | 10 +++-- test/ciao/place/missing_id.coffee | 10 +++-- test/ciao/reverse/basic_reverse.coffee | 11 +++-- test/ciao/reverse/null_island.coffee | 11 +++-- test/ciao/search/address_parsing.coffee | 41 +++++++++++++++++++ test/ciao/search/basic_search.coffee | 10 +++-- test/ciao/search/no_params.coffee | 33 +++++++++++++++ test/ciao/search/null_island.coffee | 12 ++++-- 13 files changed, 140 insertions(+), 29 deletions(-) create mode 100644 test/ciao/search/address_parsing.coffee create mode 100644 test/ciao/search/no_params.coffee diff --git a/package.json b/package.json index 3acd057d..259528a9 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "through2": "0.6.5" }, "devDependencies": { - "ciao": "^0.3.4", + "ciao": "^0.6.0", "istanbul": "^0.3.13", "jshint": "^2.5.6", "nsp": "^0.3.0", diff --git a/test/ciao/404.coffee b/test/ciao/404.coffee index 764bc8d5..7a22618d 100644 --- a/test/ciao/404.coffee +++ b/test/ciao/404.coffee @@ -3,7 +3,7 @@ path: '/notexist' #? not found -response.statusCode.should.equal 404 +response.statusCode.should.be.equal 404 #? content-type header correctly set response.should.have.header 'Content-Type','application/json; charset=utf-8' @@ -14,4 +14,4 @@ response.should.have.header 'Cache-Control','public,max-age=300' #? should respond in json with server info should.exist json should.exist json.error -json.error.should.equal 'not found: invalid path' \ No newline at end of file +json.error.should.be.equal 'not found: invalid path' \ No newline at end of file diff --git a/test/ciao/autocomplete/basic_autocomplete.coffee b/test/ciao/autocomplete/basic_autocomplete.coffee index dadfc9dd..5c9278ca 100644 --- a/test/ciao/autocomplete/basic_autocomplete.coffee +++ b/test/ciao/autocomplete/basic_autocomplete.coffee @@ -3,7 +3,7 @@ path: '/v1/autocomplete?text=a' #? 200 ok -response.statusCode.should.equal 200 +response.statusCode.should.be.equal 200 response.should.have.header 'charset', 'utf8' response.should.have.header 'content-type', 'application/json; charset=utf-8' @@ -19,11 +19,15 @@ should.exist json.geocoding.engine.version should.exist json.geocoding.timestamp #? valid geojson -json.type.should.equal 'FeatureCollection' +json.type.should.be.equal 'FeatureCollection' json.features.should.be.instanceof Array #? expected errors should.not.exist json.geocoding.errors #? expected warnings -should.not.exist json.geocoding.warnings \ No newline at end of file +should.not.exist json.geocoding.warnings + +#? inputs +json.geocoding.query['text'].should.eql 'a' +json.geocoding.query['size'].should.eql 10 \ No newline at end of file diff --git a/test/ciao/autocomplete/null_island.coffee b/test/ciao/autocomplete/null_island.coffee index e2f8f46f..ad229069 100644 --- a/test/ciao/autocomplete/null_island.coffee +++ b/test/ciao/autocomplete/null_island.coffee @@ -1,9 +1,9 @@ #> null island -path: '/v1/autocomplete?text=a&lat=0&lon=0' +path: '/v1/autocomplete?text=a&focus.point.lat=0&focus.point.lon=0' #? 200 ok -response.statusCode.should.equal 200 +response.statusCode.should.be.equal 200 response.should.have.header 'charset', 'utf8' response.should.have.header 'content-type', 'application/json; charset=utf-8' @@ -19,11 +19,16 @@ should.exist json.geocoding.engine.version should.exist json.geocoding.timestamp #? valid geojson -json.type.should.equal 'FeatureCollection' +json.type.should.be.equal 'FeatureCollection' json.features.should.be.instanceof Array #? expected errors should.not.exist json.geocoding.errors #? expected warnings -should.not.exist json.geocoding.warnings \ No newline at end of file +should.not.exist json.geocoding.warnings + +#? inputs +json.geocoding.query['lat'].should.eql 0 +json.geocoding.query['lon'].should.eql 0 +json.geocoding.query['size'].should.eql 10 \ No newline at end of file diff --git a/test/ciao/index.coffee b/test/ciao/index.coffee index b495c747..8dd9da90 100644 --- a/test/ciao/index.coffee +++ b/test/ciao/index.coffee @@ -3,7 +3,7 @@ path: '/v1/' #? endpoint available -response.statusCode.should.equal 200 +response.statusCode.should.be.equal 200 #? content-type header correctly set response.should.have.header 'Content-Type','text/html; charset=utf-8' diff --git a/test/ciao/place/basic_place.coffee b/test/ciao/place/basic_place.coffee index 9e6f0e73..b734bff5 100644 --- a/test/ciao/place/basic_place.coffee +++ b/test/ciao/place/basic_place.coffee @@ -3,7 +3,7 @@ path: '/v1/place?id=geoname:1' #? 200 ok -response.statusCode.should.equal 200 +response.statusCode.should.be.equal 200 response.should.have.header 'charset', 'utf8' response.should.have.header 'content-type', 'application/json; charset=utf-8' @@ -19,11 +19,15 @@ should.exist json.geocoding.engine.version should.exist json.geocoding.timestamp #? valid geojson -json.type.should.equal 'FeatureCollection' +json.type.should.be.equal 'FeatureCollection' json.features.should.be.instanceof Array #? expected errors should.not.exist json.geocoding.errors #? expected warnings -should.not.exist json.geocoding.warnings \ No newline at end of file +should.not.exist json.geocoding.warnings + +#? inputs +json.geocoding.query['ids'].should.eql [{ id: '1', type: 'geoname' }] +should.not.exist json.geocoding.query['size'] \ No newline at end of file diff --git a/test/ciao/place/missing_id.coffee b/test/ciao/place/missing_id.coffee index 82bad4bf..4e851c3f 100644 --- a/test/ciao/place/missing_id.coffee +++ b/test/ciao/place/missing_id.coffee @@ -3,7 +3,7 @@ path: '/v1/place' #? 200 ok -response.statusCode.should.equal 200 +response.statusCode.should.be.equal 200 response.should.have.header 'charset', 'utf8' response.should.have.header 'content-type', 'application/json; charset=utf-8' @@ -19,7 +19,7 @@ should.exist json.geocoding.engine.version should.exist json.geocoding.timestamp #? valid geojson -json.type.should.equal 'FeatureCollection' +json.type.should.be.equal 'FeatureCollection' json.features.should.be.instanceof Array #? expected errors @@ -27,4 +27,8 @@ should.exist json.geocoding.errors json.geocoding.errors.should.eql [ 'invalid param \'id\': text length, must be >0' ] #? expected warnings -should.not.exist json.geocoding.warnings \ No newline at end of file +should.not.exist json.geocoding.warnings + +#? inputs +json.geocoding.query['ids'].should.eql [] +should.not.exist json.geocoding.query['size'] \ No newline at end of file diff --git a/test/ciao/reverse/basic_reverse.coffee b/test/ciao/reverse/basic_reverse.coffee index bba41310..d4d708ed 100644 --- a/test/ciao/reverse/basic_reverse.coffee +++ b/test/ciao/reverse/basic_reverse.coffee @@ -3,7 +3,7 @@ path: '/v1/reverse?point.lat=1&point.lon=2' #? 200 ok -response.statusCode.should.equal 200 +response.statusCode.should.be.equal 200 response.should.have.header 'charset', 'utf8' response.should.have.header 'content-type', 'application/json; charset=utf-8' @@ -19,11 +19,16 @@ should.exist json.geocoding.engine.version should.exist json.geocoding.timestamp #? valid geojson -json.type.should.equal 'FeatureCollection' +json.type.should.be.equal 'FeatureCollection' json.features.should.be.instanceof Array #? expected errors should.not.exist json.geocoding.errors #? expected warnings -should.not.exist json.geocoding.warnings \ No newline at end of file +should.not.exist json.geocoding.warnings + +#? inputs +json.geocoding.query['lat'].should.eql 1 +json.geocoding.query['lon'].should.eql 2 +json.geocoding.query['size'].should.eql 10 \ No newline at end of file diff --git a/test/ciao/reverse/null_island.coffee b/test/ciao/reverse/null_island.coffee index f1d26d38..5189a152 100644 --- a/test/ciao/reverse/null_island.coffee +++ b/test/ciao/reverse/null_island.coffee @@ -3,7 +3,7 @@ path: '/v1/reverse?point.lat=0&point.lon=0' #? 200 ok -response.statusCode.should.equal 200 +response.statusCode.should.be.equal 200 response.should.have.header 'charset', 'utf8' response.should.have.header 'content-type', 'application/json; charset=utf-8' @@ -19,11 +19,16 @@ should.exist json.geocoding.engine.version should.exist json.geocoding.timestamp #? valid geojson -json.type.should.equal 'FeatureCollection' +json.type.should.be.equal 'FeatureCollection' json.features.should.be.instanceof Array #? expected errors should.not.exist json.geocoding.errors #? expected warnings -should.not.exist json.geocoding.warnings \ No newline at end of file +should.not.exist json.geocoding.warnings + +#? inputs +json.geocoding.query['lat'].should.eql 0 +json.geocoding.query['lon'].should.eql 0 +json.geocoding.query['size'].should.eql 10 \ No newline at end of file diff --git a/test/ciao/search/address_parsing.coffee b/test/ciao/search/address_parsing.coffee new file mode 100644 index 00000000..83d3e1bc --- /dev/null +++ b/test/ciao/search/address_parsing.coffee @@ -0,0 +1,41 @@ + +#> address parsing +path: '/v1/search?text=30%20w%2026th%20st%2C%20ny' + +#? 200 ok +response.statusCode.should.be.equal 200 +response.should.have.header 'charset', 'utf8' +response.should.have.header 'content-type', 'application/json; charset=utf-8' + +#? valid geocoding block +should.exist json.geocoding +should.exist json.geocoding.version +should.exist json.geocoding.attribution +should.exist json.geocoding.query +should.exist json.geocoding.engine +should.exist json.geocoding.engine.name +should.exist json.geocoding.engine.author +should.exist json.geocoding.engine.version +should.exist json.geocoding.timestamp + +#? valid geojson +json.type.should.be.equal 'FeatureCollection' +json.features.should.be.instanceof Array + +#? expected errors +should.not.exist json.geocoding.errors + +#? expected warnings +should.not.exist json.geocoding.warnings + +#? inputs +json.geocoding.query['text'].should.eql '30 w 26th st, ny' +json.geocoding.query['size'].should.eql 10 + +#? address parsing +json.geocoding.query.parsed_text['name'].should.eql '30 w 26th st' +json.geocoding.query.parsed_text['number'].should.eql 30 +json.geocoding.query.parsed_text['street'].should.eql 'w 26th st' +json.geocoding.query.parsed_text['state'].should.eql 'NY' +json.geocoding.query.parsed_text['regions'].should.eql [] +json.geocoding.query.parsed_text['admin_parts'].should.eql "ny" \ No newline at end of file diff --git a/test/ciao/search/basic_search.coffee b/test/ciao/search/basic_search.coffee index 5db527be..039fe8f8 100644 --- a/test/ciao/search/basic_search.coffee +++ b/test/ciao/search/basic_search.coffee @@ -3,7 +3,7 @@ path: '/v1/search?text=a' #? 200 ok -response.statusCode.should.equal 200 +response.statusCode.should.be.equal 200 response.should.have.header 'charset', 'utf8' response.should.have.header 'content-type', 'application/json; charset=utf-8' @@ -19,11 +19,15 @@ should.exist json.geocoding.engine.version should.exist json.geocoding.timestamp #? valid geojson -json.type.should.equal 'FeatureCollection' +json.type.should.be.equal 'FeatureCollection' json.features.should.be.instanceof Array #? expected errors should.not.exist json.geocoding.errors #? expected warnings -should.not.exist json.geocoding.warnings \ No newline at end of file +should.not.exist json.geocoding.warnings + +#? inputs +json.geocoding.query['text'].should.eql 'a' +json.geocoding.query['size'].should.eql 10 \ No newline at end of file diff --git a/test/ciao/search/no_params.coffee b/test/ciao/search/no_params.coffee new file mode 100644 index 00000000..e374c6aa --- /dev/null +++ b/test/ciao/search/no_params.coffee @@ -0,0 +1,33 @@ + +#> no params specified +path: '/v1/search' + +#? 200 ok +response.statusCode.should.be.equal 200 +response.should.have.header 'charset', 'utf8' +response.should.have.header 'content-type', 'application/json; charset=utf-8' + +#? valid geocoding block +should.exist json.geocoding +should.exist json.geocoding.version +should.exist json.geocoding.attribution +should.exist json.geocoding.query +should.exist json.geocoding.engine +should.exist json.geocoding.engine.name +should.exist json.geocoding.engine.author +should.exist json.geocoding.engine.version +should.exist json.geocoding.timestamp + +#? valid geojson +json.type.should.be.equal 'FeatureCollection' +json.features.should.be.instanceof Array + +#? expected errors +should.exist json.geocoding.errors +json.geocoding.errors.should.eql [ 'invalid param \'text\': text length, must be >0' ] + +#? expected warnings +should.not.exist json.geocoding.warnings + +#? inputs +json.geocoding.query['size'].should.eql 10 \ No newline at end of file diff --git a/test/ciao/search/null_island.coffee b/test/ciao/search/null_island.coffee index 5d3d46d5..e620dc80 100644 --- a/test/ciao/search/null_island.coffee +++ b/test/ciao/search/null_island.coffee @@ -3,7 +3,7 @@ path: '/v1/search?text=a&focus.point.lat=0&focus.point.lon=0' #? 200 ok -response.statusCode.should.equal 200 +response.statusCode.should.be.equal 200 response.should.have.header 'charset', 'utf8' response.should.have.header 'content-type', 'application/json; charset=utf-8' @@ -19,11 +19,17 @@ should.exist json.geocoding.engine.version should.exist json.geocoding.timestamp #? valid geojson -json.type.should.equal 'FeatureCollection' +json.type.should.be.equal 'FeatureCollection' json.features.should.be.instanceof Array #? expected errors should.not.exist json.geocoding.errors #? expected warnings -should.not.exist json.geocoding.warnings \ No newline at end of file +should.not.exist json.geocoding.warnings + +#? inputs +json.geocoding.query['text'].should.eql 'a' +json.geocoding.query['size'].should.eql 10 +json.geocoding.query['lat'].should.eql 0 +json.geocoding.query['lon'].should.eql 0 \ No newline at end of file