-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
100 lines (88 loc) · 2.77 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
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
<!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>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script src="src/reindr.js" type="text/javascript"></script>
<style type="text/css">
#results div {
padding: 12px;
background: #ccc;
border: 1px solid black;
margin-bottom: 8px;
}
#results div.pass {
background: #C4FFA0;
border-color: #4ECB00;
color: #4ECB00;
font-size: 14px;
font-weight: bold;
}
#results div.fail {
background: #FFADAD;
border-color: #FF0000;
color: #FF0000;
font-size: 14px;
font-weight: bold;
}
</style>
<script type="text/javascript">
var pass = function(desc) {
var result = "<div class=\"pass\">";
result += "<span>Pass: " + desc + "</span>";
result += "</div>";
$("#results").append(result);
};
var fail = function(desc, msg) {
var result = $("<div>").addClass("fail");
var desc = $("<span>").text("Failure: " + desc);
var msg = $("<span>").text(msg);
$("#results").append(result.append(msg).append(msg));
};
var assert_renders = function(rd, markup, desc){
//same markup without whitespaces
if(rd.replace(/\s/g,'') == markup.replace(/\s/g,'')){
pass(desc);
}else{
fail(desc, "expected: " + rd + " to be: " + markup);
}
};
$(function(){
var example1 = reindr(function(){
return [span, "lol"];
});
assert_renders(example1, '<span>lol</span>', "tag with content");
var example2 = reindr(function(){
return [span, [a, "myhouse"]];
});
assert_renders(example2, "<span><a>myhouse</a></span>", "nested tag with content");
var example3 = reindr(function(){
return [span({class: "droid"}), "Robots"];
});
assert_renders(example3, '<span class="droid">Robots</span>', "tag with attributes");
var example4 = reindr(function(){
return [ul,
[li, "ichi"],
[li, "ni"],
[li, "san"],
];
});
assert_renders(example4, '<ul><li>ichi</li><li>ni</li><li>san</li></ul>', "tag with multiple children with respective content");
//templates
var my_func = reindr(function(obj){
return [div,
[a, obj.name]];
});
var my_obj = {name: "knives chau"};
//assert_renders(my_func(my_obj));
});
</script>
</head>
<body>
<h1>Reindr tests</h1>
<div id="results">
</div>
<div id="target1" style="visibility: hidden"></div>
</body>
</html>