Skip to content

Commit

Permalink
Merge pull request #50 from PolymerElements/fix-jsdocs
Browse files Browse the repository at this point in the history
fix jsdocs. Create global.TestHelpers in test-helpers
  • Loading branch information
valdrinkoshi committed Mar 30, 2016
2 parents e9febb6 + 7f55c74 commit 59cc0ea
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 74 deletions.
12 changes: 0 additions & 12 deletions iron-test-helpers.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,3 @@
-->
<link rel="import" href="mock-interactions.html">
<link rel="import" href="test-helpers.html">
<script>
(function(global) {
'use strict';

var TestHelpers = global.TestHelpers = global.TestHelpers || {};

TestHelpers.flushAsynchronousOperations = flushAsynchronousOperations;
TestHelpers.forceXIfStamp = forceXIfStamp;
TestHelpers.fireEvent = fireEvent;
TestHelpers.skipUnless = skipUnless;
})(this);
</script>
112 changes: 56 additions & 56 deletions mock-interactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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;
Expand All @@ -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,
Expand All @@ -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 = {
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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);
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -250,22 +250,22 @@

/**
* 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) {
xy = xy || middleOfNode(node);
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.
Expand All @@ -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.
Expand All @@ -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', {}, {
Expand All @@ -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', {}, {
Expand All @@ -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<string>)=} modifiers The key modifiers for the event.
* Accepted values are shift, ctrl, alt, meta.
*/
function keyboardEventFor(type, keyCode, modifiers) {
Expand All @@ -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<string>)=} 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<string>)=} 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<string>)=} 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<string>)=} modifiers The key modifiers for the event.
* Accepted values are shift, ctrl, alt, meta.
*/
function pressAndReleaseKeyOn(target, keyCode, modifiers) {
Expand All @@ -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);
Expand Down
Loading

0 comments on commit 59cc0ea

Please sign in to comment.