Skip to content

Instantly share code, notes, and snippets.

beforeEach(function() {
jasmine.addMatchers(getCustomMatcher());
});
function getCustomMatcher() {
function createCustomMatcher(arg, util, customEqualityTesters) {
return sinon.match(function (val) {
return util.equals(val, arg, customEqualityTesters);
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;
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;
}