dom/tests/mochitest/ajax/scriptaculous/test/unit/unit_test.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/ajax/scriptaculous/test/unit/unit_test.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,154 @@
     1.4 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     1.5 +        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     1.6 +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
     1.7 +<head>
     1.8 +  <title>script.aculo.us Unit test file</title>
     1.9 +  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    1.10 +  <script src="../../lib/prototype.js" type="text/javascript"></script>
    1.11 +  <script src="../../src/scriptaculous.js" type="text/javascript"></script>
    1.12 +  <script src="../../src/unittest.js" type="text/javascript"></script>
    1.13 +  <link rel="stylesheet" href="../test.css" type="text/css" />
    1.14 +  <style type="text/css" media="screen">
    1.15 +  /* <![CDATA[ */
    1.16 +    #testcss1 { font-size:11px; color: #f00; }
    1.17 +    #testcss2 { font-size:12px; color: #0f0; display: none; }
    1.18 +  /* ]]> */
    1.19 +  </style>
    1.20 +</head>
    1.21 +<body>
    1.22 +<h1>script.aculo.us Unit test file</h1>
    1.23 +<p>
    1.24 +  This is a preliminary version mostly for testing the unittest library.
    1.25 +</p>
    1.26 +
    1.27 +<!-- Log output -->
    1.28 +<div id="testlog"> </div>
    1.29 +
    1.30 +<!-- Test elements follow -->
    1.31 +<div id="test_1" class="a bbbbbbbbbbbb cccccccccc dddd"> </div>
    1.32 +
    1.33 +<div id="test_2"> <span> </span> 
    1.34 +
    1.35 +
    1.36 +
    1.37 +<div><div></div> </div><span> </span>
    1.38 +</div>
    1.39 +
    1.40 +<ul id="tlist"><li id="tlist_1">x1</li><li id="tlist_2">x2</li></ul>
    1.41 +<ul id="tlist2"><li class="a" id="tlist2_1">x1</li><li id="tlist2_2">x2</li></ul>
    1.42 +
    1.43 +<div id="testmoveby" style="background-color:#333;width:100px;">XXXX</div>
    1.44 +
    1.45 +<div id="testcss1">testcss1<span id="testcss1_span" style="display:none;">blah</span></div><div id="testcss2">testcss1</div>
    1.46 +
    1.47 +<!-- Tests follow -->
    1.48 +<script type="text/javascript" language="javascript" charset="utf-8">
    1.49 +// <![CDATA[
    1.50 +
    1.51 +  var testObj = {
    1.52 +    isNice: function(){
    1.53 +      return true;
    1.54 +    },
    1.55 +    isBroken: function(){
    1.56 +      return false;
    1.57 +    }
    1.58 +  }
    1.59 +
    1.60 +  new Test.Unit.Runner({
    1.61 +    
    1.62 +    testAssertEqual: function() { with(this) {
    1.63 +      assertEqual(0, 0);
    1.64 +      assertEqual(0, 0, "test");
    1.65 +      
    1.66 +      assertEqual(0,'0');
    1.67 +      assertEqual(65.0, 65);
    1.68 +      
    1.69 +      assertEqual("a", "a");
    1.70 +      assertEqual("a", "a", "test");
    1.71 +      
    1.72 +      assertNotEqual(0, 1);
    1.73 +      assertNotEqual("a","b");
    1.74 +      assertNotEqual({},{});
    1.75 +      assertNotEqual([],[]);
    1.76 +      assertNotEqual([],{});
    1.77 +    }},
    1.78 +    
    1.79 +    testAssertRespondsTo: function() { with(this) {
    1.80 +      assertRespondsTo('isNice', testObj);
    1.81 +      assertRespondsTo('isBroken', testObj);
    1.82 +    }},
    1.83 +    
    1.84 +    testAssertIndentical: function() { with(this) { 
    1.85 +      assertIdentical(0, 0); 
    1.86 +      assertIdentical(0, 0, "test"); 
    1.87 +      assertIdentical(1, 1); 
    1.88 +      assertIdentical('a', 'a'); 
    1.89 +      assertIdentical('a', 'a', "test"); 
    1.90 +      assertIdentical('', ''); 
    1.91 +      assertIdentical(undefined, undefined); 
    1.92 +      assertIdentical(null, null); 
    1.93 +      assertIdentical(true, true); 
    1.94 +      assertIdentical(false, false); 
    1.95 +      
    1.96 +      var obj = {a:'b'};
    1.97 +      assertIdentical(obj, obj);
    1.98 +      
    1.99 +      assertNotIdentical({1:2,3:4},{1:2,3:4});
   1.100 +      
   1.101 +      assertIdentical(1, 1.0); // both are typeof == 'number'
   1.102 +      
   1.103 +      assertNotIdentical(1, '1');
   1.104 +      assertNotIdentical(1, '1.0');
   1.105 +    }},
   1.106 +    
   1.107 +    testAssertMatch: function() { with(this) {
   1.108 +      assertMatch(/knowmad.jpg$/, 'http://script.aculo.us/images/knowmad.jpg');
   1.109 +      assertMatch(/Fuc/, 'Thomas Fuchs');
   1.110 +      assertMatch(/^\$(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/, '$19.95');
   1.111 +      assertMatch(/(\d{3}\) ?)|(\d{3}[- \.])?\d{3}[- \.]\d{4}(\s(x\d+)?){0,1}$/, '704-343-9330');
   1.112 +           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');
   1.113 +      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');
   1.114 +      
   1.115 +    }},
   1.116 +    
   1.117 +    testAssertInstanceOf: function() { with(this) {
   1.118 +      assertInstanceOf(Effect.Opacity, new Effect.Opacity('testcss1',{sync:true}));
   1.119 +      assertNotInstanceOf(String, new Effect.Opacity('testcss1',{sync:true}));
   1.120 +      
   1.121 +      // note: fails with firefox 1.0.X (bug, fixed in Deer Park)
   1.122 +      assertNotInstanceOf(Effect.Parallel, new Effect.Opacity('testcss1',{sync:true}), "(note: fails with firefox 1.0.X, fixed in Deer Park)");   
   1.123 +    }},
   1.124 +    
   1.125 +    testAssertReturns: function() { with(this) {
   1.126 +      
   1.127 +      assertReturnsTrue('isNice',testObj);
   1.128 +      assertReturnsFalse('isBroken',testObj);
   1.129 +      
   1.130 +      assertReturnsTrue('nice',testObj);
   1.131 +      assertReturnsFalse('broken',testObj);
   1.132 +      
   1.133 +    }},
   1.134 +  
   1.135 +    testAssertVisible: function() { with(this) {
   1.136 +      assertVisible('testcss1');
   1.137 +      assertNotVisible('testcss1_span');
   1.138 +      assertNotVisible('testcss2', "Due to a Safari bug, this test fails in Safari.");
   1.139 +      
   1.140 +      Element.hide('testcss1');
   1.141 +      assertNotVisible('testcss1');
   1.142 +      assertNotVisible('testcss1_span');
   1.143 +      Element.show('testcss1');
   1.144 +      assertVisible('testcss1');
   1.145 +      assertNotVisible('testcss1_span');
   1.146 +      
   1.147 +      Element.show('testcss1_span');
   1.148 +      assertVisible('testcss1_span');
   1.149 +      Element.hide('testcss1');
   1.150 +      assertNotVisible('testcss1_span'); // hidden by parent
   1.151 +    }}
   1.152 +      
   1.153 +  }, "testlog");
   1.154 +// ]]>
   1.155 +</script>
   1.156 +</body>
   1.157 +</html>
   1.158 \ No newline at end of file

mercurial