Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: 0.1
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 127 lines (109 sloc) 3.677 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
<%--
 Copyright 2010 Dan Lynn

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
 --%>
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
  <head>
    <title>Test Runner</title>
    <style type="text/css">
      .pass {color: green;}
      .fail {color: red;}
    </style>
    <g:urlMappings />
  </head>
  <body>
    <script type="text/javascript">
      /*
            Super lightweight jUnit-style testing harness.
           */

      function pass(name) {
        document.write('<div class="pass">' + name + '</div>');
      }

      function fail(name, message) {
        document.write('<div class="fail">' + name + ': ' + message + '</div>');
      }

      var Assert = {
        equals : function(expected, actual, message) {
          if (expected != actual) {
            throw 'Expected "' + expected + '", but got "' + actual + '".' + (message ? ' ' + message : '');
          }
        }
      };
      var tests = {
        createLink_draws_id : function() {
          var expected = "${createLink(controller: 'a', action: 'one', params: [id: '3', key: 'value'])}";
          var actual = g.createLink({
                      controller: 'a',
                      action: 'one',
                      params: {
                        id: 3,
                        key: 'value'
                      }});

          Assert.equals(expected, actual);
        },

        createLink_without_id : function() {
          var expected = "${createLink(controller: 'a', action: 'one', params: [key: 'value'])}";
          var actual = g.createLink({
                      controller: 'a',
                      action: 'one',
                      params: {
                        key: 'value'
                      }});

          Assert.equals(expected, actual);
        },

        createLink_just_controller : function() {
          var expected = "${createLink(controller: 'a')}";
          var actual = g.createLink({controller: 'a'});

          Assert.equals(expected, actual);
        },

        resource_with_dir_and_file: function() {
          Assert.equals(
                  '${resource(dir: 'aDir', file: 'aFile.txt')}',
                  g.resource({dir: 'aDir', file: 'aFile.txt'})
          );
        },

        resource_only_dir: function() {
          Assert.equals(
                  '${resource(dir: 'aDir')}',
                  g.resource({dir: 'aDir'})
          );
        },

        resource_only_file: function() {
          Assert.equals(
                  '${resource(file: 'aFile.txt')}',
                  g.resource({file: 'aFile.txt'})
          );
        },

        resource_dir_only_slash: function() {
          Assert.equals(
                  '${resource(dir: '/')}',
                  g.resource({dir: '/'})
          );
        },

        resource_file_only_slash: function() {
          Assert.equals(
                  '${resource(file: '/')}',
                  g.resource({file: '/'})
          );
        }

      }

      for (var test in tests) {
        try {
          tests[test]();
          pass(test);
        } catch (error) {
          fail(test, error);
        }
      }
    </script>
  </body>
</html>
Something went wrong with that request. Please try again.