-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #367 from colinwren/master
Add tests for automatic view routing and rendering, and updated package.json
- Loading branch information
Showing
6 changed files
with
71 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
createView |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
indexView |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
var assert = require('assert'); | ||
var httpHelper = require('./helpers/httpHelper.js'); | ||
var appHelper = require('./helpers/appHelper'); | ||
|
||
describe('View routes', function() { | ||
var appName = 'testApp'; | ||
|
||
before(function(done) { | ||
appHelper.build(function(err) { | ||
if (err) return done(err); | ||
|
||
process.chdir(appName); | ||
done(); | ||
}); | ||
}); | ||
|
||
after(function() { | ||
process.chdir('../'); | ||
appHelper.teardown(); | ||
}); | ||
|
||
describe('with default routing', function() { | ||
|
||
it('should respond to a get request to localhost:1337 with welcome page', function(done) { | ||
|
||
httpHelper.testRoute('get', '', function(err, response) { | ||
if (err) done(new Error(err)); | ||
|
||
assert(response.body.indexOf('It works!') !== -1); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('with no specified routing', function() { | ||
|
||
it('should respond to get request to :controller with the template at views/:controller/index.ejs', function(done) { | ||
|
||
// Empty router file | ||
httpHelper.writeRoutes({}); | ||
|
||
httpHelper.testRoute('get', 'viewTest', function(err, response) { | ||
if (err) done(new Error(err)); | ||
|
||
assert(response.body.indexOf('indexView') !== -1); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should respond to get request to :controller/:action with the template at views/:controller/:action.ejs', function(done) { | ||
|
||
httpHelper.testRoute('get', 'viewTest/create', function(err, response) { | ||
if (err) done(new Error(err)); | ||
|
||
assert(response.body.indexOf('createView') !== -1); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |