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
.Framework
.Views
.NVelocity
.Tests
17 using Castle
.MonoRail
.Framework
.Tests
;
18 using NUnit
.Framework
;
21 public class JSGenerationTestCase
: AbstractTestCase
23 #region Stock operations
26 public void ReplaceHtml()
28 DoGet("jsgeneration/replacehtml.rails");
30 AssertReplyContains("Element.update(\"aa\",\"new content\");");
34 public void ReplaceHtmlUsingPartial()
36 DoGet("jsgeneration/replacehtmlwithpartial.rails");
38 AssertReplyContains("Element.update(\"aa\",\"You\'re hammett <br> [ a ][ b ]\")");
44 DoGet("jsgeneration/replace.rails");
46 AssertReplyContains("Element.replace(\"aa\",\"new content\")");
50 public void InsertHtml()
52 DoGet("jsgeneration/InsertHtml.rails");
54 AssertReplyContains("new Insertion.Top(\"aa\",\"new content\");");
55 AssertReplyContains("new Insertion.Bottom(\"aa\",\"new content\");");
56 AssertReplyContains("new Insertion.After(\"aa\",\"new content\");");
57 AssertReplyContains("new Insertion.Before(\"aa\",\"new content\");");
61 public void VisualEffect()
63 DoGet("jsgeneration/visualeffect.rails");
65 AssertReplyContains("Effect.Highlight('element1', {});");
66 AssertReplyContains("Effect.Highlight('element1', {duration:4});");
70 public void ShowHideToggleRemove()
72 DoGet("jsgeneration/multipleactions.rails");
74 AssertReplyContains("Element.show(\"a\");");
75 AssertReplyContains("Element.show(\"a\",\"b\",\"c\");");
76 AssertReplyContains("Element.hide(\"a\");");
77 AssertReplyContains("Element.hide(\"a\",\"b\",\"c\");");
78 AssertReplyContains("Element.toggle(\"a\");");
79 AssertReplyContains("Element.toggle(\"a\",\"b\",\"c\");");
80 AssertReplyContains("[\"a\",\"b\",\"c\"].each(Element.remove);");
85 #region Element related
88 public void SimpleElementAccess()
90 DoGet("jsgeneration/elementaccess.rails");
92 AssertReplyContains("$('aa');");
96 public void AccessingElementAttribute()
98 DoGet("jsgeneration/elementattribute.rails");
100 AssertReplyContains("$('aa').className = \"newclass\";");
104 public void AccessingElementAttributeDepth()
106 DoGet("jsgeneration/elementattributedepth.rails");
108 AssertReplyContains("$('aa').style.display = \"none\";");
112 public void AccessingElementMethod()
114 DoGet("jsgeneration/elementmethod.rails");
116 AssertReplyContains("$('aa').hide();");
120 public void AccessingElementMethodDepth()
122 DoGet("jsgeneration/elementmethoddepth.rails");
124 AssertReplyContains("$('aa').read().test();");
128 public void AccessingElementStockOperationReplaceHtml()
130 DoGet("jsgeneration/elementreplacehtml.rails");
132 AssertReplyContains("$('aa').update(\"new content\")");
136 public void AccessingElementStockOperationReplace()
138 DoGet("jsgeneration/elementreplace.rails");
140 AssertReplyContains("$('aa').replace(\"new content\")");
145 #region Select related
148 public void SimpleCollectionAccess()
150 DoGet("jsgeneration/collectionaccess.rails");
152 AssertReplyContains("$$('aa');");
156 public void CollectionFirstLast()
158 DoGet("jsgeneration/collectionfirstlast.rails");
160 AssertReplyContains("$$('p.welcome b').first().hide();");
161 AssertReplyContains("$$('p.welcome b').last().show();");