Skip to content

Instantly share code, notes, and snippets.

@hellobrian
Created March 21, 2015 01:19
Show Gist options
  • Select an option

  • Save hellobrian/2eee445916c132415308 to your computer and use it in GitHub Desktop.

Select an option

Save hellobrian/2eee445916c132415308 to your computer and use it in GitHub Desktop.
test suite mocha supertest
var request = require('supertest');
var app = require('./app');
function makeGetRequest(urlPath) {
return request(app).get(urlPath);
}
//--------------- HOME PAGE ---------------//
describe('Requests for Home page (index)', function() {
it('Returns a 200 status code', function(done) {
makeGetRequest('/').expect(200, done);
});
it('Returns HTML format', function(done) {
makeGetRequest('/').expect('Content-Type', /html/, done);
});
it('Returns an h1 with Bluemix Design Guide', function(done) {
makeGetRequest('/').expect(/<h1>Bluemix Design Guide<\/h1>/, done);
});
});
//--------------- BRANDING PAGES ---------------//
describe('Requests for Branding pages', function() {
describe('/branding', function() {
it('Returns a 200 status code for /branding', function(done) {
makeGetRequest('/branding').expect(200, done);
});
it('Returns HTML format for /branding', function(done) {
makeGetRequest('/branding').expect('Content-Type', /html/, done);
});
it('Returns an h1 with Branding', function(done) {
makeGetRequest('/branding').expect(/<h1>Branding<\/h1>/, done);
});
});
describe('/branding/who-we-are', function() {
it('Returns a 200 status code for /branding/who-we-are', function(done) {
makeGetRequest('/branding/who-we-are')
.expect(200, done);
});
it('Returns HTML format for /branding/who-we-are', function(done) {
makeGetRequest('/branding/who-we-are')
.expect('Content-Type', /html/, done);
});
it('Returns an h1 with Who we are', function(done) {
makeGetRequest('/branding/who-we-are')
.expect(/<h1>Who We Are<\/h1>/i, done);
});
});
describe('/branding/main-characteristics', function() {
it('Returns a 200 status code for /branding/main-characteristics', function(done) {
makeGetRequest('/branding/main-characteristics')
.expect(200, done);
});
it('Returns HTML format for /branding/main-characteristics', function(done) {
makeGetRequest('/branding/main-characteristics')
.expect('Content-Type', /html/, done);
});
it('Returns an h1 with Main Characteristics', function(done) {
makeGetRequest('/branding/main-characteristics')
.expect(/<h1>main characteristics<\/h1>/i, done);
});
});
});
//--------------- SCAFFOLDING PAGES ---------------//
describe('Requests for Scaffolding pages', function() {
describe('/scaffolding', function() {
it('Returns a 200 status code for /scaffolding', function(done) {
makeGetRequest('/scaffolding').expect(200, done);
});
it('Returns HTML format for /scaffolding', function(done) {
makeGetRequest('/scaffolding').expect('Content-Type', /html/, done);
});
it('Returns an h1 with Branding', function(done) {
makeGetRequest('/scaffolding').expect(/<h1>Scaffolding<\/h1>/i, done);
});
});
describe('/scaffolding/grid', function() {
it('Returns a 200 status code for /scaffolding/grid', function(done) {
makeGetRequest('/scaffolding/grid').expect(200, done);
});
it('Returns HTML format for /scaffolding/grid', function(done) {
makeGetRequest('/scaffolding/grid').expect('Content-Type', /html/, done);
});
it('Returns an h1 with Grid', function(done) {
makeGetRequest('/scaffolding/grid').expect(/<h1>Grid<\/h1>/i, done);
});
});
describe('/scaffolding/colors', function() {
it('Returns a 200 status code for /scaffolding/colors', function(done) {
makeGetRequest('/scaffolding/colors').expect(200, done);
});
it('Returns HTML format for /scaffolding/colors', function(done) {
makeGetRequest('/scaffolding/colors').expect('Content-Type', /html/, done);
});
it('Returns an h1 with Colors', function(done) {
makeGetRequest('/scaffolding/colors').expect(/<h1>Colors<\/h1>/i, done);
});
});
describe('/scaffolding/typography', function() {
it('Returns a 200 status code for /scaffolding/typography', function(done) {
makeGetRequest('/scaffolding/typography').expect(200, done);
});
it('Returns HTML format for /scaffolding/typography', function(done) {
makeGetRequest('/scaffolding/typography').expect('Content-Type', /html/, done);
});
it('Returns an h1 with Typography', function(done) {
makeGetRequest('/scaffolding/typography').expect(/<h1>Typography<\/h1>/i, done);
});
});
});
//--------------- ELEMENTS PAGES ---------------//
describe('Requests for Elements pages', function() {
describe('/elements', function() {
it('Returns a 200 status code for /elements', function(done) {
makeGetRequest('/elements').expect(200, done);
});
it('Returns HTML format for /elements', function(done) {
makeGetRequest('/elements').expect('Content-Type', /html/, done);
});
it('Returns an h1 with Branding', function(done) {
makeGetRequest('/elements').expect(/<h1>Elements<\/h1>/i, done);
});
});
describe('/elements/buttons', function() {
it('Returns a 200 status code for /elements/buttons', function(done) {
makeGetRequest('/elements/buttons').expect(200, done);
});
it('Returns HTML format for /elements/buttons', function(done) {
makeGetRequest('/elements/buttons').expect('Content-Type', /html/, done);
});
it('Returns an h1 with Buttons', function(done) {
makeGetRequest('/elements/buttons').expect(/<h1>Buttons<\/h1>/i, done);
});
});
});
//--------------- INTERACTIONS PAGES ---------------//
describe('Requests for Interactions pages', function() {
describe('/interactions', function() {
it('Returns a 200 status code for /interactions', function(done) {
makeGetRequest('/interactions').expect(200, done);
});
it('Returns HTML format for /interactions', function(done) {
makeGetRequest('/interactions').expect('Content-Type', /html/, done);
});
it('Returns an h1 with Branding', function(done) {
makeGetRequest('/interactions').expect(/<h1>Interactions<\/h1>/i, done);
});
});
});
//--------------- CONTENT PAGES ---------------//
describe('Requests for Content pages', function() {
describe('/content', function() {
it('Returns a 200 status code for /content', function(done) {
makeGetRequest('/content').expect(200, done);
});
it('Returns HTML format for /content', function(done) {
makeGetRequest('/content').expect('Content-Type', /html/, done);
});
it('Returns an h1 with Branding', function(done) {
makeGetRequest('/content').expect(/<h1>Content<\/h1>/i, done);
});
});
});
//--------------- ALERT/ERRORS PAGES ---------------//
describe('Requests for Alert/Errors pages', function() {
describe('/alerts-errors', function() {
it('Returns a 200 status code for /alerts-errors', function(done) {
makeGetRequest('/alerts-errors').expect(200, done);
});
it('Returns HTML format for /alerts-errors', function(done) {
makeGetRequest('/alerts-errors').expect('Content-Type', /html/, done);
});
it('Returns an h1 with Branding', function(done) {
makeGetRequest('/alerts-errors').expect(/<h1>Alerts\/Errors<\/h1>/i, done);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment