Skip to content

Commit

Permalink
More view tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricemach committed Aug 7, 2011
1 parent 492c321 commit 0bd340f
Show file tree
Hide file tree
Showing 6 changed files with 167 additions and 5 deletions.
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -13,7 +13,9 @@
"node-uuid": "1.2.0"
},
"devDependencies": {
"expresso": "0.8.1"
"expresso": "0.8.1",
"eco": "1.1.0-rc-1",
"jade": "0.13.0"
},
"keywords": ["framework", "websockets", "coffeescript", "express", "socket.io", "sammy", "sinatra"],
"main": "./lib/zappa",
Expand Down
157 changes: 155 additions & 2 deletions tests/views.coffee
Expand Up @@ -6,6 +6,7 @@ module.exports =
get '/': ->
@foo = 'bar'
render 'index', layout: no

view index: -> h2 "CoffeeKup inline template: #{@foo}"

t.get '/', '<h2>CoffeeKup inline template: bar</h2>'
Expand All @@ -15,7 +16,9 @@ module.exports =
get '/': ->
@foo = 'bar'
render 'index'

view index: -> h2 "CoffeeKup inline template: #{@foo}"

view layout: ->
doctype 5
html ->
Expand Down Expand Up @@ -43,12 +46,162 @@ module.exports =

'Views (response.render)': ->
t = zappa ->
get '/': -> response.render 'index', foo: 'bar', layout: no
get '/': ->
response.render 'index', foo: 'bar', layout: no

t.get '/', '<h2>CoffeeKup file template: bar</h2>'

'Views (response.render, layout)': ->
t = zappa ->
get '/': -> response.render 'index', foo: 'bar'
get '/': ->
response.render 'index', foo: 'bar'

t.get '/', '<!DOCTYPE html><html><head><title>CoffeeKup file layout</title></head><body><h2>CoffeeKup file template: bar</h2></body></html>'

'Views (eco, inline)': ->
t = zappa ->
set 'view engine': 'eco'

get '/': ->
@foo = 'bar'
render 'index', layout: no

view index: "<h2>Eco inline template: <%= @params.foo %></h2>"

t.get '/', '<h2>Eco inline template: bar</h2>'

'Views (eco, inline, inline layout)': ->
t = zappa ->
set 'view engine': 'eco'

get '/': ->
@foo = 'bar'
render 'index'

view index: "<h2>Eco inline template: <%= @params.foo %></h2>"

view layout: '''
<!DOCTYPE html>
<html>
<head>
<title>Eco inline layout</title>
</head>
<body><%- @body %></body>
</html>
'''

t.get '/', '<!DOCTYPE html>\n<html>\n <head>\n <title>Eco inline layout</title>\n </head>\n <body><h2>Eco inline template: bar</h2></body>\n</html>'


'Views (eco, file)': ->
t = zappa ->
set 'view engine': 'eco'

get '/': ->
@foo = 'bar'
render 'index', layout: no

t.get '/', '<h2>Eco file template: bar</h2>'

'Views (eco, file, file layout)': ->
t = zappa ->
set 'view engine': 'eco'

get '/': ->
@foo = 'bar'
render 'index'

t.get '/', '<!DOCTYPE html>\n<html>\n <head>\n <title>Eco file layout</title>\n </head>\n <body><h2>Eco file template: bar</h2></body>\n</html>'

'Views (eco, zappa adapter, inline, inline layout)': ->
t = zappa ->
set 'view engine': 'eco'
app.register '.eco', require('../src/zappa').adapter('eco')

get '/': ->
@foo = 'bar'
render 'index'

view index: "<h2>Eco inline template: <%= @foo %></h2>"

view layout: '''
<!DOCTYPE html>
<html>
<head>
<title>Eco inline layout</title>
</head>
<body><%- @body %></body>
</html>
'''

'Views (jade, inline)': ->
t = zappa ->
set 'view engine': 'jade'

get '/': ->
@foo = 'bar'
render 'index', layout: no

view index: "h2= 'Jade inline template: ' + params.foo"

t.get '/', '<h2>Jade inline template: bar</h2>'

'Views (jade, inline, inline layout)': ->
t = zappa ->
set 'view engine': 'jade'

get '/': ->
@foo = 'bar'
render 'index'

view index: "h2= 'Jade inline template: ' + params.foo"

view layout: '''
!!! 5
html
head
title Jade inline layout
body!= body
'''

t.get '/', '<!DOCTYPE html><html><head><title>Jade inline layout</title></head><body><h2>Jade inline template: bar</h2></body></html>'


'Views (jade, file)': ->
t = zappa ->
set 'view engine': 'jade'

get '/': ->
@foo = 'bar'
render 'index', layout: no

t.get '/', '<h2>Jade file template: bar</h2>'

'Views (jade, file, file layout)': ->
t = zappa ->
set 'view engine': 'jade'

get '/': ->
@foo = 'bar'
render 'index'

t.get '/', '<!DOCTYPE html><html><head><title>Jade file layout</title></head><body><h2>Jade file template: bar</h2></body></html>'

'Views (jade, zappa adapter, inline, inline layout)': ->
t = zappa ->
set 'view engine': 'jade'
app.register '.jade', require('../src/zappa').adapter('jade')

get '/': ->
@foo = 'bar'
render 'index'

view index: "h2= 'Jade inline template: ' + foo"

view layout: '''
!!! 5
html
head
title Jade inline layout
body!= body
'''
1 change: 1 addition & 0 deletions tests/views/index.eco
@@ -0,0 +1 @@
<h2>Eco file template: <%= @params.foo %></h2>
2 changes: 1 addition & 1 deletion tests/views/index.jade
@@ -1 +1 @@
h2 Jade file template
h2= 'Jade file template: ' + params.foo
7 changes: 7 additions & 0 deletions tests/views/layout.eco
@@ -0,0 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Eco file layout</title>
</head>
<body><%- @body %></body>
</html>
1 change: 0 additions & 1 deletion tests/views/layout.jade
Expand Up @@ -3,5 +3,4 @@ html
head
title Jade file layout
body
h1 Jade file layout
!= body

0 comments on commit 0bd340f

Please sign in to comment.