From 4b3c5b930aa4e00481d908656aaec263f4dc6338 Mon Sep 17 00:00:00 2001 From: Avital Oliver Date: Mon, 8 Jun 2015 11:19:22 -0700 Subject: [PATCH] Export `clickIt` utility from test-helpers package --- .../spacebars-tests/old_templates_tests.js | 9 -------- packages/spacebars-tests/template_tests.js | 21 ------------------ packages/test-helpers/event_simulation.js | 22 +++++++++++++++++++ packages/test-helpers/package.js | 2 +- 4 files changed, 23 insertions(+), 31 deletions(-) diff --git a/packages/spacebars-tests/old_templates_tests.js b/packages/spacebars-tests/old_templates_tests.js index 72044edb66..e034a8c5dc 100644 --- a/packages/spacebars-tests/old_templates_tests.js +++ b/packages/spacebars-tests/old_templates_tests.js @@ -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); diff --git a/packages/spacebars-tests/template_tests.js b/packages/spacebars-tests/template_tests.js index 4921866601..d3c45830c9 100644 --- a/packages/spacebars-tests/template_tests.js +++ b/packages/spacebars-tests/template_tests.js @@ -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); diff --git a/packages/test-helpers/event_simulation.js b/packages/test-helpers/event_simulation.js index 72b1133ae6..672fd03771 100644 --- a/packages/test-helpers/event_simulation.js +++ b/packages/test-helpers/event_simulation.js @@ -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); +}; + diff --git a/packages/test-helpers/package.js b/packages/test-helpers/package.js index 01bf5c59e8..b4e735c508 100644 --- a/packages/test-helpers/package.js +++ b/packages/test-helpers/package.js @@ -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']);