Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

made the test pass #30

Merged
merged 1 commit into from

2 participants

@mschuster

No description provided.

Michelle Schuster made the test pass 0be2c4d
@ekryski ekryski merged commit 118451e into yycjs:dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 24, 2012
  1. made the test pass

    Michelle Schuster authored
This page is out of date. Refresh to see the latest.
View
2  app.js
@@ -37,7 +37,7 @@ Vibe = mongoose.model('Vibe');
Amenity = mongoose.model('Amenity');
Tag = mongoose.model( 'Tag' );
-app.models. = require( './models' );
+app.models = require( './models' );
app.models.initialize( { app: app } );
app.controllers = require( './controllers' );
View
3  controllers/home.js
@@ -1,8 +1,9 @@
module.exports = ( function () {
+ var app
var Listing;
function initialize ( options ){
- var app = options.app;
+ app = options.app;
Listing = app.models.listing.getModel();
}
View
1  models/index.js
@@ -1,4 +1,5 @@
module.exports = (function () {
+
var listing;
function initialize ( options ) {
View
50 test/unit/controllers/homeTest.js
@@ -7,13 +7,57 @@ describe( 'sharpodz.test.unit.controllers.home', function() {
var mockRequest = {};
var mockResponse = { render: stub.sync() };
- var mockApp = { };
+ var listings = [{
+ images: ['one','two']
+ },{
+ images: ['three','four']
+ }
+ ];
+ var expectedListing = [{
+ images: ['one','two'],
+ mainImage: 'one'
+ }
+ ];
+ var expectedLatest = {
+ images: ['three','four'],
+ mainImage: 'three'
+ }
+
+ var mockListing = {
+ find: stub.sync(null, {
+ limit : stub.sync(null, {
+ sort: stub.sync(null, {
+ exec: stub.async(null, listings)
+ })
+ })
+ })
+ };
+
+ var mockApp = {
+ models: {
+ listing: {
+ getModel: function() {
+ return mockListing;
+ }
+ }
+ }
+ };
describe( 'index', function() {
it( 'should call the database and grab the first 7 listings', function( done ) {
- homeController.initialize( mockApp );
-
+ homeController.initialize( { app: mockApp } );
+ homeController.index(mockRequest, mockResponse);
+ mockListing.find.called.withAnyArguments();
+ listings[0].mainImage.should.equal(expectedListing[0].mainImage);
+ mockResponse.render.called.withArguments('index', {
+ locals: {
+ title: "Test",
+ is_home: true,
+ results: expectedListing,
+ latest: expectedLatest
+ }
+ });
done();
} );
Something went wrong with that request. Please try again.