Permalink
Browse files

Added View#name. Useful for app testing.

  • Loading branch information...
1 parent 5271b54 commit 24446c7abb25f1c5a17ae7880a11b8c9e0d2cf9c @raroni committed Apr 6, 2012
Showing with 14 additions and 0 deletions.
  1. +4 −0 lib/wingman/view.coffee
  2. +10 −0 test/cases/view_test.coffee
@@ -35,6 +35,10 @@ module.exports = class extends WingmanObject
@set children: []
@render() if options?.render
+ name: ->
+ withoutView = @constructor.name.replace ///View$///, ''
+ Fleck.camelize Fleck.underscore(withoutView)
+
render: ->
templateSource = @get 'templateSource'
if templateSource
@@ -177,6 +177,16 @@ module.exports = class ViewTest extends Janitor.TestCase
view = new MainView render: true
@assert callbackFired
+ 'test single word name': ->
+ class MainView extends ViewWithTemplateSource
+ view = new MainView
+ @assertEqual 'main', view.get('name')
+
+ 'test double word name': ->
+ class UserNameView extends ViewWithTemplateSource
+ view = new UserNameView
+ @assertEqual 'userName', view.get('name')
+
'test view with child view': ->
class MainView extends Wingman.View
templateSource: '{view user}'

0 comments on commit 24446c7

Please sign in to comment.