Removed untyped contructor from ComponentRegistration and add a protected setter.
[castle.git] / MonoRail / Castle.MonoRail.Views.Brail.Tests / JSGenerationTestCase.cs
blobabc5b086dbd2ac1a90191962bdb3f989fd2d61b2
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 ProcessViewJS("jsgeneration/elementattribute");
27 AssertReplyContains("$('aa').className = \"newclass\";");
30 [Test]
31 public void AccessingElementAttributeDepth()
33 ProcessViewJS("jsgeneration/elementattributedepth");
34 AssertReplyContains("$('aa').style.display = \"none\";");
37 [Test]
38 public void AccessingElementMethod()
40 ProcessViewJS("jsgeneration/elementmethod");
41 AssertReplyContains("$('aa').hide();");
44 [Test]
45 public void AccessingElementMethodDepth()
47 ProcessViewJS("jsgeneration/elementmethoddepth");
48 AssertReplyContains("$('aa').read().test();");
51 [Test]
52 public void AccessingElementStockOperationReplace()
54 ProcessViewJS("jsgeneration/elementreplace");
55 AssertReplyContains("$('aa').replace(\"new content\")");
58 [Test]
59 public void AccessingElementStockOperationReplaceHtml()
61 ProcessViewJS("jsgeneration/elementreplacehtml");
62 AssertReplyContains("$('aa').update(\"new content\")");
65 [Test]
66 public void CollectionFirstLast()
68 ProcessViewJS("jsgeneration/collectionfirstlast");
69 AssertReplyContains("$$('p.welcome b').first().hide();");
70 AssertReplyContains("$$('p.welcome b').last().show();");
73 [Test]
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\");");
83 [Test]
84 public void MR_264()
86 ProcessViewJS("jsgeneration/mr264");
87 AssertReplyContains(
88 "Element.update(\"holder\",\"test\");\r\n" +
89 "new Effect.Highlight('holder', {});");
92 [Test]
93 public void Replace()
95 ProcessViewJS("jsgeneration/replace");
96 AssertReplyContains("Element.replace(\"aa\",\"new content\")");
99 [Test]
100 public void ReplaceHtml()
102 ProcessViewJS("jsgeneration/replacehtml");
103 AssertReplyContains("Element.update(\"aa\",\"new content\");");
106 [Test]
107 public void ReplaceHtmlUsingPartial()
109 ProcessViewJS("jsgeneration/replacehtmlwithpartial");
110 AssertReplyContains("Element.update(\"aa\",\"You\'re hammett <br> [ a ][ b ]\")");
113 [Test]
114 public void ShowHideToggleRemove()
116 ProcessViewJS("jsgeneration/multipleactions");
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 ProcessViewJS("jsgeneration/collectionaccess");
130 AssertReplyContains("$$('aa');");
133 [Test]
134 public void SimpleElementAccess()
136 ProcessViewJS("jsgeneration/elementaccess");
137 AssertReplyContains("$('aa');");
140 [Test]
141 public void VisualEffect()
143 ProcessViewJS("jsgeneration/visualeffect");
144 AssertReplyContains("Effect.Highlight('element1', {});");
145 AssertReplyContains("Effect.Highlight('element1', {duration:4});");