Minor style changes
[castle.git] / MonoRail / Castle.MonoRail.Views.Brail.Tests / JSGenerationTestCase.cs
blob4a776caa297ab317ff806a0e1bc882f7fbedf903
1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
2 //
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
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
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;
20 [TestFixture]
21 public class JSGenerationTestCase : AbstractTestCase
23 [Test]
24 public void AccessingElementAttribute()
26 DoGet("jsgeneration/elementattribute.rails");
27 AssertSuccess();
28 AssertReplyContains("$('aa').className = \"newclass\";");
31 [Test]
32 public void AccessingElementAttributeDepth()
34 DoGet("jsgeneration/elementattributedepth.rails");
35 AssertSuccess();
36 AssertReplyContains("$('aa').style.display = \"none\";");
39 [Test]
40 public void AccessingElementMethod()
42 DoGet("jsgeneration/elementmethod.rails");
43 AssertSuccess();
44 AssertReplyContains("$('aa').hide();");
47 [Test]
48 public void AccessingElementMethodDepth()
50 DoGet("jsgeneration/elementmethoddepth.rails");
51 AssertSuccess();
52 AssertReplyContains("$('aa').read().test();");
55 [Test]
56 public void AccessingElementStockOperationReplace()
58 DoGet("jsgeneration/elementreplace.rails");
59 AssertSuccess();
60 AssertReplyContains("$('aa').replace(\"new content\")");
63 [Test]
64 public void AccessingElementStockOperationReplaceHtml()
66 DoGet("jsgeneration/elementreplacehtml.rails");
67 AssertSuccess();
68 AssertReplyContains("$('aa').update(\"new content\")");
71 [Test]
72 public void CollectionFirstLast()
74 DoGet("jsgeneration/collectionfirstlast.rails");
75 AssertSuccess();
76 AssertReplyContains("$$('p.welcome b').first().hide();");
77 AssertReplyContains("$$('p.welcome b').last().show();");
80 [Test]
81 public void InsertHtml()
83 DoGet("jsgeneration/InsertHtml.rails");
84 AssertSuccess();
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\");");
91 [Test]
92 public void MR_264()
94 DoGet("jsgeneration/mr264.rails");
95 AssertReplyContains(
96 "Element.update(\"holder\",\"test\");\r\n" +
97 "new Effect.Highlight('holder', {});");
100 [Test]
101 public void Replace()
103 DoGet("jsgeneration/replace.rails");
104 AssertSuccess();
105 AssertReplyContains("Element.replace(\"aa\",\"new content\")");
108 [Test]
109 public void ReplaceHtml()
111 DoGet("jsgeneration/replacehtml.rails");
112 AssertSuccess();
113 AssertReplyContains("Element.update(\"aa\",\"new content\");");
116 [Test]
117 public void ReplaceHtmlUsingPartial()
119 DoGet("jsgeneration/replacehtmlwithpartial.rails");
120 AssertSuccess();
121 AssertReplyContains("Element.update(\"aa\",\"You\'re hammett <br> [ a ][ b ]\")");
124 [Test]
125 public void ShowHideToggleRemove()
127 DoGet("jsgeneration/multipleactions.rails");
128 AssertSuccess();
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);");
138 [Test]
139 public void SimpleCollectionAccess()
141 DoGet("jsgeneration/collectionaccess.rails");
142 AssertSuccess();
143 AssertReplyContains("$$('aa');");
146 [Test]
147 public void SimpleElementAccess()
149 DoGet("jsgeneration/elementaccess.rails");
150 AssertSuccess();
151 AssertReplyContains("$('aa');");
154 [Test]
155 public void VisualEffect()
157 DoGet("jsgeneration/visualeffect.rails");
158 AssertSuccess();
159 AssertReplyContains("Effect.Highlight('element1', {});");
160 AssertReplyContains("Effect.Highlight('element1', {duration:4});");