From 67e24897d1898b1673742eccccf49b74462e74ce Mon Sep 17 00:00:00 2001 From: Chris Blanchard Date: Sun, 27 Dec 2015 19:42:32 +0000 Subject: [PATCH] Added browser skeleton --- config/routes.js | 9 ++++++++ spec/messages.integration.js | 40 ++++++++++++++++++++++++++++++++++++ views/messages.hbs | 15 ++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 spec/messages.integration.js create mode 100644 views/messages.hbs diff --git a/config/routes.js b/config/routes.js index 731fdc7..e599e03 100644 --- a/config/routes.js +++ b/config/routes.js @@ -28,6 +28,15 @@ module.exports = app => { response.status(200).json(gather.toJson()); }); + app.get("/messages", (request, response) => { + if (request.is("json")) { + // To Implement + response.end("") + } else { + response.render("messages.hbs"); + } + }); + app.get("*", (request, response) => { response.status(404).render("404.hbs"); }); diff --git a/spec/messages.integration.js b/spec/messages.integration.js new file mode 100644 index 0000000..c57ca01 --- /dev/null +++ b/spec/messages.integration.js @@ -0,0 +1,40 @@ +"use strict"; + +var helper = require("./helpers/index.js"); +var request = require("supertest"); +var assert = require("chai").assert; +var app = helper.app; + +describe("Messages", () => { + beforeEach(done => { + done(); + }); + + afterEach(done => { + done(); + }); + describe("#Index", () => { + describe("JSON Api", () => { + it ("returns most recent messages"); + it ("is sensitive to limit"); + it ("returns a maximum of last 250 messages"); + it ("is sensitive to pagination"); + it ("is sensitive to user"); + it ("is sensitive to search terms"); + }); + describe("HTML Browser", () => { + it ("renders message browser", done => { + request(app) + .get("/messages") + .set("Accept", "text/html; charset=utf-8") + .expect('Content-Type', /html/) + .expect(200) + .end((error, response) => { + if (error) return done(error); + assert.include(response.text, "Message Browser"); + done(); + }); + }) + }); + }); +}); diff --git a/views/messages.hbs b/views/messages.hbs new file mode 100644 index 0000000..bb47980 --- /dev/null +++ b/views/messages.hbs @@ -0,0 +1,15 @@ +
+ {{>menu}} +
+
+
+
+

Message Browser

+
+
+ +
+
+
+
+