Skip to content

Commit

Permalink
Adding a test for sorting Objects
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed May 14, 2017
1 parent 9ab83a1 commit 28cafe2
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/behavior_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,28 @@ describe("CORS", function () {
.end();
});
});

describe("Sorting", function () {
const port = 8014;

this.timeout(timeout);
tenso({port: port, routes: routes, logging: {level: "error"}, security: {csrf: false}});

it("GET /things?order_by=user_id%20asc&order_by=name%20desc - returns a sorted array of objects", function () {
return tinyhttptest({url: "http://localhost:" + port + "/things?order_by=user_id%20asc&order_by=name%20desc"})
.expectStatus(200)
.expectValue("data", [{"id": 2, "name": "thing 2", "user_id": 1}, {"id": 1, "name": "thing 1", "user_id": 1}, {"id": 3, "name": "thing 3", "user_id": 2}])
.expectValue("error", null)
.expectValue("status", 200)
.end();
});

/*it("GET /items?order_by=desc - returns a sorted array of primitives", function () {
return tinyhttptest({url: "http://localhost:" + port + "/items?order_by=desc"})
.expectStatus(200)
.expectValue("data", [{"id":2,"name":"thing 2","user_id":1},{"id":1,"name":"thing 1","user_id":1},{"id":3,"name":"thing 3","user_id":2}])
.expectValue("error", null)
.expectValue("status", 200)
.end();
});*/
});

0 comments on commit 28cafe2

Please sign in to comment.