More working tests.
[castle.git] / MonoRail / Castle.MonoRail.Views.Brail.Tests / JSGenerationTestCase.cs
blob4406040f1d38bd3bc6930c16fe8c80723e0380bf
1 // Copyright 2004-2008 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
18 using NUnit.Framework;
20 [TestFixture]
21 public class JSGenerationTestCase : BaseViewOnlyTestFixture
23 [Test]
24 public void AccessingElementAttribute()
26 ProcessView_StripRailsExtension("jsgeneration/elementattribute.rails");
27 AssertReplyContains("$('aa').className = \"newclass\";");
30 [Test]
31 public void AccessingElementAttributeDepth()
33 ProcessView_StripRailsExtension("jsgeneration/elementattributedepth.rails");
34 AssertReplyContains("$('aa').style.display = \"none\";");
37 [Test]
38 public void AccessingElementMethod()
40 ProcessView_StripRailsExtension("jsgeneration/elementmethod.rails");
41 AssertReplyContains("$('aa').hide();");
44 [Test]
45 public void AccessingElementMethodDepth()
47 ProcessView_StripRailsExtension("jsgeneration/elementmethoddepth.rails");
48 AssertReplyContains("$('aa').read().test();");
51 [Test]
52 public void AccessingElementStockOperationReplace()
54 ProcessView_StripRailsExtension("jsgeneration/elementreplace.rails");
55 AssertReplyContains("$('aa').replace(\"new content\")");
58 [Test]
59 public void AccessingElementStockOperationReplaceHtml()
61 ProcessView_StripRailsExtension("jsgeneration/elementreplacehtml.rails");
62 AssertReplyContains("$('aa').update(\"new content\")");
65 [Test]
66 public void CollectionFirstLast()
68 ProcessView_StripRailsExtension("jsgeneration/collectionfirstlast.rails");
69 AssertReplyContains("$$('p.welcome b').first().hide();");
70 AssertReplyContains("$$('p.welcome b').last().show();");
73 [Test]
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\");");
83 [Test]
84 public void MR_264()
86 ProcessView_StripRailsExtension("jsgeneration/mr264.rails");
87 AssertReplyContains(
88 "Element.update(\"holder\",\"test\");\r\n" +
89 "new Effect.Highlight('holder', {});");
92 [Test]
93 public void Replace()
95 ProcessView_StripRailsExtension("jsgeneration/replace.rails");
96 AssertReplyContains("Element.replace(\"aa\",\"new content\")");
99 [Test]
100 public void ReplaceHtml()
102 ProcessView_StripRailsExtension("jsgeneration/replacehtml.rails");
103 AssertReplyContains("Element.update(\"aa\",\"new content\");");
106 [Test]
107 public void ReplaceHtmlUsingPartial()
109 ProcessView_StripRailsExtension("jsgeneration/replacehtmlwithpartial.rails");
110 AssertReplyContains("Element.update(\"aa\",\"You\'re hammett <br> [ a ][ b ]\")");
113 [Test]
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);");
126 [Test]
127 public void SimpleCollectionAccess()
129 ProcessView_StripRailsExtension("jsgeneration/collectionaccess.rails");
130 AssertReplyContains("$$('aa');");
133 [Test]
134 public void SimpleElementAccess()
136 ProcessView_StripRailsExtension("jsgeneration/elementaccess.rails");
137 AssertReplyContains("$('aa');");
140 [Test]
141 public void VisualEffect()
143 ProcessView_StripRailsExtension("jsgeneration/visualeffect.rails");
144 AssertReplyContains("Effect.Highlight('element1', {});");
145 AssertReplyContains("Effect.Highlight('element1', {duration:4});");