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>script.aculo.us Unit test file</title> |
---|
6 | <meta http-equiv="content-type" content="text/html; charset=utf-8" /> |
---|
7 | <script src="../../lib/prototype.js" type="text/javascript"></script> |
---|
8 | <script src="../../src/scriptaculous.js" type="text/javascript"></script> |
---|
9 | <script src="../../src/unittest.js" type="text/javascript"></script> |
---|
10 | <link rel="stylesheet" href="../test.css" type="text/css" /> |
---|
11 | </head> |
---|
12 | <body> |
---|
13 | <h1>script.aculo.us Unit test file</h1> |
---|
14 | <p> |
---|
15 | Tests for String.prototype extensions in effects.js |
---|
16 | </p> |
---|
17 | |
---|
18 | <!-- Log output --> |
---|
19 | <div id="testlog"> </div> |
---|
20 | |
---|
21 | <!-- Tests follow --> |
---|
22 | <script type="text/javascript" language="javascript" charset="utf-8"> |
---|
23 | // <![CDATA[ |
---|
24 | |
---|
25 | new Test.Unit.Runner({ |
---|
26 | |
---|
27 | testStringParseColor: function() { with(this) { |
---|
28 | assertEqual('#000000', "#000000".parseColor()); |
---|
29 | assertEqual('#000000', "rgb(0,0,0)".parseColor()); |
---|
30 | assertEqual('#000000', "rgb(0, 0, 0)".parseColor()); |
---|
31 | assertEqual('#000000', "#000".parseColor()); |
---|
32 | |
---|
33 | assertEqual('#1', "#1".parseColor()); |
---|
34 | assertEqual('#12', "#12".parseColor()); |
---|
35 | assertEqual('#112233', "#123".parseColor()); |
---|
36 | assertEqual('#1234', "#1234".parseColor()); |
---|
37 | assertEqual('#12345', "#12345".parseColor()); |
---|
38 | assertEqual('#123456', "#123456".parseColor()); |
---|
39 | |
---|
40 | assertEqual('#abcdef', "#aBcDeF".parseColor()); |
---|
41 | assertEqual('#aabbcc', "#aBc".parseColor()); |
---|
42 | |
---|
43 | assertEqual('white', "white".parseColor()); |
---|
44 | assertEqual('#123456', "#123456".parseColor('#000000')); // default to #000000 if not parseable |
---|
45 | assertEqual('#000000', "white".parseColor('#000000')); // default to #000000 if not parseable |
---|
46 | |
---|
47 | assertEqual('#ffffff', "rgb(255,255,255)".parseColor()); |
---|
48 | assertEqual('#ff0000', "rgb(255,0,0)".parseColor()); |
---|
49 | assertEqual('#00ff00', "rgb(0,255,0)".parseColor()); |
---|
50 | assertEqual('#0000ff', "rgb(0,0,255)".parseColor()); |
---|
51 | }}, |
---|
52 | |
---|
53 | testStringParseStyle: function() { with(this) { |
---|
54 | var expected = "#<Hash:{'fontSize': '11px'}>"; |
---|
55 | var expectedMultiple = "#<Hash:{'fontSize': '11px', 'width': '780px'}>"; |
---|
56 | |
---|
57 | assertInspect(expected, "font-size:11px".parseStyle()); |
---|
58 | assertInspect(expected, "font-SIZE: 11px".parseStyle()); |
---|
59 | assertInspect(expected, "font-size:11px ".parseStyle()); |
---|
60 | assertInspect(expected, " Font-size: 11px ".parseStyle()); |
---|
61 | |
---|
62 | assertInspect(expectedMultiple, " font-size: 11px;width:780px".parseStyle()); |
---|
63 | |
---|
64 | }} |
---|
65 | |
---|
66 | }); |
---|
67 | |
---|
68 | // ]]> |
---|
69 | </script> |
---|
70 | </body> |
---|
71 | </html> |
---|