      1 jasmine.Matchers.prototype.toBeAWidgetOfType = function(expectedType) {
      2   if (!this.actual || !pockets.getWidgetController(this.actual)) {
      3     return this.report(false, 'Expected ' + this.actual + ' to be a Mojo ' + expectedType + ' widget, but it wasn\'t');
      4   }
      5   var actualType = this.actual.getAttribute('x-mojo-element');
      6   return this.report((actualType == expectedType),
      7       'Expected ' + this.actual + ' to be a Mojo ' + expectedType + ' widget but was Mojo ' + actualType);
      8 };
      9 /** @deprecated */
     10 jasmine.Matchers.prototype.shouldBeAWidgetOfType = jasmine.Matchers.prototype.toBeAWidgetOfType;
     11
     12 jasmine.Matchers.prototype.toBeVisible = function() {
     13   if (!Object.isElement(this.actual)) {
     14     return this.report(false, "Expected DOM element but got " + this.actual);
     15   }
     16
     17   var actualIsVisible = Element.visible(this.actual) &&
     18                 Element.ancestors(this.actual).all(function(element) {return Element.visible(element);});
     19
     20   return this.report(actualIsVisible,
     21     "Expected element " + pockets.dom.htmlEscape(pockets.ui.htmlForElement(this.actual)) +
     22     " to have been visible, but it was not.");
     23 };
     24
     25 jasmine.Matchers.prototype.toNotBeVisible = function() {
     26   if (!Object.isElement(this.actual)) {
     27     return this.report(false, "Expected DOM element but got " + this.actual);
     28   }
     29   var actualIsVisible = Element.visible(this.actual) &&
     30                 Element.ancestors(this.actual).all(function(element) {return Element.visible(element);});
     31
     32   return this.report(!actualIsVisible,
     33     "Expected element id " + pockets.dom.htmlEscape(pockets.ui.htmlForElement(this.actual)) +
     34     " to have been invisible, but it was in fact visible.");
     35 };
     36
     37 jasmine.Matchers.prototype.toHaveButtonLabel = function(expectedButtonText) {
     38   if (!Object.isElement(this.actual)) {
     39     return this.report(false, "Expected DOM element but got " + this.actual);
     40   }
     41   if (this.actual.getAttribute("x-mojo-element") != "Button") {
     42     return this.report(false, "Expected a button, but it wasn't");
     43   }
     44   if (!this.actual.querySelector(".palm-button-wrapper")) {
     45     return this.report(false, "Expected a fully activated button, but it wasn't set up");
     46   }
     47   var actualButtonText = this.actual.querySelector(".palm-button-wrapper .truncating-text").innerHTML;
     48   return this.report(actualButtonText.strip() == expectedButtonText.strip(),
     49     "Expected button " + pockets.dom.htmlEscape(pockets.ui.htmlForElement(this.actual)) +
     50     " to have label " + expectedButtonText + ", but its label was " + actualButtonText);
     51 }
     52