Skip to content

Instantly share code, notes, and snippets.

@kaievns
Created April 7, 2011 15:38
Show Gist options
  • Save kaievns/908025 to your computer and use it in GitHub Desktop.
Save kaievns/908025 to your computer and use it in GitHub Desktop.
Jasmine Hack
// 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});
}
});
});
@arundevarajan
Copy link

Who do this work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment