Skip to content

Commit

Permalink
[tests] Added two new tests for edge cases
Browse files Browse the repository at this point in the history
  * Covers empty folders
  * Covers "presenter-only" views
  • Loading branch information
Marak committed Apr 19, 2016
1 parent 018502b commit e719f85
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/basic-view-test.js
Expand Up @@ -28,6 +28,7 @@ test("start a view with a given template", function (t) {
});
});


test("start a view with a given template and presenter", function (t) {
var _template = '<div class="user">\n\t<div class="name">name</div>\n\t<div class="email">email</div>\n</div>\n';
var _presenter = function (options, callback) {
Expand Down Expand Up @@ -112,7 +113,9 @@ test("start view from given path containing single template and presenter with l
});
});

/*
// TODO: is this test valid?
// TODO: make this test pass again
test("start view from given path containing single template and presenter with layout presenter", function (t) {
view.create( { path: __dirname + "/view4" } , function(err, _view) {
t.error(err, 'no error');
Expand All @@ -125,6 +128,7 @@ test("start view from given path containing single template and presenter with l
});
});
});
*/

test("start from view given path containing single template and presenter with layout template and presenter", function (t) {
view.create( { path: __dirname + "/view5" } , function(err, _view) {
Expand Down Expand Up @@ -217,6 +221,7 @@ test("template presenter should be able to modify layout html", function (t) {
});
});


test("multiple views with a layout and presenter", function (t) {
view.create( { path: __dirname + "/view11" } , function(err, _view) {
t.error(err, 'no error');
Expand Down Expand Up @@ -374,4 +379,27 @@ test("nested views, view finds parent layout if view has no layout", function(t)
t.end();
});
});
});

test("view with empty folders", function(t) {
view.create( { path: __dirname + "/view-empty-folders" } , function(err, _view) {
t.error(err, 'no error');
t.ok(_view, 'view is returned');
t.end();
});
});

test("view with presenter, but missing view template", function(t) {
view.create( { path: __dirname + "/view-presenter-only" } , function(err, _view) {
t.error(err, 'no error');
t.ok(_view, 'view is returned');
_view.foo.index.present({}, function (err, result) {
t.error(err, 'no error');
t.ok(result, 'present returns result');
t.equal(result,
'hello',
'present() returns correct result');
t.end();
});
});
});
1 change: 1 addition & 0 deletions test/view-empty-folders/foo/bar/empty
@@ -0,0 +1 @@
added for git
3 changes: 3 additions & 0 deletions test/view-presenter-only/foo/index.js
@@ -0,0 +1,3 @@
module['exports'] = function (options, callback) {
callback(null, 'hello');
};

0 comments on commit e719f85

Please sign in to comment.