1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle
.MonoRail
.Views
.Brail
.Tests
17 using Castle
.MonoRail
.Framework
.Tests
;
18 using NUnit
.Framework
;
21 public class JSGenerationTestCase
: AbstractTestCase
24 public void AccessingElementAttribute()
26 DoGet("jsgeneration/elementattribute.rails");
28 AssertReplyContains("$('aa').className = \"newclass\";");
32 public void AccessingElementAttributeDepth()
34 DoGet("jsgeneration/elementattributedepth.rails");
36 AssertReplyContains("$('aa').style.display = \"none\";");
40 public void AccessingElementMethod()
42 DoGet("jsgeneration/elementmethod.rails");
44 AssertReplyContains("$('aa').hide();");
48 public void AccessingElementMethodDepth()
50 DoGet("jsgeneration/elementmethoddepth.rails");
52 AssertReplyContains("$('aa').read().test();");
56 public void AccessingElementStockOperationReplace()
58 DoGet("jsgeneration/elementreplace.rails");
60 AssertReplyContains("$('aa').replace(\"new content\")");
64 public void AccessingElementStockOperationReplaceHtml()
66 DoGet("jsgeneration/elementreplacehtml.rails");
68 AssertReplyContains("$('aa').update(\"new content\")");
72 public void CollectionFirstLast()
74 DoGet("jsgeneration/collectionfirstlast.rails");
76 AssertReplyContains("$$('p.welcome b').first().hide();");
77 AssertReplyContains("$$('p.welcome b').last().show();");
81 public void InsertHtml()
83 DoGet("jsgeneration/InsertHtml.rails");
85 AssertReplyContains("new Insertion.Top(\"aa\",\"new content\");");
86 AssertReplyContains("new Insertion.Bottom(\"aa\",\"new content\");");
87 AssertReplyContains("new Insertion.After(\"aa\",\"new content\");");
88 AssertReplyContains("new Insertion.Before(\"aa\",\"new content\");");
94 DoGet("jsgeneration/mr264.rails");
96 "Element.update(\"holder\",\"test\");\r\n" +
97 "new Effect.Highlight('holder', {});");
101 public void Replace()
103 DoGet("jsgeneration/replace.rails");
105 AssertReplyContains("Element.replace(\"aa\",\"new content\")");
109 public void ReplaceHtml()
111 DoGet("jsgeneration/replacehtml.rails");
113 AssertReplyContains("Element.update(\"aa\",\"new content\");");
117 public void ReplaceHtmlUsingPartial()
119 DoGet("jsgeneration/replacehtmlwithpartial.rails");
121 AssertReplyContains("Element.update(\"aa\",\"You\'re hammett <br> [ a ][ b ]\")");
125 public void ShowHideToggleRemove()
127 DoGet("jsgeneration/multipleactions.rails");
129 AssertReplyContains("Element.show(\"a\");");
130 AssertReplyContains("Element.show(\"a\",\"b\",\"c\");");
131 AssertReplyContains("Element.hide(\"a\");");
132 AssertReplyContains("Element.hide(\"a\",\"b\",\"c\");");
133 AssertReplyContains("Element.toggle(\"a\");");
134 AssertReplyContains("Element.toggle(\"a\",\"b\",\"c\");");
135 AssertReplyContains("[\"a\",\"b\",\"c\"].each(Element.remove);");
139 public void SimpleCollectionAccess()
141 DoGet("jsgeneration/collectionaccess.rails");
143 AssertReplyContains("$$('aa');");
147 public void SimpleElementAccess()
149 DoGet("jsgeneration/elementaccess.rails");
151 AssertReplyContains("$('aa');");
155 public void VisualEffect()
157 DoGet("jsgeneration/visualeffect.rails");
159 AssertReplyContains("Effect.Highlight('element1', {});");
160 AssertReplyContains("Effect.Highlight('element1', {duration:4});");