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 ProcessViewJS("jsgeneration/elementattribute");
27 AssertReplyContains("$('aa').className = \"newclass\";");
31 public void AccessingElementAttributeDepth()
33 ProcessViewJS("jsgeneration/elementattributedepth");
34 AssertReplyContains("$('aa').style.display = \"none\";");
38 public void AccessingElementMethod()
40 ProcessViewJS("jsgeneration/elementmethod");
41 AssertReplyContains("$('aa').hide();");
45 public void AccessingElementMethodDepth()
47 ProcessViewJS("jsgeneration/elementmethoddepth");
48 AssertReplyContains("$('aa').read().test();");
52 public void AccessingElementStockOperationReplace()
54 ProcessViewJS("jsgeneration/elementreplace");
55 AssertReplyContains("$('aa').replace(\"new content\")");
59 public void AccessingElementStockOperationReplaceHtml()
61 ProcessViewJS("jsgeneration/elementreplacehtml");
62 AssertReplyContains("$('aa').replacehtml(\"new content\")");
66 public void CollectionFirstLast()
68 ProcessViewJS("jsgeneration/collectionfirstlast");
69 AssertReplyContains("$('p.welcome b').first().hide();");
70 AssertReplyContains("$('p.welcome b').last().show();");
74 public void InsertHtml()
76 ProcessViewJS("jsgeneration/InsertHtml");
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 ProcessViewJS("jsgeneration/mr264");
88 "Element.update(\"holder\",\"test\");\r\n" +
89 "new Effect.Highlight('holder', {});");
95 ProcessViewJS("jsgeneration/replace");
96 AssertReplyContains("Element.replace(\"aa\",\"new content\")");
100 public void ReplaceHtml()
102 ProcessViewJS("jsgeneration/replacehtml");
103 AssertReplyContains("Element.update(\"aa\",\"new content\");");
107 public void ReplaceHtmlUsingPartial()
109 PropertyBag
["Name"] = "hammett";
110 PropertyBag
["list"] = new string[] {"a", "b"}
;
112 ProcessViewJS("jsgeneration/replacehtmlwithpartial");
113 AssertReplyContains("Element.update(\"aa\",\"You\'re hammett <br> [ a ][ b ]\")");
117 public void ShowHideToggleRemove()
119 ProcessViewJS("jsgeneration/multipleactions");
120 AssertReplyContains("Element.show(\"a\");");
121 AssertReplyContains("Element.show(\"a\",\"b\",\"c\");");
122 AssertReplyContains("Element.hide(\"a\");");
123 AssertReplyContains("Element.hide(\"a\",\"b\",\"c\");");
124 AssertReplyContains("Element.toggle(\"a\");");
125 AssertReplyContains("Element.toggle(\"a\",\"b\",\"c\");");
126 AssertReplyContains("[\"a\",\"b\",\"c\"].each(Element.remove);");
130 public void SimpleElementAccess()
132 ProcessViewJS("jsgeneration/elementaccess");
133 AssertReplyContains("$('aa');");
137 public void VisualEffect()
139 ProcessViewJS("jsgeneration/visualeffect");
140 AssertReplyContains("Effect.Highlight('element1', {});");
141 AssertReplyContains("Effect.Highlight('element1', {duration:4});");