Permalink
Browse files

added view integration tests, updated other tests

  • Loading branch information...
1 parent 2115138 commit 42dcca878a1151718663e9accb49730f09ee469f @hunterloftis committed Aug 9, 2012
View
@@ -1,11 +1,22 @@
+setup:
+ rm -rf node_modules
+ npm cache clean
+ npm install
+
+test:
+ npm install
+ scripts/test
+
+test-quick:
+ scripts/test
+
start:
npm start
open:
(sleep 2 && open http://localhost:3000) &
npm start
-test:
- scripts/test
-.PHONY: start open test
+
+.PHONY: setup test test-quick start open
@@ -1,5 +1,8 @@
extends ../shared/layout
+block title
+ | Dashboard - Components test
+
block content
.dash-header
.half-drop
View
@@ -4,7 +4,8 @@ include ../flash/messages
html
head
meta(charset="utf-8")
- title Components test
+ title: block title
+ | Components test
block styles
link(rel='stylesheet', type='text/css', href='/shared/global.css')
View
@@ -1,5 +1,8 @@
extends ../shared/layout
+block title
+ | Sign in - Components test
+
block content
form.form-gateway(action='/signin', method='post')
.title-bar
@@ -49,7 +49,7 @@ describe('User controller', function() {
});
});
});
- describe('/ landing page', function() {
+ describe('/', function() {
var agent = superagent.agent();
before(loginUser(agent));
@@ -3,7 +3,7 @@ var should = require('should');
var UserModel = require('../userModel');
describe('User model', function() {
- describe('authenticate', function() {
+ describe('authenticate()', function() {
it('should reject a request without an email', function(done) {
UserModel.authenticate({ password: 'bacon' }, onAuth);
function onAuth(err, user) {
View
@@ -1,5 +1,5 @@
#!/bin/bash
-TESTS=`find lib -name '*.test.js'`
+TESTS=`find lib -name '*.test.js' && find test -name '*.test.js'`
node_modules/.bin/mocha -R list $TESTS
View
@@ -0,0 +1,78 @@
+var should = require('should');
+var Zombie = require('zombie');
+var assert = require('assert');
+
+var utils = require('../lib/shared/test.utils');
+
+utils.startApp(3002);
+
+describe('Browser', function() {
+ describe('of an unregistered user', function() {
+ var browser = new Zombie();
+ it('should be able to view the landing page', function(done) {
+ browser.visit('http://localhost:3002', function() {
+ assert.ok(browser.success);
+ browser.text('title').should.include('Sign in');
+ return done();
+ });
+ });
+ it('should not be able to view the dashboard', function(done) {
+ browser.visit('http://localhost:3002/dashboard', function() {
+ assert.ok(browser.success);
+ browser.text('title').should.include('Sign in');
+ browser.text('.flash-messages').should.include('Please log in first');
+ return done();
+ });
+ });
+ });
+ describe('of a registered user', function() {
+ var browser = new Zombie();
+ it('should be able to view the landing page', function(done) {
+ browser.visit('http://localhost:3002', function() {
+ assert.ok(browser.success);
+ browser.text('title').should.include('Sign in');
+ return done();
+ });
+ });
+ it('should get an error with bad credentials', function(done) {
+ browser
+ .fill('email', 'test@dummy.com')
+ .fill('password', 'wrong')
+ .pressButton('Sign in')
+ .then(function() {
+ assert.ok(browser.success);
+ browser.text('title').should.include('Sign in');
+ browser.text('.flash-messages').should.include('Sorry, that username or password was not found');
+ return done();
+ })
+ .fail(done);
+ });
+ it('should be able to sign in with good credentials', function(done) {
+ browser
+ .fill('email', 'test@dummy.com')
+ .fill('password', 'bacon')
+ .pressButton('Sign in')
+ .then(function() {
+ assert.ok(browser.success);
+ browser.text('title').should.include('Dashboard');
+ return done();
+ })
+ .fail(done);
+ });
+ it('should be able to reload the dashboard', function(done) {
+ browser.visit('http://localhost:3002/dashboard', function() {
+ assert.ok(browser.success);
+ browser.text('title').should.include('Dashboard');
+ return done();
+ });
+ });
+ it('should be able to sign out', function(done) {
+ browser.clickLink('Sign out', function() {
+ assert.ok(browser.success);
+ browser.text('title').should.include('Sign in');
+ browser.text('.flash-messages').should.include('You have been signed out');
+ return done();
+ });
+ });
+ });
+});

0 comments on commit 42dcca8

Please sign in to comment.