diff --git a/iron-test-helpers.html b/iron-test-helpers.html
index 225680b..b5678b9 100644
--- a/iron-test-helpers.html
+++ b/iron-test-helpers.html
@@ -9,15 +9,3 @@
-->
-
diff --git a/mock-interactions.js b/mock-interactions.js
index 1c880cf..60ab3f1 100644
--- a/mock-interactions.js
+++ b/mock-interactions.js
@@ -27,10 +27,10 @@
return has;
})();
- /*
+ /**
* Returns the (x,y) coordinates representing the middle of a node.
*
- * @param {HTMLElement} node An element.
+ * @param {!HTMLElement} node An element.
*/
function middleOfNode(node) {
var bcr = node.getBoundingClientRect();
@@ -40,10 +40,10 @@
};
}
- /*
+ /**
* Returns the (x,y) coordinates representing the top left corner of a node.
*
- * @param {HTMLElement} node An element.
+ * @param {!HTMLElement} node An element.
*/
function topLeftOfNode(node) {
var bcr = node.getBoundingClientRect();
@@ -58,8 +58,8 @@
* and a target node. The Touch instances will each have a unique Touch
* identifier.
*
- * @param {Array} xyList A list of (x,y) coordinate objects.
- * @param {HTMLElement} node A target element node.
+ * @param {!Array<{ x: number, y: number }>} xyList A list of (x,y) coordinate objects.
+ * @param {!HTMLElement} node A target element node.
*/
function makeTouches(xyList, node) {
var id = 0;
@@ -83,11 +83,11 @@
* @param {string} type The type of TouchEvent to generate.
* @param {{ x: number, y: number }} xy An (x,y) coordinate for the generated
* TouchEvent.
- * @param {HTMLElement} node The target element node for the generated
+ * @param {!HTMLElement} node The target element node for the generated
* TouchEvent to be dispatched on.
*/
function makeSoloTouchEvent(type, xy, node) {
- var xy = xy || middleOfNode(node);
+ xy = xy || middleOfNode(node);
var touches = makeTouches([xy], node);
var touchEventInit = {
touches: touches,
@@ -108,13 +108,13 @@
node.dispatchEvent(event);
}
- /*
+ /**
* Fires a mouse event on a specific node, at a given set of coordinates.
* This event bubbles and is cancellable.
*
* @param {string} type The type of mouse event (such as 'tap' or 'down').
- * @param {Object} xy The (x,y) coordinates the mouse event should be fired from.
- * @param {HTMLElement} node The node to fire the event on.
+ * @param {{ x: number, y: number }} xy The (x,y) coordinates the mouse event should be fired from.
+ * @param {!HTMLElement} node The node to fire the event on.
*/
function makeMouseEvent(type, xy, node) {
var props = {
@@ -147,14 +147,14 @@
node.dispatchEvent(e);
}
- /*
+ /**
* Simulates a mouse move action by firing a `move` mouse event on a
* specific node, between a set of coordinates.
*
- * @param {HTMLElement} node The node to fire the event on.
+ * @param {!HTMLElement} node The node to fire the event on.
* @param {Object} fromXY The (x,y) coordinates the dragging should start from.
* @param {Object} toXY The (x,y) coordinates the dragging should end at.
- * @param {?Object} steps Optional. The numbers of steps in the move motion.
+ * @param {?number} steps Optional. The numbers of steps in the move motion.
* If not specified, the default is 5.
*/
function move(node, fromXY, toXY, steps) {
@@ -176,13 +176,13 @@
}, node);
}
- /*
+ /**
* Simulates a mouse dragging action originating in the middle of a specific node.
*
- * @param {HTMLElement} target The node to fire the event on.
+ * @param {!HTMLElement} target The node to fire the event on.
* @param {?number} dx The horizontal displacement.
* @param {?number} dy The vertical displacement
- * @param {?Object} steps Optional. The numbers of steps in the dragging motion.
+ * @param {?number} steps Optional. The numbers of steps in the dragging motion.
* If not specified, the default is 5.
*/
function track(target, dx, dy, steps) {
@@ -199,26 +199,26 @@
up(target, xy2);
}
- /*
+ /**
* Fires a `down` mouse event on a specific node, at a given set of coordinates.
* This event bubbles and is cancellable. If the (x,y) coordinates are
* not specified, the middle of the node will be used instead.
*
- * @param {HTMLElement} node The node to fire the event on.
- * @param {?Object} xy Optional. The (x,y) coordinates the mouse event should be fired from.
+ * @param {!HTMLElement} node The node to fire the event on.
+ * @param {{ x: number, y: number }=} xy Optional. The (x,y) coordinates the mouse event should be fired from.
*/
function down(node, xy) {
xy = xy || middleOfNode(node);
makeMouseEvent('mousedown', xy, node);
}
- /*
+ /**
* Fires an `up` mouse event on a specific node, at a given set of coordinates.
* This event bubbles and is cancellable. If the (x,y) coordinates are
* not specified, the middle of the node will be used instead.
*
- * @param {HTMLElement} node The node to fire the event on.
- * @param {?Object} xy Optional. The (x,y) coordinates the mouse event should be fired from.
+ * @param {!HTMLElement} node The node to fire the event on.
+ * @param {{ x: number, y: number }=} xy Optional. The (x,y) coordinates the mouse event should be fired from.
*/
function up(node, xy) {
xy = xy || middleOfNode(node);
@@ -227,8 +227,8 @@
/**
* Generate a click event on a given node, optionally at a given coordinate.
- * @param {HTMLElement} node The node to fire the click event on.
- * @param {?Object} xy Optional. The (x,y) coordinates the mouse event should
+ * @param {!HTMLElement} node The node to fire the click event on.
+ * @param {{ x: number, y: number }=} xy Optional. The (x,y) coordinates the mouse event should
* be fired from.
*/
function click(node, xy) {
@@ -238,8 +238,8 @@
/**
* Generate a touchstart event on a given node, optionally at a given coordinate.
- * @param {HTMLElement} node The node to fire the click event on.
- * @param {?Object} xy Optional. The (x,y) coordinates the touch event should
+ * @param {!HTMLElement} node The node to fire the click event on.
+ * @param {{ x: number, y: number }=} xy Optional. The (x,y) coordinates the touch event should
* be fired from.
*/
function touchstart(node, xy) {
@@ -250,8 +250,8 @@
/**
* Generate a touchend event on a given node, optionally at a given coordinate.
- * @param {HTMLElement} node The node to fire the click event on.
- * @param {?Object} xy Optional. The (x,y) coordinates the touch event should
+ * @param {!HTMLElement} node The node to fire the click event on.
+ * @param {{ x: number, y: number }=} xy Optional. The (x,y) coordinates the touch event should
* be fired from.
*/
function touchend(node, xy) {
@@ -259,13 +259,13 @@
makeSoloTouchEvent('touchend', xy, node);
}
- /*
+ /**
* Simulates a complete mouse click by firing a `down` mouse event, followed
* by an asynchronous `up` and `tap` events on a specific node. Calls the
*`callback` after the `tap` event is fired.
*
- * @param {HTMLElement} target The node to fire the event on.
- * @param {?Object} callback Optional. The function to be called after the action ends.
+ * @param {!HTMLElement} target The node to fire the event on.
+ * @param {?Function} callback Optional. The function to be called after the action ends.
* @param {?{
* emulateTouch: boolean
* }} options Optional. Configure the emulation fidelity of the mouse events.
@@ -284,11 +284,11 @@
});
}
- /*
+ /**
* Fires a 'tap' mouse event on a specific node. This respects the pointer-events
* set on the node, and will not fire on disabled nodes.
*
- * @param {HTMLElement} node The node to fire the event on.
+ * @param {!HTMLElement} node The node to fire the event on.
* @param {?{
* emulateTouch: boolean
* }} options Optional. Configure the emulation fidelity of the mouse event.
@@ -310,10 +310,10 @@
click(node, xy);
}
- /*
+ /**
* Focuses a node by firing a `focus` event. This event does not bubble.
*
- * @param {HTMLElement} target The node to fire the event on.
+ * @param {!HTMLElement} target The node to fire the event on.
*/
function focus(target) {
Polymer.Base.fire('focus', {}, {
@@ -322,10 +322,10 @@
});
}
- /*
+ /**
* Blurs a node by firing a `blur` event. This event does not bubble.
*
- * @param {HTMLElement} target The node to fire the event on.
+ * @param {!HTMLElement} target The node to fire the event on.
*/
function blur(target) {
Polymer.Base.fire('blur', {}, {
@@ -334,12 +334,12 @@
});
}
- /*
+ /**
* Returns a keyboard event. This event bubbles and is cancellable.
*
* @param {string} type The type of keyboard event (such as 'keyup' or 'keydown').
* @param {number} keyCode The keyCode for the event.
- * @param {?string|[string]} modifiers The key modifiers for the event.
+ * @param {(string|Array)=} modifiers The key modifiers for the event.
* Accepted values are shift, ctrl, alt, meta.
*/
function keyboardEventFor(type, keyCode, modifiers) {
@@ -363,50 +363,50 @@
return event;
}
- /*
+ /**
* Fires a keyboard event on a specific node. This event bubbles and is cancellable.
*
- * @param {HTMLElement} target The node to fire the event on.
+ * @param {!HTMLElement} target The node to fire the event on.
* @param {string} type The type of keyboard event (such as 'keyup' or 'keydown').
* @param {number} keyCode The keyCode for the event.
- * @param {?string|[string]} modifiers The key modifiers for the event.
+ * @param {(string|Array)=} modifiers The key modifiers for the event.
* Accepted values are shift, ctrl, alt, meta.
*/
function keyEventOn(target, type, keyCode, modifiers) {
target.dispatchEvent(keyboardEventFor(type, keyCode, modifiers));
}
- /*
+ /**
* Fires a 'keydown' event on a specific node. This event bubbles and is cancellable.
*
- * @param {HTMLElement} target The node to fire the event on.
+ * @param {!HTMLElement} target The node to fire the event on.
* @param {number} keyCode The keyCode for the event.
- * @param {?string|[string]} modifiers The key modifiers for the event.
+ * @param {(string|Array)=} modifiers The key modifiers for the event.
* Accepted values are shift, ctrl, alt, meta.
*/
function keyDownOn(target, keyCode, modifiers) {
keyEventOn(target, 'keydown', keyCode, modifiers);
}
- /*
+ /**
* Fires a 'keyup' event on a specific node. This event bubbles and is cancellable.
*
- * @param {HTMLElement} target The node to fire the event on.
+ * @param {!HTMLElement} target The node to fire the event on.
* @param {number} keyCode The keyCode for the event.
- * @param {?string|[string]} modifiers The key modifiers for the event.
+ * @param {(string|Array)=} modifiers The key modifiers for the event.
* Accepted values are shift, ctrl, alt, meta.
*/
function keyUpOn(target, keyCode, modifiers) {
keyEventOn(target, 'keyup', keyCode, modifiers);
}
- /*
+ /**
* Simulates a complete key press by firing a `keydown` keyboard event, followed
* by an asynchronous `keyup` event on a specific node.
*
- * @param {HTMLElement} target The node to fire the event on.
+ * @param {!HTMLElement} target The node to fire the event on.
* @param {number} keyCode The keyCode for the event.
- * @param {?string|[string]} modifiers The key modifiers for the event.
+ * @param {(string|Array)=} modifiers The key modifiers for the event.
* Accepted values are shift, ctrl, alt, meta.
*/
function pressAndReleaseKeyOn(target, keyCode, modifiers) {
@@ -416,21 +416,21 @@
}, 1);
}
- /*
+ /**
* Simulates a complete 'enter' key press by firing a `keydown` keyboard event,
* followed by an asynchronous `keyup` event on a specific node.
*
- * @param {HTMLElement} target The node to fire the event on.
+ * @param {!HTMLElement} target The node to fire the event on.
*/
function pressEnter(target) {
pressAndReleaseKeyOn(target, 13);
}
- /*
+ /**
* Simulates a complete 'space' key press by firing a `keydown` keyboard event,
* followed by an asynchronous `keyup` event on a specific node.
*
- * @param {HTMLElement} target The node to fire the event on.
+ * @param {!HTMLElement} target The node to fire the event on.
*/
function pressSpace(target) {
pressAndReleaseKeyOn(target, 32);
diff --git a/test-helpers.js b/test-helpers.js
index b48bbb9..7507b18 100644
--- a/test-helpers.js
+++ b/test-helpers.js
@@ -10,7 +10,8 @@
(function(global) {
'use strict';
- /*
+
+ /**
* Forces distribution of light children, and lifecycle callbacks on the
* Custom Elements polyfill. Used when testing elements that rely on their
* distributed children.
@@ -22,7 +23,7 @@
window.CustomElements && window.CustomElements.takeRecords();
};
- /*
+ /**
* Stamps and renders a `dom-if` template.
*
* @param {HTMLElement} node The node containing the template,
@@ -36,10 +37,10 @@
global.flushAsynchronousOperations();
};
- /*
+ /**
* Fires a custom event on a specific node. This event bubbles and is cancellable.
*
- * @param {String} type The type of event.
+ * @param {string} type The type of event.
* @param {Object} props Any custom properties the event contains.
* @param {HTMLElement} node The node to fire the event on.
*/
@@ -54,7 +55,7 @@
node.dispatchEvent(event);
};
- /*
+ /**
* Skips a test unless a condition is met. Sample use:
* function isNotIE() {
* return !navigator.userAgent.match(/MSIE/i);
@@ -63,7 +64,7 @@
* ...
* });
*
- * @param {String} condition The name of a Boolean function determining if the test should be run.
+ * @param {Function} condition The name of a Boolean function determining if the test should be run.
* @param {Function} test The test to be run.
*/
@@ -86,4 +87,11 @@
return result;
};
};
+
+ global.TestHelpers = {
+ flushAsynchronousOperations: global.flushAsynchronousOperations,
+ forceXIfStamp: global.forceXIfStamp,
+ fireEvent: global.fireEvent,
+ skipUnless: global.skipUnless
+ };
})(this);