Last active
December 24, 2015 11:19
-
-
Save dmitryshimkin/6790098 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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