Created
December 5, 2010 18:56
-
-
Save jorgemanrubia/729345 to your computer and use it in GitHub Desktop.
Jasmine matcher that checks the class of an object and some expected set of properties
This file contains 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
toBeObjectWithProperties: function(expectedClass, expectedProperties) { | |
var isObjectWithProperties = (this.actual instanceof expectedClass); | |
for(var propertyName in expectedProperties){ | |
var expectedPropertyValue = expectedProperties[propertyName]; | |
isObjectWithProperties = isObjectWithProperties && (this.actual[propertyName] == expectedPropertyValue); | |
} | |
return isObjectWithProperties; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment