public
Description: A JavaScript BDD Testing Library
Homepage: http://www.yehudakatz.com
Clone URL: git://github.com/wycats/jspec.git
jspec / tester.html
100644 101 lines (80 sloc) 2.837 kb
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
101
<!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>tester</title>
<meta name="generator" content="TextMate http://macromates.com/">
<meta name="author" content="Yehuda Katz">
<script src="jspec.js"></script>
<script>$ = "$"</script>
<script src="jquery.js"></script>
<script>
jspec.describe("The browser environment", function() {
it("should have Array.prototype.push", function() {
Array.prototype.push.should("exist");
});
 
it("should have Function.prototype.apply", function() {
Function.prototype.apply.should("exist");
});
 
it("should have document.getElementById", function() {
        document.getElementById.should("exist");
});
 
      it("should have document.getElementsByTagName", function() {
        document.getElementsByTagName.should("exist");
      });
      
      it("should have RegExp", function() {
        RegExp.should("exist");
      });
      
      it("should have jQuery", function() {
        jQuery.should("exist");
      });
})
 
jspec.describe("$()", function() {
it("should generate the correct number of elements for <code>", function() {
$("<code/>").length.should("==", 1);
});
 
it("should generate the correct number of elements for <img>", function() {
$("<img/>").length.should("==", 1);
});
 
it("should generate the correct number of elements for <div/><hr/><code/><b/>", function() {
$("<div/><hr/><code/><b/>").length.should("==", 4);
});
})
 
jspec.describe("jQuery.noConflict()", function() {
var old = jQuery;
var newjQuery = jQuery.noConflict();
 
it("should return the jQuery object", function() {
newjQuery.should("==", old);
});
 
it("should not have harmed the original jQuery", function() {
jQuery.should("==", old)
});
 
it("should revert $", function() {
$.should("==", "$");
});
 
jQuery = $ = old;
newjQuery = jQuery.noConflict(true);
 
 
})
 
    // var old = jQuery;
    // var newjQuery = jQuery.noConflict();
    //
    // ok( newjQuery == old, "noConflict returned the jQuery object" );
    // ok( jQuery == old, "Make sure jQuery wasn't touched." );
    // ok( $ == "$", "Make sure $ was reverted." );
    //
    // jQuery = $ = old;
    //
    // newjQuery = jQuery.noConflict(true);
    //
    // ok( newjQuery == old, "noConflict returned the jQuery object" );
    // ok( jQuery == "jQuery", "Make sure jQuery was reverted." );
    // ok( $ == "$", "Make sure $ was reverted." );
    //
    // jQuery = $ = old;
  
 
</script>
<!-- Date: 2007-10-28 -->
</head>
<body>
 
</body>
</html>