Export clickIt utility from test-helpers package

This commit is contained in:
Avital Oliver
2015-06-08 11:19:22 -07:00
parent 0c25d5395c
commit 4b3c5b930a
4 changed files with 23 additions and 31 deletions

View File

@@ -15,15 +15,6 @@ var nodesToArray = function (array) {
return _.map(array, _.identity);
};
var clickIt = function (elem) {
// jQuery's bubbling change event polyfill for IE 8 seems
// to require that the element in question have focus when
// it receives a simulated click.
if (elem.focus)
elem.focus();
clickElement(elem);
};
Tinytest.add("spacebars-tests - old - template_tests - simple helper", function (test) {
var tmpl = Template.old_spacebars_template_test_simple_helper;
var R = ReactiveVar(1);

View File

@@ -10,27 +10,6 @@ var nodesToArray = function (array) {
return _.map(array, _.identity);
};
var inDocument = function (elem) {
while ((elem = elem.parentNode)) {
if (elem == document) {
return true;
}
}
return false;
};
var clickIt = function (elem) {
if (!inDocument(elem))
throw new Error("Can't click on elements without first adding them to the document");
// jQuery's bubbling change event polyfill for IE 8 seems
// to require that the element in question have focus when
// it receives a simulated click.
if (elem.focus)
elem.focus();
clickElement(elem);
};
// maybe use created callback on the template instead of this?
var extendTemplateWithInit = function (template, initFunc) {
var tmpl = new Template(template.viewName+'-extended', template.renderFunction);

View File

@@ -42,3 +42,25 @@ clickElement = function(elem) {
else
simulateEvent(elem, 'click');
};
var inDocument = function (elem) {
while ((elem = elem.parentNode)) {
if (elem == document) {
return true;
}
}
return false;
};
clickIt = function (elem) {
if (!inDocument(elem))
throw new Error("Can't click on elements without first adding them to the document");
// jQuery's bubbling change event polyfill for IE 8 seems
// to require that the element in question have focus when
// it receives a simulated click.
if (elem.focus)
elem.focus();
clickElement(elem);
};

View File

@@ -20,7 +20,7 @@ Package.onUse(function (api) {
'pollUntil', 'try_all_permutations',
'SeededRandom', 'clickElement', 'blurElement',
'focusElement', 'simulateEvent', 'getStyleProperty', 'canonicalizeHtml',
'renderToDiv',
'renderToDiv', 'clickIt',
'withCallbackLogger', 'testAsyncMulti', 'simplePoll',
'makeTestConnection', 'DomUtils']);