This repository has been archived by the owner on May 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure that the json property is set when the content is JSON (#140)
* Change all calls to request to use the body property instead of the json property * json property is now set if the produces or consumes is a JSON media type
- Loading branch information
Showing
36 changed files
with
518 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
test/jsonProperty/compare/request/expect/no-property-user-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
'use strict'; | ||
var chai = require('chai'); | ||
var request = require('request'); | ||
var expect = chai.expect; | ||
|
||
describe('/user', function() { | ||
describe('get', function() { | ||
it('should respond with 200 OK', function(done) { | ||
request({ | ||
url: 'https://api.uber.com/user', | ||
json: true, | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
} | ||
}, | ||
function(error, res, body) { | ||
if (error) return done(error); | ||
|
||
expect(res.statusCode).to.equal(200); | ||
|
||
expect(body).to.equal(null); // non-json response or no schema | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should respond with 400 NOT OK', function(done) { | ||
request({ | ||
url: 'https://api.uber.com/user', | ||
json: true, | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
} | ||
}, | ||
function(error, res, body) { | ||
if (error) return done(error); | ||
|
||
expect(res.statusCode).to.equal(400); | ||
|
||
expect(body).to.equal(null); // non-json response or no schema | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should respond with 500 SERVER ERROR', function(done) { | ||
request({ | ||
url: 'https://api.uber.com/user', | ||
json: true, | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
} | ||
}, | ||
function(error, res, body) { | ||
if (error) return done(error); | ||
|
||
expect(res.statusCode).to.equal(500); | ||
|
||
expect(body).to.equal(null); // non-json response or no schema | ||
done(); | ||
}); | ||
}); | ||
|
||
}); | ||
|
||
}); |
67 changes: 67 additions & 0 deletions
67
test/jsonProperty/compare/request/expect/non-json-user-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
'use strict'; | ||
var chai = require('chai'); | ||
var request = require('request'); | ||
var expect = chai.expect; | ||
|
||
describe('/user', function() { | ||
describe('post', function() { | ||
it('should respond with 200 OK', function(done) { | ||
request({ | ||
url: 'https://api.uber.com/user', | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/xml' | ||
}, | ||
body: 'XML STRING GOES HERE' | ||
}, | ||
function(error, res, body) { | ||
if (error) return done(error); | ||
|
||
expect(res.statusCode).to.equal(200); | ||
|
||
expect(body).to.equal(null); // non-json response or no schema | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should respond with 400 NOT OK', function(done) { | ||
request({ | ||
url: 'https://api.uber.com/user', | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/xml' | ||
}, | ||
body: 'XML STRING GOES HERE' | ||
}, | ||
function(error, res, body) { | ||
if (error) return done(error); | ||
|
||
expect(res.statusCode).to.equal(400); | ||
|
||
expect(body).to.equal(null); // non-json response or no schema | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should respond with 500 SERVER ERROR', function(done) { | ||
request({ | ||
url: 'https://api.uber.com/user', | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/xml' | ||
}, | ||
body: 'XML STRING GOES HERE' | ||
}, | ||
function(error, res, body) { | ||
if (error) return done(error); | ||
|
||
expect(res.statusCode).to.equal(500); | ||
|
||
expect(body).to.equal(null); // non-json response or no schema | ||
done(); | ||
}); | ||
}); | ||
|
||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"swagger": "2.0", | ||
"info": { | ||
"version": "0.0.0", | ||
"title": "Simple API" | ||
}, | ||
"host": "api.uber.com", | ||
"schemes": [ | ||
"https" | ||
], | ||
"paths": { | ||
"/user": { | ||
"get": { | ||
"responses": { | ||
"200": { | ||
"description": "OK" | ||
}, | ||
"400": { | ||
"description": "NOT OK" | ||
}, | ||
"500": { | ||
"description": "SERVER ERROR" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"swagger": "2.0", | ||
"info": { | ||
"version": "0.0.0", | ||
"title": "Simple API" | ||
}, | ||
"host": "api.uber.com", | ||
"schemes": [ | ||
"https" | ||
], | ||
"paths": { | ||
"/user": { | ||
"post": { | ||
"consumes": [ | ||
"application/xml" | ||
], | ||
"produces": [ | ||
"application/xml" | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "OK" | ||
}, | ||
"400": { | ||
"description": "NOT OK" | ||
}, | ||
"500": { | ||
"description": "SERVER ERROR" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.