Skip to content

Instantly share code, notes, and snippets.

@dmitryshimkin
Last active December 24, 2015 11:19
Show Gist options
  • Select an option

  • Save dmitryshimkin/6790098 to your computer and use it in GitHub Desktop.

Select an option

Save dmitryshimkin/6790098 to your computer and use it in GitHub Desktop.
this.addMatchers({
toBeAbout: function (expected, precision) {
if (typeof this.actual !== 'number' || typeof expected !== 'number') {
return false;
}
var delta = Math.abs(expected - this.actual);
precision = precision || 20;
return delta <= precision;
},
toBeNumber: function () {
return Object.prototype.toString.call(this.actual) === '[object Number]';
},
toBeHidden: function () {
return this.actual.classList.contains('hidden');
},
toBeVisible: function () {
return !this.actual.classList.contains('hidden');
},
toBeChecked: function () {
var elem = CLND.dom.closest(this.actual, '[data-role="checkbox"]');
return this.actual.checked && elem.classList.contains('checkbox_checked');
},
toBeUnchecked: function () {
var elem = CLND.dom.closest(this.actual, '[data-role="checkbox"]');
return !this.actual.checked && !elem.classList.contains('checkbox_checked');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment