View add JQuery scope matcher to jasmine
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
beforeEach(function() { | |
jasmine.addMatchers(getCustomMatcher()); | |
}); | |
function getCustomMatcher() { | |
function createCustomMatcher(arg, util, customEqualityTesters) { | |
return sinon.match(function (val) { | |
return util.equals(val, arg, customEqualityTesters); |
View getBoundingClientRect.js
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
function getStyle(elem, prop) { | |
return window.getComputedStyle(elem).getPropertyValue(prop); | |
} | |
function bodyOffset( body ) { | |
let top = body.offsetTop, | |
left = body.offsetLeft; | |
let doesNotIncludeMarginInBodyOffset; // TODO | |
if (doesNotIncludeMarginInBodyOffset ) { | |
top += parseFloat( getStyle(body, 'marginTop') ) || 0; |
View gist:5ac65564cee81c209ad9b5ca24bbb0d0
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
var MAX_DEPTH_OF_CHECK = 6; | |
function objectsAreEqual(first, second, depthOfCheck) { | |
var isFirstObject = isObject(first); | |
var isSecondObject = isObject(second); | |
if (!isFirstObject && !isSecondObject) { // both are not objects, compare primitives | |
return first === second; | |
} else if (!isFirstObject || !isSecondObject) { // one of them is not object | |
return false; | |
} |