Added DictionaryAdapter.build.
[castle.git] / MonoRail / Castle.MonoRail.Views.Brail.Tests / JSGenerationTestCase.cs
blob4e19e34570aa625bffa6f6c30baeeca25201799e
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 #region Stock operations
25 [Test]
26 public void ReplaceHtml()
28 DoGet("jsgeneration/replacehtml.rails");
29 AssertSuccess();
30 AssertReplyContains("Element.update(\"aa\",\"new content\");");
33 [Test]
34 public void ReplaceHtmlUsingPartial()
36 DoGet("jsgeneration/replacehtmlwithpartial.rails");
37 AssertSuccess();
38 AssertReplyContains("Element.update(\"aa\",\"You\'re hammett <br> [ a ][ b ]\")");
41 [Test]
42 public void Replace()
44 DoGet("jsgeneration/replace.rails");
45 AssertSuccess();
46 AssertReplyContains("Element.replace(\"aa\",\"new content\")");
49 [Test]
50 public void InsertHtml()
52 DoGet("jsgeneration/InsertHtml.rails");
53 AssertSuccess();
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\");");
60 [Test]
61 public void VisualEffect()
63 DoGet("jsgeneration/visualeffect.rails");
64 AssertSuccess();
65 AssertReplyContains("Effect.Highlight('element1', {});");
66 AssertReplyContains("Effect.Highlight('element1', {duration:4});");
69 [Test]
70 public void ShowHideToggleRemove()
72 DoGet("jsgeneration/multipleactions.rails");
73 AssertSuccess();
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);");
83 [Test]
84 public void MR_264()
86 DoGet("jsgeneration/mr264.rails");
87 AssertReplyContains(
88 "Element.update(\"holder\",\"test\");\r\n"+
89 "new Effect.Highlight('holder', {});");
92 #endregion
94 #region Element related
96 [Test]
97 public void SimpleElementAccess()
99 DoGet("jsgeneration/elementaccess.rails");
100 AssertSuccess();
101 AssertReplyContains("$('aa');");
104 [Test]
105 public void AccessingElementAttribute()
107 DoGet("jsgeneration/elementattribute.rails");
108 AssertSuccess();
109 AssertReplyContains("$('aa').className = \"newclass\";");
112 [Test]
113 public void AccessingElementAttributeDepth()
115 DoGet("jsgeneration/elementattributedepth.rails");
116 AssertSuccess();
117 AssertReplyContains("$('aa').style.display = \"none\";");
120 [Test]
121 public void AccessingElementMethod()
123 DoGet("jsgeneration/elementmethod.rails");
124 AssertSuccess();
125 AssertReplyContains("$('aa').hide();");
128 [Test]
129 public void AccessingElementMethodDepth()
131 DoGet("jsgeneration/elementmethoddepth.rails");
132 AssertSuccess();
133 AssertReplyContains("$('aa').read().test();");
136 [Test]
137 public void AccessingElementStockOperationReplaceHtml()
139 DoGet("jsgeneration/elementreplacehtml.rails");
140 AssertSuccess();
141 AssertReplyContains("$('aa').update(\"new content\")");
144 [Test]
145 public void AccessingElementStockOperationReplace()
147 DoGet("jsgeneration/elementreplace.rails");
148 AssertSuccess();
149 AssertReplyContains("$('aa').replace(\"new content\")");
152 #endregion
154 #region Select related
156 [Test]
157 public void SimpleCollectionAccess()
159 DoGet("jsgeneration/collectionaccess.rails");
160 AssertSuccess();
161 AssertReplyContains("$$('aa');");
164 [Test]
165 public void CollectionFirstLast()
167 DoGet("jsgeneration/collectionfirstlast.rails");
168 AssertSuccess();
169 AssertReplyContains("$$('p.welcome b').first().hide();");
170 AssertReplyContains("$$('p.welcome b').last().show();");
173 #endregion