Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 127 lines (109 sloc) 3.677 kb
8947561 basic functionality. see README
Dan Lynn authored
1 <%--
2 Copyright 2010 Dan Lynn
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 --%>
16 <%@ page contentType="text/html;charset=UTF-8" %>
17 <html>
18 <head>
c76327e @danklynn added javascript unit tests, g.resource() function, and "controller/acti...
authored
19 <title>Test Runner</title>
20 <style type="text/css">
21 .pass {color: green;}
22 .fail {color: red;}
23 </style>
8947561 basic functionality. see README
Dan Lynn authored
24 <g:urlMappings />
25 </head>
26 <body>
27 <script type="text/javascript">
c76327e @danklynn added javascript unit tests, g.resource() function, and "controller/acti...
authored
28 /*
29 Super lightweight jUnit-style testing harness.
30 */
8947561 basic functionality. see README
Dan Lynn authored
31
c76327e @danklynn added javascript unit tests, g.resource() function, and "controller/acti...
authored
32 function pass(name) {
33 document.write('<div class="pass">' + name + '</div>');
34 }
8947561 basic functionality. see README
Dan Lynn authored
35
c76327e @danklynn added javascript unit tests, g.resource() function, and "controller/acti...
authored
36 function fail(name, message) {
37 document.write('<div class="fail">' + name + ': ' + message + '</div>');
38 }
39
40 var Assert = {
41 equals : function(expected, actual, message) {
42 if (expected != actual) {
43 throw 'Expected "' + expected + '", but got "' + actual + '".' + (message ? ' ' + message : '');
44 }
45 }
46 };
47 var tests = {
48 createLink_draws_id : function() {
49 var expected = "${createLink(controller: 'a', action: 'one', params: [id: '3', key: 'value'])}";
50 var actual = g.createLink({
51 controller: 'a',
52 action: 'one',
53 params: {
54 id: 3,
55 key: 'value'
56 }});
57
58 Assert.equals(expected, actual);
59 },
60
61 createLink_without_id : function() {
62 var expected = "${createLink(controller: 'a', action: 'one', params: [key: 'value'])}";
63 var actual = g.createLink({
64 controller: 'a',
65 action: 'one',
66 params: {
67 key: 'value'
68 }});
69
70 Assert.equals(expected, actual);
71 },
72
73 createLink_just_controller : function() {
74 var expected = "${createLink(controller: 'a')}";
75 var actual = g.createLink({controller: 'a'});
76
77 Assert.equals(expected, actual);
78 },
79
80 resource_with_dir_and_file: function() {
81 Assert.equals(
82 '${resource(dir: 'aDir', file: 'aFile.txt')}',
83 g.resource({dir: 'aDir', file: 'aFile.txt'})
84 );
85 },
86
87 resource_only_dir: function() {
88 Assert.equals(
89 '${resource(dir: 'aDir')}',
90 g.resource({dir: 'aDir'})
91 );
92 },
93
94 resource_only_file: function() {
95 Assert.equals(
96 '${resource(file: 'aFile.txt')}',
97 g.resource({file: 'aFile.txt'})
98 );
99 },
100
101 resource_dir_only_slash: function() {
102 Assert.equals(
103 '${resource(dir: '/')}',
104 g.resource({dir: '/'})
105 );
106 },
107
108 resource_file_only_slash: function() {
109 Assert.equals(
110 '${resource(file: '/')}',
111 g.resource({file: '/'})
112 );
113 }
114
115 }
116
117 for (var test in tests) {
118 try {
119 tests[test]();
120 pass(test);
121 } catch (error) {
122 fail(test, error);
123 }
124 }
8947561 basic functionality. see README
Dan Lynn authored
125 </script>
126 </body>
127 </html>
Something went wrong with that request. Please try again.