1 // Copyright 2004-2008 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
18 using NUnit
.Framework
;
21 public class JSGenerationTestCase
: BaseViewOnlyTestFixture
24 public void AccessingElementAttribute()
26 ProcessView_StripRailsExtension("jsgeneration/elementattribute.rails");
27 AssertReplyContains("$('aa').className = \"newclass\";");
31 public void AccessingElementAttributeDepth()
33 ProcessView_StripRailsExtension("jsgeneration/elementattributedepth.rails");
34 AssertReplyContains("$('aa').style.display = \"none\";");
38 public void AccessingElementMethod()
40 ProcessView_StripRailsExtension("jsgeneration/elementmethod.rails");
41 AssertReplyContains("$('aa').hide();");
45 public void AccessingElementMethodDepth()
47 ProcessView_StripRailsExtension("jsgeneration/elementmethoddepth.rails");
48 AssertReplyContains("$('aa').read().test();");
52 public void AccessingElementStockOperationReplace()
54 ProcessView_StripRailsExtension("jsgeneration/elementreplace.rails");
55 AssertReplyContains("$('aa').replace(\"new content\")");
59 public void AccessingElementStockOperationReplaceHtml()
61 ProcessView_StripRailsExtension("jsgeneration/elementreplacehtml.rails");
62 AssertReplyContains("$('aa').update(\"new content\")");
66 public void CollectionFirstLast()
68 ProcessView_StripRailsExtension("jsgeneration/collectionfirstlast.rails");
69 AssertReplyContains("$$('p.welcome b').first().hide();");
70 AssertReplyContains("$$('p.welcome b').last().show();");
74 public void InsertHtml()
76 ProcessView_StripRailsExtension("jsgeneration/InsertHtml.rails");
77 AssertReplyContains("new Insertion.Top(\"aa\",\"new content\");");
78 AssertReplyContains("new Insertion.Bottom(\"aa\",\"new content\");");
79 AssertReplyContains("new Insertion.After(\"aa\",\"new content\");");
80 AssertReplyContains("new Insertion.Before(\"aa\",\"new content\");");
86 ProcessView_StripRailsExtension("jsgeneration/mr264.rails");
88 "Element.update(\"holder\",\"test\");\r\n" +
89 "new Effect.Highlight('holder', {});");
95 ProcessView_StripRailsExtension("jsgeneration/replace.rails");
96 AssertReplyContains("Element.replace(\"aa\",\"new content\")");
100 public void ReplaceHtml()
102 ProcessView_StripRailsExtension("jsgeneration/replacehtml.rails");
103 AssertReplyContains("Element.update(\"aa\",\"new content\");");
107 public void ReplaceHtmlUsingPartial()
109 ProcessView_StripRailsExtension("jsgeneration/replacehtmlwithpartial.rails");
110 AssertReplyContains("Element.update(\"aa\",\"You\'re hammett <br> [ a ][ b ]\")");
114 public void ShowHideToggleRemove()
116 ProcessView_StripRailsExtension("jsgeneration/multipleactions.rails");
117 AssertReplyContains("Element.show(\"a\");");
118 AssertReplyContains("Element.show(\"a\",\"b\",\"c\");");
119 AssertReplyContains("Element.hide(\"a\");");
120 AssertReplyContains("Element.hide(\"a\",\"b\",\"c\");");
121 AssertReplyContains("Element.toggle(\"a\");");
122 AssertReplyContains("Element.toggle(\"a\",\"b\",\"c\");");
123 AssertReplyContains("[\"a\",\"b\",\"c\"].each(Element.remove);");
127 public void SimpleCollectionAccess()
129 ProcessView_StripRailsExtension("jsgeneration/collectionaccess.rails");
130 AssertReplyContains("$$('aa');");
134 public void SimpleElementAccess()
136 ProcessView_StripRailsExtension("jsgeneration/elementaccess.rails");
137 AssertReplyContains("$('aa');");
141 public void VisualEffect()
143 ProcessView_StripRailsExtension("jsgeneration/visualeffect.rails");
144 AssertReplyContains("Effect.Highlight('element1', {});");
145 AssertReplyContains("Effect.Highlight('element1', {duration:4});");