-
Notifications
You must be signed in to change notification settings - Fork 28
/
test.html
66 lines (54 loc) · 1.95 KB
/
test.html
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Color Wheel Demo</title>
<script src="//code.jquery.com/jquery-2.1.0.min.js" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.2/raphael-min.js" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/qunit/1.14.0/qunit.min.js" type="text/javascript"></script>
<script src="./colorwheel.js" type="text/javascript"></script>
<script type='text/javascript'>
function run_tests(){
function input_example(){
var cw = Raphael.colorwheel($("#test .colorwheel")[0],150);
cw.input($("#test input")[0]);
return cw;
}
function callback_example(){
var cw = Raphael.colorwheel($("#test .colorwheel")[0],150);
cw.input($("#test input")[0]);
return cw;
}
module("Color Wheel");
var input = $("#test input");
var cw = input_example();
test("setting the color value updates the picker and the input", function(){
cw.color("#FF0000");
equal("#ff0000", cw.color().hex, "the color value is set");
equal("#ff0000", input.val(), "input is set");
});
module("Callback");
test("onchange should happen when user interaction happens", function(){
var onchange_count = 0;
cw.onchange(function(){ onchange_count += 1; });
equal(onchange_count, 0, "onchange has not triggered yet");
input.val("#FFFFFF").trigger("keyup");
equal(onchange_count, 1, "onchange should trigger when input changed");
});
}
$(run_tests);
</script>
</head>
<body>
<h1 id="qunit-header">Colorwheel Test</h1>
<h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests">
</ol>
<div id='test'>
<div class='colorwheel'/>
<input id='test_input' type='text'/>
</div>
</body>
</html>