Created
March 6, 2014 18:36
-
-
Save danielpsf/9396450 to your computer and use it in GitHub Desktop.
This is my jasmine spec helper
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
'use strict'; | |
beforeEach(function() { | |
this.addMatchers({ | |
toEqualData: function(expected) { | |
this.message = function () { | |
var notText = this.isNot ? " not" : ""; | |
return "Expected " + JSON.stringify(this.actual) + notText + " to be equals that " + JSON.stringify(expected); | |
} | |
return JSON.stringify(this.actual) === JSON.stringify(expected); | |
}, | |
toHaveThisPattern : function(expected) { | |
this.message = function() { | |
var notText = this.isNot ? " not" : ""; | |
return "Expected " + this.actual + notText + " to have this pattern " + expected; | |
} | |
return this.actual.test(expected); | |
}, | |
toHaveBeenCalledToManyCalls : function(expected) { | |
this.message = function() { | |
var notText = this.isNot ? "not" : ""; | |
return "Expected " + this.actual.callCount + notText + " but got " + expected; | |
} | |
return this.actual.callCount === expected; | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment