newjs 1.5.1 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. data/History.txt +11 -0
  2. data/Manifest.txt +162 -14
  3. data/{README.txt → README.rdoc} +1 -1
  4. data/Rakefile +25 -3
  5. data/app_generators/newjs_iphone/templates/Html/test/assets/jsunittest.js +41 -13
  6. data/app_generators/newjs_iphone/templates/Html/test/assets/unittest.css +4 -0
  7. data/features/development.feature +13 -0
  8. data/features/imported_files_for_generators.feature +19 -0
  9. data/features/steps/common.rb +205 -0
  10. data/features/steps/env.rb +6 -0
  11. data/javascript_test_generators/functional_test/functional_test_generator.rb +9 -1
  12. data/javascript_test_generators/functional_test/templates/test/assets/jshoulda.js +186 -0
  13. data/javascript_test_generators/functional_test/templates/test/test.html.erb +15 -1
  14. data/javascript_test_generators/unit_test/templates/test/assets/jshoulda.js +186 -0
  15. data/javascript_test_generators/unit_test/templates/test/test.html.erb +18 -20
  16. data/javascript_test_generators/unit_test/templates/test/test_jshoulda.html.erb +45 -0
  17. data/javascript_test_generators/unit_test/unit_test_generator.rb +11 -3
  18. data/lib/newjs.rb +3 -2
  19. data/newjs_iphone_generators/page/USAGE +5 -0
  20. data/newjs_iphone_generators/page/page_generator.rb +36 -0
  21. data/newjs_iphone_generators/page/templates/src/name.css.erb +0 -0
  22. data/newjs_iphone_generators/page/templates/src/name.html.erb +13 -0
  23. data/newjs_iphone_generators/page/templates/src/name.js.erb +4 -0
  24. data/newjs_iphone_generators/page/templates/test/fixtures/name.js.erb +5 -0
  25. data/newjs_iphone_generators/page/templates/test/unit/name_test.html.erb +61 -0
  26. data/rack_generators/javascript_test/USAGE +5 -0
  27. data/rack_generators/javascript_test/javascript_test_generator.rb +88 -0
  28. data/rack_generators/javascript_test/templates/assets/jshoulda.js +186 -0
  29. data/rack_generators/javascript_test/templates/assets/jsunittest.js +1004 -0
  30. data/rack_generators/javascript_test/templates/assets/unittest.css +54 -0
  31. data/rack_generators/javascript_test/templates/ext/jquery.js +3408 -0
  32. data/{app_generators/newjs_iphone/templates/Html/test/assets → rack_generators/javascript_test/templates/ext}/prototype.js +56 -122
  33. data/rack_generators/javascript_test/templates/library.js.erb +3 -0
  34. data/rack_generators/javascript_test/templates/test.html.erb +59 -0
  35. data/rack_generators/javascript_test/templates/test_jshoulda.html.erb +48 -0
  36. data/rails_generators/javascript_test/javascript_test_generator.rb +15 -3
  37. data/rails_generators/javascript_test/templates/assets/jshoulda.js +186 -0
  38. data/rails_generators/javascript_test/templates/test_jshoulda.html.erb +48 -0
  39. data/script/console +10 -0
  40. data/script/destroy +1 -1
  41. data/tasks/vendor/update/jshoulda.rake +18 -0
  42. data/tasks/vendor/update/jsunittest.rake +18 -0
  43. data/test/test_functional_test_generator.rb +13 -0
  44. data/test/test_generator_helper.rb +10 -1
  45. data/test/test_page_generator.rb +50 -0
  46. data/test/test_rack_javascript_test.rb +166 -0
  47. data/test/{test_javascript_test_generator.rb → test_rails_javascript_test_generator.rb} +15 -1
  48. data/test/test_unit_test_generator.rb +13 -0
  49. data/vendor/jshoulda/History.txt +108 -0
  50. data/vendor/jshoulda/License.txt +20 -0
  51. data/vendor/jshoulda/README.mdown +34 -0
  52. data/vendor/jshoulda/Rakefile +120 -0
  53. data/vendor/jshoulda/config/javascript_test_autotest.yml.sample +15 -0
  54. data/vendor/jshoulda/dist/jshoulda-0.0.1.js +62 -0
  55. data/vendor/jshoulda/dist/jshoulda-0.0.2.js +72 -0
  56. data/vendor/jshoulda/dist/jshoulda-0.0.3.js +72 -0
  57. data/vendor/jshoulda/dist/jshoulda-1.0.1.js +74 -0
  58. data/vendor/jshoulda/dist/jshoulda-1.0.js +72 -0
  59. data/vendor/jshoulda/dist/jshoulda-1.1.js +110 -0
  60. data/vendor/jshoulda/dist/jshoulda-1.2.1.js +186 -0
  61. data/vendor/jshoulda/dist/jshoulda-1.2.js +141 -0
  62. data/vendor/jshoulda/dist/jshoulda-1.2.x.js +142 -0
  63. data/vendor/jshoulda/dist/jshoulda.js +186 -0
  64. data/vendor/jshoulda/jshoulda/test/basic_test.html +42 -0
  65. data/vendor/jshoulda/lib/jstest.rb +382 -0
  66. data/vendor/jshoulda/lib/protodoc.rb +36 -0
  67. data/vendor/jshoulda/script/destroy +14 -0
  68. data/vendor/jshoulda/script/generate +14 -0
  69. data/vendor/jshoulda/script/js_autotest +1 -0
  70. data/vendor/jshoulda/script/rstakeout +97 -0
  71. data/vendor/jshoulda/site/asset_defaults.yaml +6 -0
  72. data/vendor/jshoulda/site/config.yaml +3 -0
  73. data/vendor/jshoulda/site/content/content.html +27 -0
  74. data/vendor/jshoulda/site/content/content.yaml +4 -0
  75. data/vendor/jshoulda/site/content/tutorial/tutorial.html +268 -0
  76. data/vendor/jshoulda/site/content/tutorial/tutorial.yaml +4 -0
  77. data/vendor/jshoulda/site/css/blackboard.css +88 -0
  78. data/vendor/jshoulda/site/css/jshoulda_site.css +33 -0
  79. data/vendor/jshoulda/site/css/unittest.css +42 -0
  80. data/vendor/jshoulda/site/example/minimal.html +55 -0
  81. data/vendor/jshoulda/site/js/editable.js +42 -0
  82. data/vendor/jshoulda/site/layouts/default/default.html +29 -0
  83. data/vendor/jshoulda/site/layouts/default/default.yaml +4 -0
  84. data/vendor/jshoulda/site/layouts/home_test/home_test.js +18 -0
  85. data/vendor/jshoulda/site/layouts/home_test/home_test.yaml +4 -0
  86. data/vendor/jshoulda/site/lib/analytics.rb +12 -0
  87. data/vendor/jshoulda/site/lib/default.rb +2 -0
  88. data/vendor/jshoulda/site/lib/example.rb +10 -0
  89. data/vendor/jshoulda/site/lib/hash.rb +11 -0
  90. data/vendor/jshoulda/site/lib/highlight.rb +17 -0
  91. data/vendor/jshoulda/site/page_defaults.yaml +10 -0
  92. data/vendor/jshoulda/site/templates/default/default.html +1 -0
  93. data/vendor/jshoulda/site/templates/default/default.yaml +4 -0
  94. data/vendor/jshoulda/src/HEADER +8 -0
  95. data/vendor/jshoulda/src/jshoulda.js +177 -0
  96. data/vendor/jshoulda/src/jshoulda.js.erb +3 -0
  97. data/vendor/jshoulda/tasks/bundle.rake +12 -0
  98. data/vendor/jshoulda/tasks/demo.rake +9 -0
  99. data/vendor/jshoulda/tasks/deploy.rake +29 -0
  100. data/{tasks → vendor/jshoulda/tasks}/environment.rake +0 -0
  101. data/vendor/jshoulda/tasks/javascript_test_autotest_tasks.rake +45 -0
  102. data/vendor/jshoulda/tasks/site.rake +74 -0
  103. data/vendor/jshoulda/test/assets/jsunittest.js +1004 -0
  104. data/vendor/jshoulda/test/assets/prototype.js +4324 -0
  105. data/{app_generators/newjs_iphone/templates/Html/test/assets/unittest.js → vendor/jshoulda/test/assets/prototype_unittest.js} +15 -9
  106. data/vendor/jshoulda/test/assets/unittest.css +50 -0
  107. data/vendor/jshoulda/test/unit/factory_test.html +82 -0
  108. data/vendor/jshoulda/test/unit/jshoulda2_test.html +85 -0
  109. data/vendor/jshoulda/test/unit/jshoulda_prototype_test.html +87 -0
  110. data/vendor/jshoulda/test/unit/jshoulda_test.html +86 -0
  111. data/vendor/jshoulda/test/unit/merge_methods_test.html +77 -0
  112. data/vendor/jshoulda/test/unit/names_and_count.html +68 -0
  113. data/vendor/jshoulda/test/unit/no_config_test.html +57 -0
  114. data/vendor/jshoulda/test/unit/styles_test.html +77 -0
  115. data/vendor/jshoulda/test/unit/unify_runners.html +69 -0
  116. data/vendor/jshoulda/test/unit/unnamed_context_test.html +67 -0
  117. data/vendor/jsunittest/Capfile +4 -0
  118. data/vendor/jsunittest/History.txt +37 -0
  119. data/{License.txt → vendor/jsunittest/License.txt} +0 -0
  120. data/vendor/jsunittest/README.txt +21 -0
  121. data/vendor/jsunittest/Rakefile +118 -0
  122. data/vendor/jsunittest/config/deploy.rb +20 -0
  123. data/vendor/jsunittest/config/website.yml.sample +2 -0
  124. data/vendor/jsunittest/dist/jsunittest-0.7.2.js +1004 -0
  125. data/vendor/jsunittest/dist/jsunittest.js +1004 -0
  126. data/vendor/jsunittest/dist/unittest.css +54 -0
  127. data/vendor/jsunittest/lib/jstest.rb +390 -0
  128. data/vendor/jsunittest/lib/protodoc.rb +36 -0
  129. data/vendor/jsunittest/script/destroy +14 -0
  130. data/vendor/jsunittest/script/generate +14 -0
  131. data/vendor/jsunittest/script/js_autotest +1 -0
  132. data/vendor/jsunittest/script/rstakeout +97 -0
  133. data/vendor/jsunittest/script/txt2html +75 -0
  134. data/vendor/jsunittest/src/HEADER +8 -0
  135. data/vendor/jsunittest/src/ajax.js +121 -0
  136. data/vendor/jsunittest/src/assertions.js +244 -0
  137. data/vendor/jsunittest/src/common.js +191 -0
  138. data/vendor/jsunittest/src/jsunittest.js +1004 -0
  139. data/vendor/jsunittest/src/logger.js +86 -0
  140. data/vendor/jsunittest/src/message_template.js +17 -0
  141. data/vendor/jsunittest/src/orig/unittest.js +484 -0
  142. data/vendor/jsunittest/src/prototype/event.js +72 -0
  143. data/vendor/jsunittest/src/prototype/template.js +33 -0
  144. data/vendor/jsunittest/src/runner.js +120 -0
  145. data/vendor/jsunittest/src/test_case.js +106 -0
  146. data/vendor/jsunittest/tasks/deploy.rake +29 -0
  147. data/vendor/jsunittest/tasks/environment.rake +7 -0
  148. data/vendor/jsunittest/tasks/javascript_test_autotest_tasks.rake +44 -0
  149. data/vendor/jsunittest/tasks/tmbundle.rake +24 -0
  150. data/vendor/jsunittest/tasks/website.rake +53 -0
  151. data/vendor/jsunittest/test/assets/example_test.html +50 -0
  152. data/{app_generators/newjs/templates → vendor/jsunittest}/test/assets/prototype.js +0 -0
  153. data/vendor/jsunittest/test/assets/unittest.css +54 -0
  154. data/{app_generators/newjs/templates → vendor/jsunittest}/test/assets/unittest.js +0 -0
  155. data/vendor/jsunittest/test/functional/jsunittest_test.html +209 -0
  156. data/vendor/jsunittest/test/unit/assertions_test.html +202 -0
  157. data/vendor/jsunittest/test/unit/common_test.html +61 -0
  158. data/vendor/jsunittest/test/unit/logger_test.html +98 -0
  159. data/vendor/jsunittest/test/unit/message_template_test.html +44 -0
  160. data/vendor/jsunittest/test/unit/runner_test.html +77 -0
  161. data/vendor/jsunittest/test/unit/template_test.html +57 -0
  162. data/vendor/jsunittest/test/unit/test_case_test.html +97 -0
  163. data/vendor/jsunittest/website/dist/jsunittest-0.7.2.js +1004 -0
  164. data/vendor/jsunittest/website/dist/jsunittest-getting-started.tar.gz +0 -0
  165. data/vendor/jsunittest/website/dist/jsunittest-getting-started.zip +0 -0
  166. data/vendor/jsunittest/website/dist/jsunittest-getting-started/assets/jsunittest.js +1004 -0
  167. data/vendor/jsunittest/website/dist/jsunittest-getting-started/assets/unittest.css +54 -0
  168. data/vendor/jsunittest/website/dist/jsunittest-getting-started/example_test.html +50 -0
  169. data/vendor/jsunittest/website/dist/jsunittest.js +1004 -0
  170. data/vendor/jsunittest/website/images/logo_bundle.png +0 -0
  171. data/vendor/jsunittest/website/images/passing_prototypejs_unittest_tests.jpg +0 -0
  172. data/vendor/jsunittest/website/index.html +94 -0
  173. data/vendor/jsunittest/website/index.txt +80 -0
  174. data/vendor/jsunittest/website/javascripts/rounded_corners_lite.inc.js +285 -0
  175. data/vendor/jsunittest/website/stylesheets/screen.css +138 -0
  176. data/vendor/jsunittest/website/template.html.erb +46 -0
  177. data/vendor/jsunittest/website/tmbundle/JavaScript Unit Testing.tmbundle.tar.gz +0 -0
  178. metadata +189 -24
  179. data/config/hoe.rb +0 -75
  180. data/config/requirements.rb +0 -17
  181. data/lib/newjs/version.rb +0 -9
  182. data/tasks/deployment.rake +0 -34
  183. data/tasks/jsunittest/update.rake +0 -18
  184. data/tasks/website.rake +0 -17
@@ -0,0 +1,50 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <title>JavaScript unit test file</title>
6
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7
+ <script src="assets/jsunittest.js" type="text/javascript"></script>
8
+
9
+ <!-- TODO: REPLACE "example_library_to_test" throughout file with name of file to test -->
10
+ <script src="../src/example_library_to_test.js" type="text/javascript"></script>
11
+
12
+ <link rel="stylesheet" href="assets/unittest.css" type="text/css" />
13
+ </head>
14
+ <body>
15
+
16
+ <div id="content">
17
+
18
+ <div id="header">
19
+ <h1>JavaScript unit test file</h1>
20
+ <p>
21
+ This file tests <strong>example_library_to_test.js</strong>.
22
+ </p>
23
+ </div>
24
+
25
+ <!-- Log output (one per Runner, via {testLog: "testlog"} option)-->
26
+ <div id="testlog"></div>
27
+
28
+ <!-- Put sample/test html here -->
29
+ <div id="sample">
30
+ </div>
31
+ </div>
32
+
33
+ <script type="text/javascript">
34
+ // <![CDATA[
35
+ new Test.Unit.Runner({
36
+ setup: function() {
37
+ },
38
+
39
+ teardown: function() {
40
+
41
+ },
42
+
43
+ testTruth: function() { with(this) {
44
+ assert(true);
45
+ }},
46
+ });
47
+ // ]]>
48
+ </script>
49
+ </body>
50
+ </html>
@@ -0,0 +1,54 @@
1
+ body, div, p, h1, h2, h3, ul, ol, span, a, table, td, form, img, li {
2
+ font-family: sans-serif;
3
+ }
4
+
5
+ body {
6
+ font-size:0.8em;
7
+ }
8
+
9
+ #log {
10
+ padding-bottom: 1em;
11
+ border-bottom: 2px solid #000;
12
+ margin-bottom: 2em;
13
+ }
14
+
15
+ .logsummary {
16
+ margin-top: 1em;
17
+ margin-bottom: 1em;
18
+ padding: 1ex;
19
+ border: 1px solid #000;
20
+ font-weight: bold;
21
+ }
22
+
23
+ .logtable {
24
+ width:100%;
25
+ border-collapse: collapse;
26
+ border: 1px dotted #666;
27
+ }
28
+
29
+ .logtable td, .logtable th {
30
+ text-align: left;
31
+ padding: 3px 8px;
32
+ border: 1px dotted #666;
33
+ }
34
+
35
+ .logtable .passed {
36
+ background-color: #cfc;
37
+ }
38
+
39
+ .logtable .failed, .logtable .error {
40
+ background-color: #fcc;
41
+ }
42
+
43
+ .logtable .warning {
44
+ background-color: #FC6;
45
+ }
46
+
47
+ .logtable td div.action_buttons {
48
+ display: inline;
49
+ }
50
+
51
+ .logtable td div.action_buttons input {
52
+ margin: 0 5px;
53
+ font-size: 10px;
54
+ }
@@ -0,0 +1,209 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <title>Original PrototypeJS UnitTest test file</title>
6
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7
+ <script src="../../dist/jsunittest.js" type="text/javascript"></script>
8
+ <link rel="stylesheet" href="../assets/unittest.css" type="text/css" />
9
+ <style type="text/css" media="screen">
10
+ /* <![CDATA[ */
11
+ #testcss1 { font-size:11px; color: #f00; }
12
+ #testcss2 { font-size:12px; color: #0f0; display: none; }
13
+ /* ]]> */
14
+ </style>
15
+ </head>
16
+ <body>
17
+ <h1>Original PrototypeJS UnitTest test file</h1>
18
+ <p>
19
+ Test the unit testing library (unittest.js)
20
+ </p>
21
+
22
+ <!-- Log output -->
23
+ <div id="testlog"> </div>
24
+ <div id="testlog_2"> </div>
25
+
26
+ <!-- Test elements follow -->
27
+ <div id="test_1" class="a bbbbbbbbbbbb cccccccccc dddd"> </div>
28
+
29
+ <div id="test_2"> <span> </span>
30
+
31
+
32
+
33
+ <div><div></div> </div><span> </span>
34
+ </div>
35
+
36
+ <ul id="tlist"><li id="tlist_1">x1</li><li id="tlist_2">x2</li></ul>
37
+ <ul id="tlist2"><li class="a" id="tlist2_1">x1</li><li id="tlist2_2">x2</li></ul>
38
+
39
+ <div id="testmoveby" style="background-color:#333;width:100px;">XXXX</div>
40
+
41
+ <div id="testcss1">testcss1<span id="testcss1_span" style="display:none;">blah</span></div><div id="testcss2">testcss1</div>
42
+
43
+ <!-- Tests follow -->
44
+ <script type="text/javascript" language="javascript" charset="utf-8">
45
+ // <![CDATA[
46
+
47
+ var testObj = {
48
+ isNice: function() {
49
+ return true;
50
+ },
51
+ isBroken: function() {
52
+ return false;
53
+ }
54
+ }
55
+
56
+ new JsUnitTest.Unit.Runner({
57
+ setup: function() {
58
+ this.testcss1 = JsUnitTest.$('testcss1');
59
+ this.testcss1_span = JsUnitTest.$('testcss1_span');
60
+ this.tlist = JsUnitTest.$('tlist');
61
+ },
62
+
63
+ testIsRunningFromRake: function() { with(this) {
64
+ if (window.location.toString().indexOf('http') > -1) {
65
+ assert(isRunningFromRake);
66
+ info('These tests are running from rake.')
67
+ } else {
68
+ assert(!isRunningFromRake);
69
+ info('These tests are *not* running from rake.')
70
+ }
71
+ }},
72
+
73
+ testBuildMessage: function() {
74
+ this.assertEqual("'foo' 'bar'", this.buildMessage('', '? ?', 'foo', 'bar'))
75
+ },
76
+
77
+ testAssertEqual: function() { with(this) {
78
+ assertEqual(0, 0);
79
+ assertEqual(0, 0, "test");
80
+
81
+ assertEqual(0,'0');
82
+ assertEqual(65.0, 65);
83
+
84
+ assertEqual("a", "a");
85
+ assertEqual("a", "a", "test");
86
+
87
+ assertNotEqual(0, 1);
88
+ assertNotEqual("a","b");
89
+ assertNotEqual({},{});
90
+ assertNotEqual([],[]);
91
+ assertNotEqual([],{});
92
+ }},
93
+
94
+ testAssertEnumEqual: function() { with(this) {
95
+ assertEnumEqual([], []);
96
+ assertEnumEqual(['a', 'b'], ['a', 'b']);
97
+ assertEnumEqual(['1', '2'], [1, 2]);
98
+ assertEnumNotEqual(['1', '2'], [1, 2, 3]);
99
+ }},
100
+
101
+ testAssertHashEqual: function() { with(this) {
102
+ assertHashEqual({}, {});
103
+ assertHashEqual({a:'b'}, {a:'b'});
104
+ assertHashEqual({a:'b', c:'d'}, {c:'d', a:'b'});
105
+ assertHashNotEqual({a:'b', c:'d'}, {c:'d', a:'boo!'});
106
+ }},
107
+
108
+ testAssertRespondsTo: function() { with(this) {
109
+ assertRespondsTo('isNice', testObj);
110
+ assertRespondsTo('isBroken', testObj);
111
+ }},
112
+
113
+ testAssertIdentical: function() { with(this) {
114
+ assertIdentical(0, 0);
115
+ assertIdentical(0, 0, "test");
116
+ assertIdentical(1, 1);
117
+ assertIdentical('a', 'a');
118
+ assertIdentical('a', 'a', "test");
119
+ assertIdentical('', '');
120
+ assertIdentical(undefined, undefined);
121
+ assertIdentical(null, null);
122
+ assertIdentical(true, true);
123
+ assertIdentical(false, false);
124
+
125
+ var obj = {a:'b'};
126
+ assertIdentical(obj, obj);
127
+
128
+ assertNotIdentical({1:2,3:4},{1:2,3:4});
129
+
130
+ assertIdentical(1, 1.0); // both are typeof == 'number'
131
+
132
+ assertNotIdentical(1, '1');
133
+ assertNotIdentical(1, '1.0');
134
+ }},
135
+
136
+ testAssertNullAndAssertUndefined: function() { with(this) {
137
+ assertNull(null);
138
+ assertNotNull(undefined);
139
+ assertNotNull(0);
140
+ assertNotNull('');
141
+ assertNotUndefined(null);
142
+ assertUndefined(undefined);
143
+ assertNotUndefined(0);
144
+ assertNotUndefined('');
145
+ assertNullOrUndefined(null);
146
+ assertNullOrUndefined(undefined);
147
+ assertNotNullOrUndefined(0);
148
+ assertNotNullOrUndefined('');
149
+ }},
150
+
151
+ testAssertMatch: function() { with(this) {
152
+ assertMatch(/knowmad.jpg$/, 'http://script.aculo.us/images/knowmad.jpg');
153
+ assertMatch(/Fuc/, 'Thomas Fuchs');
154
+ assertMatch(/^\$(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/, '$19.95');
155
+ assertMatch(/(\d{3}\) ?)|(\d{3}[- \.])?\d{3}[- \.]\d{4}(\s(x\d+)?){0,1}$/, '704-343-9330');
156
+ assertMatch(/^(?:(?:(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(\/|-|\.)(?:0?2\1(?:29)))|(?:(?:(?:1[6-9]|[2-9]\d)?\d{2})(\/|-|\.)(?:(?:(?:0?[13578]|1[02])\2(?:31))|(?:(?:0?[1,3-9]|1[0-2])\2(29|30))|(?:(?:0?[1-9])|(?:1[0-2]))\2(?:0?[1-9]|1\d|2[0-8]))))$/, '2001-06-16');
157
+ assertMatch(/^((0?[123456789])|(1[012]))\s*:\s*([012345]\d)(\s*:\s*([012345]\d))?\s*[ap]m\s*-\s*((0?[123456789])|(1[012]))\s*:\s*([012345]\d)(\s*:\s*([012345]\d))?\s*[ap]m$/i, '2:00PM-2:15PM');
158
+ assertNoMatch(/zubar/, 'foo bar');
159
+ }},
160
+
161
+ testAssertInstanceOf: function() { with(this) {
162
+ assertInstanceOf(String, new String);
163
+ assertInstanceOf(RegExp, /foo/);
164
+ assertNotInstanceOf(String, {});
165
+ }},
166
+
167
+ testAssertVisible: function() { with(this) {
168
+ assertVisible('testcss1');
169
+ assertNotVisible('testcss1_span');
170
+ //assertNotVisible('testcss2', "Due to a Safari bug, this test fails in Safari.");
171
+
172
+ // Element.hide('testcss1');
173
+ testcss1.style.display = "none";
174
+ assertNotVisible('testcss1');
175
+ assertNotVisible('testcss1_span');
176
+ // Element.show('testcss1');
177
+ testcss1.style.display = "block";
178
+ assertVisible('testcss1');
179
+ assertNotVisible('testcss1_span');
180
+
181
+ // Element.show('testcss1_span');
182
+ testcss1_span.style.display = "block";
183
+ assertVisible('testcss1_span');
184
+ // Element.hide('testcss1');
185
+ testcss1.style.display = "none";
186
+ assertNotVisible('testcss1_span'); // hidden by parent
187
+ }},
188
+
189
+ testAssertElementsMatch: function() { with(this) {
190
+ assertElementsMatch([tlist], '#tlist');
191
+ assertElementMatches(tlist, '#tlist');
192
+ }}
193
+
194
+ });
195
+
196
+ new JsUnitTest.Unit.Runner({
197
+ testDummy: function() { with(this) {
198
+ assert(true);
199
+ }},
200
+
201
+ testMultipleTestRunner: function() { with(this) {
202
+ // TODO assertEqual('passed', $('testlog_2').down('td', 1).innerHTML);
203
+ }}
204
+
205
+ }, {testLog: 'testlog_2'});
206
+ // ]]>
207
+ </script>
208
+ </body>
209
+ </html>
@@ -0,0 +1,202 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <title>JavaScript unit test file</title>
6
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7
+ <script src="../../dist/jsunittest.js" type="text/javascript"></script>
8
+ <script src="../../src/assertions.js" type="text/javascript"></script>
9
+
10
+ <link rel="stylesheet" href="../assets/unittest.css" type="text/css" />
11
+ <style type="text/css" media="screen">
12
+ /* <![CDATA[ */
13
+ #testcss1 { font-size:11px; color: #f00; }
14
+ #testcss2 { font-size:12px; color: #0f0; display: none; }
15
+ /* ]]> */
16
+ </style>
17
+ </head>
18
+ <body>
19
+
20
+ <div id="content">
21
+
22
+ <div id="header">
23
+ <h1>JavaScript unit test file</h1>
24
+ <p>
25
+ This file tests <strong>assertions.js</strong>.
26
+ </p>
27
+ </div>
28
+
29
+ <!-- Log output (one per Runner, via {testLog: "testlog"} option)-->
30
+ <div id="testlog"></div>
31
+
32
+ <!-- Put sample/test html here -->
33
+ <div id="sample">
34
+ <!-- Test elements follow -->
35
+ <div id="test_1" class="a bbbbbbbbbbbb cccccccccc dddd"> </div>
36
+
37
+ <div id="test_2"> <span> </span>
38
+
39
+ <div><div></div> </div><span> </span>
40
+ </div>
41
+
42
+ <ul id="tlist"><li id="tlist_1">x1</li><li id="tlist_2">x2</li></ul>
43
+ <ul id="tlist2"><li class="a" id="tlist2_1">x1</li><li id="tlist2_2">x2</li></ul>
44
+
45
+ <div id="testmoveby" style="background-color:#333;width:100px;">XXXX</div>
46
+
47
+ <div id="testcss1">testcss1<span id="testcss1_span" style="display:none;">blah</span></div><div id="testcss2">testcss1</div>
48
+
49
+ </div>
50
+ </div>
51
+
52
+ <script type="text/javascript">
53
+ // <![CDATA[
54
+
55
+ var testObj = {
56
+ isNice: function() {
57
+ return true;
58
+ },
59
+ isBroken: function() {
60
+ return false;
61
+ }
62
+ }
63
+
64
+ new Test.Unit.Runner({
65
+ setup: function() {
66
+ this.testcss1 = document.getElementById('testcss1');
67
+ this.testcss1_span = document.getElementById('testcss1_span');
68
+ this.tlist = document.getElementById('tlist');
69
+ },
70
+
71
+ testMessage: function() { with(this) {
72
+ info("No mechanism to report success/failure @ moment")
73
+ }},
74
+
75
+ testAssertEqual: function() { with(this) {
76
+ assertEqual(0, 0);
77
+ assertEqual(0, 0, "test");
78
+
79
+ assertEqual(0,'0');
80
+ assertEqual(65.0, 65);
81
+
82
+ assertEqual("a", "a");
83
+ assertEqual("a", "a", "test");
84
+
85
+ assertNotEqual(0, 1);
86
+ assertNotEqual("a","b");
87
+ assertNotEqual({},{});
88
+ assertNotEqual([],[]);
89
+ assertNotEqual([],{});
90
+ }},
91
+
92
+ testAssertEnumEqual: function() { with(this) {
93
+ assertEnumEqual([], []);
94
+ assertEnumEqual(['a', 'b'], ['a', 'b']);
95
+ assertEnumEqual(['1', '2'], [1, 2]);
96
+ assertEnumNotEqual(['1', '2'], [1, 2, 3]);
97
+ }},
98
+
99
+ testAssertHashEqual: function() { with(this) {
100
+ assertHashEqual({}, {});
101
+ assertHashEqual({a:'b'}, {a:'b'});
102
+ assertHashEqual({a:'b', c:'d'}, {c:'d', a:'b'});
103
+ assertHashNotEqual({a:'b', c:'d'}, {c:'d', a:'boo!'});
104
+ }},
105
+
106
+ testAssertRespondsTo: function() { with(this) {
107
+ assertRespondsTo('isNice', testObj);
108
+ assertRespondsTo('isBroken', testObj);
109
+ }},
110
+
111
+ testAssertIdentical: function() { with(this) {
112
+ assertIdentical(0, 0);
113
+ assertIdentical(0, 0, "test");
114
+ assertIdentical(1, 1);
115
+ assertIdentical('a', 'a');
116
+ assertIdentical('a', 'a', "test");
117
+ assertIdentical('', '');
118
+ assertIdentical(undefined, undefined);
119
+ assertIdentical(null, null);
120
+ assertIdentical(true, true);
121
+ assertIdentical(false, false);
122
+
123
+ var obj = {a:'b'};
124
+ assertIdentical(obj, obj);
125
+
126
+ assertNotIdentical({1:2,3:4},{1:2,3:4});
127
+
128
+ assertIdentical(1, 1.0); // both are typeof == 'number'
129
+
130
+ assertNotIdentical(1, '1');
131
+ assertNotIdentical(1, '1.0');
132
+ }},
133
+
134
+ testAssertNullAndAssertUndefined: function() { with(this) {
135
+ assertNull(null);
136
+ assertNotNull(undefined);
137
+ assertNotNull(0);
138
+ assertNotNull('');
139
+ assertNotUndefined(null);
140
+ assertUndefined(undefined);
141
+ assertNotUndefined(0);
142
+ assertNotUndefined('');
143
+ assertNullOrUndefined(null);
144
+ assertNullOrUndefined(undefined);
145
+ assertNotNullOrUndefined(0);
146
+ assertNotNullOrUndefined('');
147
+ }},
148
+
149
+ testAssertMatch: function() { with(this) {
150
+ assertMatch(/knowmad.jpg$/, 'http://scripaculo.us/images/knowmad.jpg');
151
+ assertMatch(/Fuc/, 'Thomas Fuchs');
152
+ assertMatch(/^\$(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/, '$19.95');
153
+ assertMatch(/(\d{3}\) ?)|(\d{3}[- \.])?\d{3}[- \.]\d{4}(\s(x\d+)?){0,1}$/, '704-343-9330');
154
+ assertMatch(/^(?:(?:(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(\/|-|\.)(?:0?2\1(?:29)))|(?:(?:(?:1[6-9]|[2-9]\d)?\d{2})(\/|-|\.)(?:(?:(?:0?[13578]|1[02])\2(?:31))|(?:(?:0?[1,3-9]|1[0-2])\2(29|30))|(?:(?:0?[1-9])|(?:1[0-2]))\2(?:0?[1-9]|1\d|2[0-8]))))$/, '2001-06-16');
155
+ assertMatch(/^((0?[123456789])|(1[012]))\s*:\s*([012345]\d)(\s*:\s*([012345]\d))?\s*[ap]m\s*-\s*((0?[123456789])|(1[012]))\s*:\s*([012345]\d)(\s*:\s*([012345]\d))?\s*[ap]m$/i, '2:00PM-2:15PM');
156
+ assertNoMatch(/zubar/, 'foo bar');
157
+ }},
158
+
159
+ testAssertInstanceOf: function() { with(this) {
160
+ assertInstanceOf(String, new String);
161
+ assertInstanceOf(RegExp, /foo/);
162
+ assertNotInstanceOf(String, {});
163
+ }},
164
+
165
+ testHasClass: function() { with(this) {
166
+ // <div id="test_1" class="a bbbbbbbbbbbb cccccccccc dddd"> </div>
167
+ assertHasClass('test_1', 'a');
168
+ // info(document.getElementById('test_1').className);
169
+ assertHasClass(document.getElementById('test_1'), 'dddd');
170
+ }},
171
+
172
+ testAssertVisible: function() { with(this) {
173
+ assertVisible('testcss1');
174
+ assertNotVisible('testcss1_span');
175
+ //assertNotVisible('testcss2', "Due to a Safari bug, this test fails in Safari.");
176
+
177
+ // Elemenhide('testcss1');
178
+ testcss1.style.display = "none";
179
+ assertNotVisible('testcss1');
180
+ assertNotVisible('testcss1_span');
181
+ // Elemenshow('testcss1');
182
+ testcss1.style.display = "block";
183
+ assertVisible('testcss1');
184
+ assertNotVisible('testcss1_span');
185
+
186
+ // Elemenshow('testcss1_span');
187
+ testcss1_span.style.display = "block";
188
+ assertVisible('testcss1_span');
189
+ // Elemenhide('testcss1');
190
+ testcss1.style.display = "none";
191
+ assertNotVisible('testcss1_span'); // hidden by parent
192
+ }},
193
+
194
+ testAssertElementsMatch: function() { with(this) {
195
+ assertElementsMatch([tlist], '#tlist');
196
+ assertElementMatches(tlist, '#tlist');
197
+ }}
198
+ });
199
+ // ]]>
200
+ </script>
201
+ </body>
202
+ </html>