|
| 1 | +'use strict'; |
| 2 | +var chai = require('chai'); |
| 3 | +var request = require('request'); |
| 4 | +var expect = chai.expect; |
| 5 | + |
| 6 | +describe('/user', function() { |
| 7 | + describe('post', function() { |
| 8 | + it('should respond with 200 OK', function(done) { |
| 9 | + request({ |
| 10 | + url: 'https://api.uber.com/user', |
| 11 | + method: 'POST', |
| 12 | + headers: { |
| 13 | + 'Content-Type': 'application/xml' |
| 14 | + }, |
| 15 | + body: 'XML STRING GOES HERE' |
| 16 | + }, |
| 17 | + function(error, res, body) { |
| 18 | + if (error) return done(error); |
| 19 | + |
| 20 | + expect(res.statusCode).to.equal(200); |
| 21 | + |
| 22 | + expect(body).to.equal(null); // non-json response or no schema |
| 23 | + done(); |
| 24 | + }); |
| 25 | + }); |
| 26 | + |
| 27 | + it('should respond with 400 NOT OK', function(done) { |
| 28 | + request({ |
| 29 | + url: 'https://api.uber.com/user', |
| 30 | + method: 'POST', |
| 31 | + headers: { |
| 32 | + 'Content-Type': 'application/xml' |
| 33 | + }, |
| 34 | + body: 'XML STRING GOES HERE' |
| 35 | + }, |
| 36 | + function(error, res, body) { |
| 37 | + if (error) return done(error); |
| 38 | + |
| 39 | + expect(res.statusCode).to.equal(400); |
| 40 | + |
| 41 | + expect(body).to.equal(null); // non-json response or no schema |
| 42 | + done(); |
| 43 | + }); |
| 44 | + }); |
| 45 | + |
| 46 | + it('should respond with 500 SERVER ERROR', function(done) { |
| 47 | + request({ |
| 48 | + url: 'https://api.uber.com/user', |
| 49 | + method: 'POST', |
| 50 | + headers: { |
| 51 | + 'Content-Type': 'application/xml' |
| 52 | + }, |
| 53 | + body: 'XML STRING GOES HERE' |
| 54 | + }, |
| 55 | + function(error, res, body) { |
| 56 | + if (error) return done(error); |
| 57 | + |
| 58 | + expect(res.statusCode).to.equal(500); |
| 59 | + |
| 60 | + expect(body).to.equal(null); // non-json response or no schema |
| 61 | + done(); |
| 62 | + }); |
| 63 | + }); |
| 64 | + |
| 65 | + }); |
| 66 | + |
| 67 | +}); |
0 commit comments