Last active
August 29, 2015 14:11
-
-
Save softcraft-development/1c3964402b099893bd61 to your computer and use it in GitHub Desktop.
Testing _.extend() for underscore/lodash
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
describe "Underscore Extend", -> | |
describe "simple objects", -> | |
it "bequeaths properties", -> | |
obj = | |
prop: "value" | |
expect(_.extend({}, obj).prop).toEqual("value") | |
it "bequeaths methods", -> | |
obj = | |
meth: () -> | |
"value" | |
expect(_.extend({}, obj).meth()).toEqual("value") | |
describe "defined classes", -> | |
class Ancestor | |
prop: "prop value" | |
constructor: () -> | |
@var = "var value" | |
meth: () -> | |
"meth value" | |
it "bequeaths properties", -> | |
# Fails in non-underscore lodash | |
expect(_.extend({}, new Ancestor()).prop).toEqual("prop value") | |
it "bequeaths variables", -> | |
expect(_.extend({}, new Ancestor()).var).toEqual("var value") | |
it "bequeaths instances", -> | |
# Fails in non-underscore lodash | |
expect(_.extend({}, new Ancestor()).meth?()).toEqual("meth value") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment