mirror of
https://github.com/azures04/crafatar.git
synced 2026-05-06 19:10:38 +02:00
Separate some test loops
This commit is contained in:
28
test/test.js
28
test/test.js
@@ -236,19 +236,31 @@ describe("Server", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// testing all paths for valid inputs
|
||||||
|
var locations = ["avatars", "skins", "renders/head"]
|
||||||
|
for (var l in locations) {
|
||||||
|
var location = locations[l];
|
||||||
|
(function(location) {
|
||||||
|
it("should return a 200 (valid input " + location + ")", function(done) {
|
||||||
|
request.get("http://localhost:3000/" + location + "/Jake0oo0", function(error, res, body) {
|
||||||
|
assert.equal(200, res.statusCode);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
it("should return a 422 (invalid id " + location + ")", function(done) {
|
||||||
|
request.get("http://localhost:3000/" + location + "/thisisaninvaliduuid", function(error, res, body) {
|
||||||
|
assert.equal(422, res.statusCode);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})(location);
|
||||||
|
}
|
||||||
|
|
||||||
// testing all paths for invalid id formats
|
// testing all paths for invalid id formats
|
||||||
var locations = ["avatars", "capes", "skins", "renders/head"]
|
var locations = ["avatars", "capes", "skins", "renders/head"]
|
||||||
for (var l in locations) {
|
for (var l in locations) {
|
||||||
var location = locations[l];
|
var location = locations[l];
|
||||||
(function(location) {
|
(function(location) {
|
||||||
if (location !== "capes") {
|
|
||||||
it("should return a 200 (valid input " + location + ")", function(done) {
|
|
||||||
request.get("http://localhost:3000/" + location + "/Jake0oo0", function(error, res, body) {
|
|
||||||
assert.equal(200, res.statusCode);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
})
|
|
||||||
}
|
|
||||||
it("should return a 422 (invalid id " + location + ")", function(done) {
|
it("should return a 422 (invalid id " + location + ")", function(done) {
|
||||||
request.get("http://localhost:3000/" + location + "/thisisaninvaliduuid", function(error, res, body) {
|
request.get("http://localhost:3000/" + location + "/thisisaninvaliduuid", function(error, res, body) {
|
||||||
assert.equal(422, res.statusCode);
|
assert.equal(422, res.statusCode);
|
||||||
|
|||||||
Reference in New Issue
Block a user