Created
April 7, 2011 15:38
-
-
Save kaievns/908025 to your computer and use it in GitHub Desktop.
Jasmine Hack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// hacking jasmine over | |
var jasmine = require('jasmine-node'); | |
var original_it = it; | |
var original_expect = expect; | |
var original_describe = describe; | |
global.it = function(desc, callback) { | |
if (typeof(desc) !== 'string') { | |
for (var key in desc) { | |
original_it(key, desc[key]); | |
} | |
} else { | |
original_it(desc, callback) | |
} | |
}; | |
global.describe = function(name, callback) { | |
if (typeof(callback) !== 'function') { | |
original_describe(name, function() { | |
it(callback); | |
}); | |
} else { | |
original_describe(name, callback); | |
} | |
} | |
global.assert = function(value) { | |
return { | |
equal: function(expected) { | |
expect(value).toEqual(expected); | |
return this; | |
}, | |
same: function(expected) { | |
expect(value).toBe(expected); | |
return this; | |
} | |
} | |
}; | |
/** | |
* The utility function specs | |
* | |
* Copyright (C) 2011 Nikolay Nemshilov | |
*/ | |
describe("Core Utils", function() { | |
var ext = LeftJS.ext; | |
describe("ext(a,b)", { | |
'should extend one object with another': function() { | |
var a = {a: 1}, b = {b: 2}, c = ext(a, b); | |
assert(c) | |
.equal({a:1, b:2}) | |
.same(a); | |
}, | |
"should accept 'null' as the second argument": function() { | |
assert(ext({a: 1}, null)).equal({a: 1}); | |
}, | |
"should accept 'undefined' as the second argument": function() { | |
assert(ext({a: 1}, undefined)).equal({a: 1}); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Who do this work