Created
April 30, 2016 16:05
-
-
Save tobythetester/8ae3263b8b018a577f22e34988454e9e to your computer and use it in GitHub Desktop.
Get List of Post Codes
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
var request = require('supertest')("http://api.postcodes.io"); | |
var expect = require('chai').expect; | |
describe("Look up a specific post code", function () { | |
it("locates correct post code when given valid post code", function (done) { | |
request | |
.get('/postcodes/' + "SW1A 1AA") | |
.expect(200) | |
.end(function (err, res) { | |
expect(res.body.result.postcode).to.equal("SW1A 1AA"); | |
done(); | |
}); | |
}) | |
it("returns 400 when no post code is provided", function (done) { | |
request | |
.get('/postcodes/') | |
.expect(200) | |
.end(function (err, res) { | |
expect(res.body.status).to.equal(400); | |
done(); | |
}); | |
}) | |
it("returns 404 when no post code is provided", function (done) { | |
request | |
.get('/postcodes/' + 'AB123') | |
.expect(200) | |
.end(function (err, res) { | |
expect(res.body.status).to.equal(404); | |
expect(res.body.error).to.equal("Postcode not found") | |
done(); | |
}); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment