Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
64 lines (58 sloc) 2.86 KB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>helpers.js test file</title>
<link rel="stylesheet" href="../lib/test.css" type="text/css" />
<script src="../lib/prototype.js" type="text/javascript"></script>
<script src="../lib/unittest.js" type="text/javascript"></script>
<script src="../element.methods.js" type="text/javascript"></script>
</head>
<body>
<div id="testlog"></div>
<div id="dummy_div">foo</div>
<input type="text" name="dummy_input" value="dummy value" id="dummy_input" />
<input type="checkbox" name="dummy_checkbox" value="" checked="checked" id="dummy_checkbox" />
<div id="wrap_dummy">foo bar baz</div>
<div id="contains_dummy">blah // foo \ some other text &copy;</div>
<div id="replace_html_dummy">some content...</div>
<script type="text/javascript">
new Test.Unit.Runner({
testElementMethodsSetProperty: function() {
$('dummy_input').setProperty('disabled', true);
this.assert($('dummy_input').disabled); // should be disabled after setting
$('dummy_div').setProperty('foo', 'bar');
this.assertIdentical('bar', $('dummy_div').foo); // property should be set
$('dummy_checkbox').setProperty('checked', false);
this.assert(!$('dummy_checkbox').checked); // should NOT be checked
$$('input').invoke('setProperty', 'className', 'foo');
$$('input').each(function(el) {
this.assertIdentical('foo', el.className);
}, this);
},
testElementMethodsWrapContent: function() {
$('wrap_dummy').wrapContent('pre', { className: 'code', id: 53 });
this.assert($('wrap_dummy').down('pre'));
this.assertIdentical('code', $('wrap_dummy').down('pre').className);
this.assertIdentical('53', $('wrap_dummy').down('pre').id);
},
testElementMethodsContains: function() {
this.assert($('contains_dummy').contains('blah'));
this.assert(!$('contains_dummy').contains('fooo'));
this.assert($('contains_dummy').contains(/bla.\s/));
},
testElementMethodsReplaceHTML: function() {
$('replace_html_dummy').replaceHTML(/some/, '_some_');
this.assertIdentical('_some_ content...', $('replace_html_dummy').innerHTML);
$('replace_html_dummy').replaceHTML(/(\S)/g, '$1 ');
this.assertIdentical('_ s o m e _ c o n t e n t . . . ', $('replace_html_dummy').innerHTML);
},
testElementMethodsReplaceAttribute: function() {
$('dummy_input').replaceAttribute('name', /_/g, '-');
this.assertIdentical('dummy-input', $('dummy_input').readAttribute('name'));
}
})
</script>
</body>
</html>
Something went wrong with that request. Please try again.