forked from wycats/jspec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtester2.html
65 lines (57 loc) · 2.15 KB
/
tester2.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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>tester2</title>
<meta name="generator" content="TextMate http://macromates.com/">
<meta name="author" content="Yehuda Katz">
<script src="jspec.js"></script>
<script>
window.onload = function() {
jspec.describe("JSpec", function() {
it("should support ==", function() {
expect(1).to("==", 1);
var arr = [];
expect(arr).to("==", arr);
var obj = new Object;
expect(obj).to("==", obj);
expect(document).to("==", document);
});
it("should support include", function() {
expect([1,2,3,4,5]).to("include", 3);
expect([1,2,3,4,5]).not_to("include", 3);
expect(document.getElementsByTagName("div")).to("include", document.getElementById("hello"))
});
it("should support exists", function() {
expect(document).to("exist");
});
it("should support pending specs");
jspec.matchers["have_tag_name"] = {
describe: function(self, target, not) {
return jspec.print_object(self) + " should " + (not ? "not " : "") + "have " + target + " as its tag name."
},
matches: function(self, target) {
return (self.tagName && self.tagName == target) ? true : false;
},
failure_message: function(self, target, not) {
return "Expected " + jspec.print_object(self) + (not ? " not " : " ") + "to have " + target + " as its tag name," +
" but was " + self.tagName;
}
};
it("should support custom matchers", function() {
expect(document.getElementById("wrapper")).to("have_tag_name", "DIV");
expect(document.getElementById("wrapper")).to("have_tag_name", "SPAN");
expect(document.getElementById("wrapper")).not_to("have_tag_name", "SPAN");
});
});
};
</script>
<style type="text/css">
div#wrapper { display: none ;}
</style>
</head>
<body>
<div id="wrapper"><div id="hello">Hello</div></div>
</body>
</html>