Changeset 4889
- Timestamp:
- 09/01/06 01:12:30 (4 years ago)
- Files:
-
- spinoffs/scriptaculous/CHANGELOG (modified) (1 diff)
- spinoffs/scriptaculous/src/unittest.js (modified) (2 diffs)
- spinoffs/scriptaculous/test/unit/bdd_test.html (modified) (1 diff)
- spinoffs/scriptaculous/test/unit/element_test.html (modified) (1 diff)
- spinoffs/scriptaculous/test/unit/unittest_test.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
spinoffs/scriptaculous/CHANGELOG
r4863 r4889 1 1 *SVN* 2 3 * Add assertRespondsTo and shouldRespondTo assertions 2 4 3 5 * Add experimental alternate syntax for unit tests (Behaviour Driven Development-style) spinoffs/scriptaculous/src/unittest.js
r4867 r4889 368 368 catch(e) { this.error(e); } 369 369 }, 370 assertRespondsTo: function(method, obj) { 371 var message = arguments[2] || 'assertRespondsTo'; 372 try { 373 (obj[method] && typeof obj[method] == 'function') ? this.pass() : 374 this.fail(message + ": object doesn't respond to [" + method + "]"); } 375 catch(e) { this.error(e); } 376 }, 370 377 assertReturnsTrue: function(method, obj) { 371 378 var message = arguments[2] || 'assertReturnsTrue'; … … 478 485 479 486 shouldBe: 'assertReturnsTrue', 480 shouldNotBe: 'assertReturnsFalse' 487 shouldNotBe: 'assertReturnsFalse', 488 shouldRespondTo: 'assertRespondsTo' 481 489 }; 482 490 Test.BDDMethods = {}; spinoffs/scriptaculous/test/unit/bdd_test.html
r4867 r4889 57 57 }, 58 58 59 'should provide extensions to tie in isSomething object methods': function(){59 'should provide extensions to tie in isSomething and respondsTo object methods': function(){ 60 60 Object.extend(testObj, Test.BDDMethods); 61 61 62 62 testObj.shouldBe('nice'); 63 63 testObj.shouldNotBe('broken'); 64 65 testObj.shouldRespondTo('isNice'); 66 testObj.shouldRespondTo('isBroken'); 64 67 }, 65 68 spinoffs/scriptaculous/test/unit/element_test.html
r4785 r4889 199 199 benchmark(function(){ 200 200 Element.childrenWithClassName("Container", "firstClass") 201 },1 ,'Element.childrenWithClassName');201 },1000,'Element.childrenWithClassName'); 202 202 203 203 // ... and that none that don't exist have been found. spinoffs/scriptaculous/test/unit/unittest_test.html
r4867 r4889 72 72 assertNotEqual([],[]); 73 73 assertNotEqual([],{}); 74 }}, 75 76 testAssertRespondsTo: function() { with(this) { 77 assertRespondsTo('isNice', testObj); 78 assertRespondsTo('isBroken', testObj); 74 79 }}, 75 80