forked from sintaxi/terraform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds tests for current.path and current.source
- Loading branch information
1 parent
aab820d
commit 2826c38
Showing
7 changed files
with
141 additions
and
3 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,97 @@ | ||
var should = require('should') | ||
var polymer = require('../') | ||
|
||
describe("current", function(){ | ||
|
||
describe("base", function(){ | ||
var root = __dirname + "/fixtures/current/base" | ||
var poly = polymer.root(root) | ||
|
||
it("should use a relative path in the root", function(done){ | ||
poly.render("index.jade", function(error, body){ | ||
should.not.exist(error) | ||
should.exist(body) | ||
body.should.include("<h1>Matthew Carter</h1>") | ||
body.should.include("<link href=\"main.css\" rel=\"stylesheet\" type=\"text/css\">") | ||
done() | ||
}) | ||
}) | ||
|
||
it("should use a relative path when nested", function(done){ | ||
poly.render("georgia/verdana/helvetica/index.ejs", function(error, body){ | ||
should.not.exist(error) | ||
should.exist(body) | ||
body.should.include("<h1>Matthew Carter</h1>") | ||
body.should.include("<link href=\"../../../main.css\" rel=\"stylesheet\" type=\"text/css\">") | ||
done() | ||
}) | ||
}) | ||
|
||
}) | ||
|
||
describe("path", function(){ | ||
var root = __dirname + "/fixtures/current/path" | ||
var poly = polymer.root(root) | ||
|
||
it("should provide current path", function(done){ | ||
poly.render("index.jade", function(error, body){ | ||
should.not.exist(error) | ||
should.exist(body) | ||
body.should.include("<h1>index</h1>") | ||
done() | ||
}) | ||
}) | ||
|
||
it("should provide current path in to an index page in a subdirectory", function(done){ | ||
poly.render("one/two/index.jade", function(error, body){ | ||
should.not.exist(error) | ||
should.exist(body) | ||
body.should.include("<li><a href=\"#\">one</a>") | ||
body.should.include("<li><a href=\"#\">two</a>") | ||
body.should.include("<li><a href=\"#\">index</a>") | ||
done() | ||
}) | ||
}) | ||
|
||
|
||
it("should provide current path to a non-index page in a subdirectory", function(done){ | ||
poly.render("one/two/three/about.jade", function(error, body){ | ||
should.not.exist(error) | ||
should.exist(body) | ||
body.should.include("<li><a href=\"#\">one</a>") | ||
body.should.include("<li><a href=\"#\">two</a>") | ||
body.should.include("<li><a href=\"#\">three</a>") | ||
body.should.include("<li><a href=\"#\">about</a>") | ||
body.should.not.include("index") | ||
done() | ||
}) | ||
}) | ||
|
||
it("should provide a portion of the current path", function(done){ | ||
poly.render("contact/index.ejs", function(error, body){ | ||
should.not.exist(error) | ||
should.exist(body) | ||
body.should.include("<title>contact</title>") | ||
done() | ||
}) | ||
}) | ||
|
||
|
||
}) | ||
|
||
describe("source", function(){ | ||
var root = __dirname + "/fixtures/current/source" | ||
var poly = polymer.root(root) | ||
|
||
it("should provide the current source", function(done){ | ||
poly.render("about.jade", function(error, body){ | ||
should.not.exist(error) | ||
should.exist(body) | ||
body.should.include("<a href=\"about\" class=\"active\">About</a>") | ||
done() | ||
}) | ||
}) | ||
|
||
}) | ||
|
||
}) |
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,8 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title><%= current.path[0] %></title> | ||
</head> | ||
<body> | ||
</body> | ||
</html> |
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,6 @@ | ||
doctype | ||
html | ||
head | ||
title Home | ||
body | ||
h1= current.path |
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,9 @@ | ||
doctype | ||
html | ||
head | ||
title Two | ||
body | ||
h1 Where am I? | ||
ul | ||
each item in current.path | ||
li: a(href="#")= item |
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,9 @@ | ||
doctype | ||
html | ||
head | ||
title About | ||
body | ||
h1 Where am I? | ||
ul | ||
each item in current.path | ||
li: a(href="#")= item |
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,8 @@ | ||
doctype | ||
html | ||
head | ||
title About | ||
body | ||
nav | ||
a(href="/") Home | ||
a(href="about" class="#{ current.source == 'about' ? 'active' : 'inactive' }") About |