-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtdd.html
196 lines (171 loc) · 6.55 KB
/
tdd.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
"use strict";
</script>
<script type="text/javascript" src="js-small/js-small.js"></script>
<script type="text/javascript" src="js-small/plugins/init.js"></script>
<style type="text/css">
body {
font: normal 300 12px Tahoma;
color: gray;
}
body > div {
display: block;
overflow: hidden;
width: 300px;
}
body > div > span {
display: block;
float: right;
width: 50px;
color: darkred;
font-weight: 800;
}
body > div > span.success {
color: darkgreen;
}
</style>
</head>
<body>
<div id="ready">Ready on page load event: <span>ERR</span></div>
<div id="ext-fun">Extending js-small function: <span>ERR</span></div>
<div id="ext-met">Extending js-small method: <span>ERR</span></div>
<div id="each"><b>Each</b> method for DOM nodes: <span>ERR</span></div>
<div id="grep"><b>Grep</b> method for DOM nodes: <span>ERR</span></div>
<div id="concat"><b>Concat</b> method for DOM node: <span>ERR</span></div>
<div id="text"><b>Text</b> method for DOM node: <span>ERR</span></div>
<div id="html"><b>Html</b> method for DOM node: <span>ERR</span></div>
<div id="empty"><b>Empty</b> method for DOM node: <span>ERR</span></div>
<div id="node"><b>Node</b> method for DOM nodes: <span>ERR</span></div>
<div id="tag"><b>TagName</b> method for DOM node: <span>ERR</span></div>
<div id="do-focus"><b>DoFocus</b> method for DOM node: <span>ERR</span></div>
<div id="evt-focus"><b>Focus Event</b> method for DOM node: <span>ERR</span></div>
<div id="do-blur"><b>DoBlur</b> method for DOM node: <span>ERR</span></div>
<div id="evt-blur"><b>Blur Event</b> method for DOM node: <span>ERR</span></div>
<div id="do-submit"><b>DoSubmit</b> method for DOM node: <span>ERR</span></div>
<div id="evt-submit"><b>Submit Event</b> method for DOM node: <span>ERR</span></div>
<div id="frame-document"><b>Document</b> method for Frame/iFrame node: <span>ERR</span></div>
<div id="frame-body"><b>Body</b> method for Frame/iFrame node: <span>ERR</span></div>
<div id="parent"><b>Parent</b> method for DOM node: <span>ERR</span></div>
<div id="child"><b>Child</b> method for DOM node: <span>ERR</span></div>
<div id="children"><b>Children</b> method for DOM node: <span>ERR</span></div>
<div id="siblings"><b>Siblings</b> method for DOM node: <span>ERR</span></div>
<script type="text/javascript">
small.plugins();
/* small.ready */
small.ready(function() {
/* small.extendMethods */
small.extendMethods({
"setOK": function() {
small('#ext-met').find('span').addClass('success').text('OK');
small(this).find('span').addClass('success').text('OK');
},
"setERR": function() {
small('#ext-met').find('span').addClass('success').text('OK');
small(this).find('span').removeClass('success').text('ERR');
}
});
/* small.extendFunctions */
small.extendFunctions({
'resetTDD': function() {
small('body').find('div').setERR();
small('#ext-fun').setOK();
}
});
small.resetTDD();
small('#ready').setOK();
/* small.each */
small('div').each(function(object) {
object.id == 'each' ? small(object).setOK() : null;
});
/* small.grep */
small('div').grep(function(object) {
return object.id == 'grep';
}).setOK();
/* small.concat */
small('#concat').find('span').concat('test');
if(small('#concat').find('span').text() == 'ERRtest') {
small('#concat').setOK();
}
/* small.text */
small('#text').find('span').text('test');
if(small('#text').find('span').text() == 'test') {
small('#text').setOK();
}
/* small.html */
small('#html').find('span').html('<b>test</b>');
if(small('#html').find('span').html() == '<b>test</b>') {
small('#html').setOK();
}
/* small.empty */
small('#empty').find('span').empty();
small('#empty').find('span').empty(function() {
small('#empty').setOK();
}, function() {
small('#empty').setERR();
});
/* small.node */
if(small('body').find('div').node(3).id == 'each') {
small('#node').setOK();
}
/* small.tagName */
if(small('body').tagName() == 'body') {
small('#tag').setOK();
}
/* small.doFocus & small.focus*/
small('body').append('input[type=text][id=text]')
.focus(function() {
small('#do-focus').setOK();
small('#evt-focus').setOK();
})
.doFocus();
/* small.doBlur & small.blur */
small('input#text')
.blur(function() {
small('#do-blur').setOK();
small('#evt-blur').setOK();
}).doBlur();
small('input#text').remove();
/* small.doSubmit & small.submit */
var form = small('body')
.append('form')
.attr({
'action': '',
'method': 'post'
}).submit(function() {
small('#do-submit').setOK();
small('#evt-submit').setOK();
return false;
}).doSubmit();
/* small.body & small.document */
var iframeBody = small('body').append('iframe').hide().body();
iframeBody.text('inner');
if(iframeBody.serialize() == '<body>inner</body>') {
small('#frame-document').setOK();
small('#frame-body').setOK();
}
small('iframe').remove();
/* small.parent */
if(small('#parent').parent().tagName() == 'body') {
small('#parent').setOK();
}
/* small.child */
if(small('#child').child().length() == 2) {
small('#child').setOK();
}
/* small.children */
if(small('#children').children().length() == 2) {
small('#children').setOK();
}
/* small.siblings */
if(small('#siblings').child().siblings().tagName() == 'span') {
small('#siblings').setOK();
}
});
</script>
</body>
</html>