dist/ember-testing.js in ember-source-2.7.0.beta.3 vs dist/ember-testing.js in ember-source-2.7.0.beta.4

- old
+ new

@@ -4,11 +4,11 @@ * @copyright Copyright 2011-2016 Tilde Inc. and contributors * Portions Copyright 2006-2011 Strobe Inc. * Portions Copyright 2008-2011 Apple Inc. All rights reserved. * @license Licensed under MIT license * See https://raw.github.com/emberjs/ember.js/master/LICENSE - * @version 2.7.0-beta.3 + * @version 2.7.0-beta.4 */ var enifed, requireModule, require, Ember; var mainContext = this; @@ -1051,257 +1051,10 @@ } }); exports.default = _emberRuntimeExtRsvp.default; }); -enifed("ember-testing/helpers/and_then", ["exports"], function (exports) { - "use strict"; - - exports.default = andThen; - - function andThen(app, callback) { - return app.testHelpers.wait(callback(app)); - } -}); -enifed('ember-testing/helpers/click', ['exports', 'ember-metal/run_loop', 'ember-testing/events'], function (exports, _emberMetalRun_loop, _emberTestingEvents) { - 'use strict'; - - exports.default = click; - - function click(app, selector, context) { - var $el = app.testHelpers.findWithAssert(selector, context); - var el = $el[0]; - - _emberMetalRun_loop.default(null, _emberTestingEvents.fireEvent, el, 'mousedown'); - - _emberTestingEvents.focus(el); - - _emberMetalRun_loop.default(null, _emberTestingEvents.fireEvent, el, 'mouseup'); - _emberMetalRun_loop.default(null, _emberTestingEvents.fireEvent, el, 'click'); - - return app.testHelpers.wait(); - } -}); -enifed('ember-testing/helpers/current_path', ['exports', 'ember-metal/property_get'], function (exports, _emberMetalProperty_get) { - 'use strict'; - - exports.default = currentPath; - - function currentPath(app) { - var routingService = app.__container__.lookup('service:-routing'); - return _emberMetalProperty_get.get(routingService, 'currentPath'); - } -}); -enifed('ember-testing/helpers/current_route_name', ['exports', 'ember-metal/property_get'], function (exports, _emberMetalProperty_get) { - 'use strict'; - - exports.default = currentRouteName; - - function currentRouteName(app) { - var routingService = app.__container__.lookup('service:-routing'); - return _emberMetalProperty_get.get(routingService, 'currentRouteName'); - } -}); -enifed('ember-testing/helpers/current_url', ['exports', 'ember-metal/property_get'], function (exports, _emberMetalProperty_get) { - 'use strict'; - - exports.default = currentURL; - - function currentURL(app) { - var router = app.__container__.lookup('router:main'); - return _emberMetalProperty_get.get(router, 'location').getURL(); - } -}); -enifed('ember-testing/helpers/fill_in', ['exports', 'ember-metal/run_loop', 'ember-testing/events'], function (exports, _emberMetalRun_loop, _emberTestingEvents) { - 'use strict'; - - exports.default = fillIn; - - function fillIn(app, selector, contextOrText, text) { - var $el, el, context; - if (typeof text === 'undefined') { - text = contextOrText; - } else { - context = contextOrText; - } - $el = app.testHelpers.findWithAssert(selector, context); - el = $el[0]; - _emberTestingEvents.focus(el); - _emberMetalRun_loop.default(function () { - $el.val(text); - _emberTestingEvents.fireEvent(el, 'input'); - _emberTestingEvents.fireEvent(el, 'change'); - }); - return app.testHelpers.wait(); - } -}); -enifed('ember-testing/helpers/find', ['exports', 'ember-metal/property_get'], function (exports, _emberMetalProperty_get) { - 'use strict'; - - exports.default = find; - - function find(app, selector, context) { - var $el = undefined; - context = context || _emberMetalProperty_get.get(app, 'rootElement'); - $el = app.$(selector, context); - return $el; - } -}); -enifed('ember-testing/helpers/find_with_assert', ['exports'], function (exports) { - 'use strict'; - - exports.default = findWithAssert; - - function findWithAssert(app, selector, context) { - var $el = app.testHelpers.find(selector, context); - if ($el.length === 0) { - throw new Error('Element ' + selector + ' not found.'); - } - return $el; - } -}); -enifed('ember-testing/helpers/key_event', ['exports'], function (exports) { - 'use strict'; - - exports.default = keyEvent; - - function keyEvent(app, selector, contextOrType, typeOrKeyCode, keyCode) { - var context, type; - - if (typeof keyCode === 'undefined') { - context = null; - keyCode = typeOrKeyCode; - type = contextOrType; - } else { - context = contextOrType; - type = typeOrKeyCode; - } - - return app.testHelpers.triggerEvent(selector, context, type, { keyCode: keyCode, which: keyCode }); - } -}); -enifed('ember-testing/helpers/pause_test', ['exports', 'ember-runtime/ext/rsvp'], function (exports, _emberRuntimeExtRsvp) { - 'use strict'; - - exports.default = pauseTest; - - function pauseTest() { - return new _emberRuntimeExtRsvp.default.Promise(function () {}, 'TestAdapter paused promise'); - } -}); -enifed('ember-testing/helpers/trigger_event', ['exports', 'ember-metal/run_loop', 'ember-testing/events'], function (exports, _emberMetalRun_loop, _emberTestingEvents) { - 'use strict'; - - exports.default = triggerEvent; - - function triggerEvent(app, selector, contextOrType, typeOrOptions, possibleOptions) { - var arity = arguments.length; - var context, type, options; - - if (arity === 3) { - // context and options are optional, so this is - // app, selector, type - context = null; - type = contextOrType; - options = {}; - } else if (arity === 4) { - // context and options are optional, so this is - if (typeof typeOrOptions === 'object') { - // either - // app, selector, type, options - context = null; - type = contextOrType; - options = typeOrOptions; - } else { - // or - // app, selector, context, type - context = contextOrType; - type = typeOrOptions; - options = {}; - } - } else { - context = contextOrType; - type = typeOrOptions; - options = possibleOptions; - } - - var $el = app.testHelpers.findWithAssert(selector, context); - var el = $el[0]; - - _emberMetalRun_loop.default(null, _emberTestingEvents.fireEvent, el, type, options); - - return app.testHelpers.wait(); - } -}); -enifed('ember-testing/helpers/visit', ['exports', 'ember-metal/run_loop'], function (exports, _emberMetalRun_loop) { - 'use strict'; - - exports.default = visit; - - function visit(app, url) { - var router = app.__container__.lookup('router:main'); - var shouldHandleURL = false; - - app.boot().then(function () { - router.location.setURL(url); - - if (shouldHandleURL) { - _emberMetalRun_loop.default(app.__deprecatedInstance__, 'handleURL', url); - } - }); - - if (app._readinessDeferrals > 0) { - router['initialURL'] = url; - _emberMetalRun_loop.default(app, 'advanceReadiness'); - delete router['initialURL']; - } else { - shouldHandleURL = true; - } - - return app.testHelpers.wait(); - } -}); -enifed('ember-testing/helpers/wait', ['exports', 'ember-testing/test/waiters', 'ember-runtime/ext/rsvp', 'ember-metal/run_loop', 'ember-testing/test/pending_requests'], function (exports, _emberTestingTestWaiters, _emberRuntimeExtRsvp, _emberMetalRun_loop, _emberTestingTestPending_requests) { - 'use strict'; - - exports.default = wait; - - function wait(app, value) { - return new _emberRuntimeExtRsvp.default.Promise(function (resolve) { - var router = app.__container__.lookup('router:main'); - - // Every 10ms, poll for the async thing to have finished - var watcher = setInterval(function () { - // 1. If the router is loading, keep polling - var routerIsLoading = router.router && !!router.router.activeTransition; - if (routerIsLoading) { - return; - } - - // 2. If there are pending Ajax requests, keep polling - if (_emberTestingTestPending_requests.pendingRequests()) { - return; - } - - // 3. If there are scheduled timers or we are inside of a run loop, keep polling - if (_emberMetalRun_loop.default.hasScheduledTimers() || _emberMetalRun_loop.default.currentRunLoop) { - return; - } - - if (_emberTestingTestWaiters.checkWaiters()) { - return; - } - - // Stop polling - clearInterval(watcher); - - // Synchronously resolve the promise - _emberMetalRun_loop.default(null, resolve, value); - }, 10); - }); - } -}); enifed('ember-testing/helpers', ['exports', 'ember-testing/test/helpers', 'ember-testing/helpers/and_then', 'ember-testing/helpers/click', 'ember-testing/helpers/current_path', 'ember-testing/helpers/current_route_name', 'ember-testing/helpers/current_url', 'ember-testing/helpers/fill_in', 'ember-testing/helpers/find', 'ember-testing/helpers/find_with_assert', 'ember-testing/helpers/key_event', 'ember-testing/helpers/pause_test', 'ember-testing/helpers/trigger_event', 'ember-testing/helpers/visit', 'ember-testing/helpers/wait'], function (exports, _emberTestingTestHelpers, _emberTestingHelpersAnd_then, _emberTestingHelpersClick, _emberTestingHelpersCurrent_path, _emberTestingHelpersCurrent_route_name, _emberTestingHelpersCurrent_url, _emberTestingHelpersFill_in, _emberTestingHelpersFind, _emberTestingHelpersFind_with_assert, _emberTestingHelpersKey_event, _emberTestingHelpersPause_test, _emberTestingHelpersTrigger_event, _emberTestingHelpersVisit, _emberTestingHelpersWait) { 'use strict'; /** @module ember @@ -1555,10 +1308,257 @@ @since 1.5.0 @public */ _emberTestingTestHelpers.registerAsyncHelper('triggerEvent', _emberTestingHelpersTrigger_event.default); }); +enifed("ember-testing/helpers/and_then", ["exports"], function (exports) { + "use strict"; + + exports.default = andThen; + + function andThen(app, callback) { + return app.testHelpers.wait(callback(app)); + } +}); +enifed('ember-testing/helpers/click', ['exports', 'ember-metal/run_loop', 'ember-testing/events'], function (exports, _emberMetalRun_loop, _emberTestingEvents) { + 'use strict'; + + exports.default = click; + + function click(app, selector, context) { + var $el = app.testHelpers.findWithAssert(selector, context); + var el = $el[0]; + + _emberMetalRun_loop.default(null, _emberTestingEvents.fireEvent, el, 'mousedown'); + + _emberTestingEvents.focus(el); + + _emberMetalRun_loop.default(null, _emberTestingEvents.fireEvent, el, 'mouseup'); + _emberMetalRun_loop.default(null, _emberTestingEvents.fireEvent, el, 'click'); + + return app.testHelpers.wait(); + } +}); +enifed('ember-testing/helpers/current_path', ['exports', 'ember-metal/property_get'], function (exports, _emberMetalProperty_get) { + 'use strict'; + + exports.default = currentPath; + + function currentPath(app) { + var routingService = app.__container__.lookup('service:-routing'); + return _emberMetalProperty_get.get(routingService, 'currentPath'); + } +}); +enifed('ember-testing/helpers/current_route_name', ['exports', 'ember-metal/property_get'], function (exports, _emberMetalProperty_get) { + 'use strict'; + + exports.default = currentRouteName; + + function currentRouteName(app) { + var routingService = app.__container__.lookup('service:-routing'); + return _emberMetalProperty_get.get(routingService, 'currentRouteName'); + } +}); +enifed('ember-testing/helpers/current_url', ['exports', 'ember-metal/property_get'], function (exports, _emberMetalProperty_get) { + 'use strict'; + + exports.default = currentURL; + + function currentURL(app) { + var router = app.__container__.lookup('router:main'); + return _emberMetalProperty_get.get(router, 'location').getURL(); + } +}); +enifed('ember-testing/helpers/fill_in', ['exports', 'ember-metal/run_loop', 'ember-testing/events'], function (exports, _emberMetalRun_loop, _emberTestingEvents) { + 'use strict'; + + exports.default = fillIn; + + function fillIn(app, selector, contextOrText, text) { + var $el, el, context; + if (typeof text === 'undefined') { + text = contextOrText; + } else { + context = contextOrText; + } + $el = app.testHelpers.findWithAssert(selector, context); + el = $el[0]; + _emberTestingEvents.focus(el); + _emberMetalRun_loop.default(function () { + $el.val(text); + _emberTestingEvents.fireEvent(el, 'input'); + _emberTestingEvents.fireEvent(el, 'change'); + }); + return app.testHelpers.wait(); + } +}); +enifed('ember-testing/helpers/find', ['exports', 'ember-metal/property_get'], function (exports, _emberMetalProperty_get) { + 'use strict'; + + exports.default = find; + + function find(app, selector, context) { + var $el = undefined; + context = context || _emberMetalProperty_get.get(app, 'rootElement'); + $el = app.$(selector, context); + return $el; + } +}); +enifed('ember-testing/helpers/find_with_assert', ['exports'], function (exports) { + 'use strict'; + + exports.default = findWithAssert; + + function findWithAssert(app, selector, context) { + var $el = app.testHelpers.find(selector, context); + if ($el.length === 0) { + throw new Error('Element ' + selector + ' not found.'); + } + return $el; + } +}); +enifed('ember-testing/helpers/key_event', ['exports'], function (exports) { + 'use strict'; + + exports.default = keyEvent; + + function keyEvent(app, selector, contextOrType, typeOrKeyCode, keyCode) { + var context, type; + + if (typeof keyCode === 'undefined') { + context = null; + keyCode = typeOrKeyCode; + type = contextOrType; + } else { + context = contextOrType; + type = typeOrKeyCode; + } + + return app.testHelpers.triggerEvent(selector, context, type, { keyCode: keyCode, which: keyCode }); + } +}); +enifed('ember-testing/helpers/pause_test', ['exports', 'ember-runtime/ext/rsvp'], function (exports, _emberRuntimeExtRsvp) { + 'use strict'; + + exports.default = pauseTest; + + function pauseTest() { + return new _emberRuntimeExtRsvp.default.Promise(function () {}, 'TestAdapter paused promise'); + } +}); +enifed('ember-testing/helpers/trigger_event', ['exports', 'ember-metal/run_loop', 'ember-testing/events'], function (exports, _emberMetalRun_loop, _emberTestingEvents) { + 'use strict'; + + exports.default = triggerEvent; + + function triggerEvent(app, selector, contextOrType, typeOrOptions, possibleOptions) { + var arity = arguments.length; + var context, type, options; + + if (arity === 3) { + // context and options are optional, so this is + // app, selector, type + context = null; + type = contextOrType; + options = {}; + } else if (arity === 4) { + // context and options are optional, so this is + if (typeof typeOrOptions === 'object') { + // either + // app, selector, type, options + context = null; + type = contextOrType; + options = typeOrOptions; + } else { + // or + // app, selector, context, type + context = contextOrType; + type = typeOrOptions; + options = {}; + } + } else { + context = contextOrType; + type = typeOrOptions; + options = possibleOptions; + } + + var $el = app.testHelpers.findWithAssert(selector, context); + var el = $el[0]; + + _emberMetalRun_loop.default(null, _emberTestingEvents.fireEvent, el, type, options); + + return app.testHelpers.wait(); + } +}); +enifed('ember-testing/helpers/visit', ['exports', 'ember-metal/run_loop'], function (exports, _emberMetalRun_loop) { + 'use strict'; + + exports.default = visit; + + function visit(app, url) { + var router = app.__container__.lookup('router:main'); + var shouldHandleURL = false; + + app.boot().then(function () { + router.location.setURL(url); + + if (shouldHandleURL) { + _emberMetalRun_loop.default(app.__deprecatedInstance__, 'handleURL', url); + } + }); + + if (app._readinessDeferrals > 0) { + router['initialURL'] = url; + _emberMetalRun_loop.default(app, 'advanceReadiness'); + delete router['initialURL']; + } else { + shouldHandleURL = true; + } + + return app.testHelpers.wait(); + } +}); +enifed('ember-testing/helpers/wait', ['exports', 'ember-testing/test/waiters', 'ember-runtime/ext/rsvp', 'ember-metal/run_loop', 'ember-testing/test/pending_requests'], function (exports, _emberTestingTestWaiters, _emberRuntimeExtRsvp, _emberMetalRun_loop, _emberTestingTestPending_requests) { + 'use strict'; + + exports.default = wait; + + function wait(app, value) { + return new _emberRuntimeExtRsvp.default.Promise(function (resolve) { + var router = app.__container__.lookup('router:main'); + + // Every 10ms, poll for the async thing to have finished + var watcher = setInterval(function () { + // 1. If the router is loading, keep polling + var routerIsLoading = router.router && !!router.router.activeTransition; + if (routerIsLoading) { + return; + } + + // 2. If there are pending Ajax requests, keep polling + if (_emberTestingTestPending_requests.pendingRequests()) { + return; + } + + // 3. If there are scheduled timers or we are inside of a run loop, keep polling + if (_emberMetalRun_loop.default.hasScheduledTimers() || _emberMetalRun_loop.default.currentRunLoop) { + return; + } + + if (_emberTestingTestWaiters.checkWaiters()) { + return; + } + + // Stop polling + clearInterval(watcher); + + // Synchronously resolve the promise + _emberMetalRun_loop.default(null, resolve, value); + }, 10); + }); + } +}); enifed('ember-testing/index', ['exports', 'ember-metal/core', 'ember-testing/test', 'ember-testing/adapters/adapter', 'ember-testing/setup_for_testing', 'require', 'ember-testing/support', 'ember-testing/ext/application', 'ember-testing/ext/rsvp', 'ember-testing/helpers', 'ember-testing/initializers'], function (exports, _emberMetalCore, _emberTestingTest, _emberTestingAdaptersAdapter, _emberTestingSetup_for_testing, _require, _emberTestingSupport, _emberTestingExtApplication, _emberTestingExtRsvp, _emberTestingHelpers, _emberTestingInitializers) { 'use strict'; // to setup initializer @@ -1685,10 +1685,84 @@ _emberMetalDebug.warn('clicked checkboxes should be checked! the jQuery patch didn\'t work', this.checked, { id: 'ember-testing.test-checkbox-click' }); }); }); } }); +enifed('ember-testing/test', ['exports', 'ember-testing/test/helpers', 'ember-testing/test/on_inject_helpers', 'ember-testing/test/promise', 'ember-testing/test/waiters', 'ember-testing/test/adapter', 'ember-metal/features'], function (exports, _emberTestingTestHelpers, _emberTestingTestOn_inject_helpers, _emberTestingTestPromise, _emberTestingTestWaiters, _emberTestingTestAdapter, _emberMetalFeatures) { + /** + @module ember + @submodule ember-testing + */ + 'use strict'; + + /** + This is a container for an assortment of testing related functionality: + + * Choose your default test adapter (for your framework of choice). + * Register/Unregister additional test helpers. + * Setup callbacks to be fired when the test helpers are injected into + your application. + + @class Test + @namespace Ember + @public + */ + var Test = { + /** + Hash containing all known test helpers. + @property _helpers + @private + @since 1.7.0 + */ + _helpers: _emberTestingTestHelpers.helpers, + + registerHelper: _emberTestingTestHelpers.registerHelper, + registerAsyncHelper: _emberTestingTestHelpers.registerAsyncHelper, + unregisterHelper: _emberTestingTestHelpers.unregisterHelper, + onInjectHelpers: _emberTestingTestOn_inject_helpers.onInjectHelpers, + Promise: _emberTestingTestPromise.default, + promise: _emberTestingTestPromise.promise, + resolve: _emberTestingTestPromise.resolve, + registerWaiter: _emberTestingTestWaiters.registerWaiter, + unregisterWaiter: _emberTestingTestWaiters.unregisterWaiter + }; + + if (false) { + Test.checkWaiters = _emberTestingTestWaiters.checkWaiters; + } + + /** + Used to allow ember-testing to communicate with a specific testing + framework. + + You can manually set it before calling `App.setupForTesting()`. + + Example: + + ```javascript + Ember.Test.adapter = MyCustomAdapter.create() + ``` + + If you do not set it, ember-testing will default to `Ember.Test.QUnitAdapter`. + + @public + @for Ember.Test + @property adapter + @type {Class} The adapter to be used. + @default Ember.Test.QUnitAdapter + */ + Object.defineProperty(Test, 'adapter', { + get: _emberTestingTestAdapter.getAdapter, + set: _emberTestingTestAdapter.setAdapter + }); + + Object.defineProperty(Test, 'waiters', { + get: _emberTestingTestWaiters.generateDeprecatedWaitersArray + }); + + exports.default = Test; +}); enifed('ember-testing/test/adapter', ['exports', 'ember-console', 'ember-metal/error_handler'], function (exports, _emberConsole, _emberMetalError_handler) { 'use strict'; exports.getAdapter = getAdapter; exports.setAdapter = setAdapter; @@ -2176,83 +2250,9 @@ array[i] = [context, callback]; } return array; } -}); -enifed('ember-testing/test', ['exports', 'ember-testing/test/helpers', 'ember-testing/test/on_inject_helpers', 'ember-testing/test/promise', 'ember-testing/test/waiters', 'ember-testing/test/adapter', 'ember-metal/features'], function (exports, _emberTestingTestHelpers, _emberTestingTestOn_inject_helpers, _emberTestingTestPromise, _emberTestingTestWaiters, _emberTestingTestAdapter, _emberMetalFeatures) { - /** - @module ember - @submodule ember-testing - */ - 'use strict'; - - /** - This is a container for an assortment of testing related functionality: - - * Choose your default test adapter (for your framework of choice). - * Register/Unregister additional test helpers. - * Setup callbacks to be fired when the test helpers are injected into - your application. - - @class Test - @namespace Ember - @public - */ - var Test = { - /** - Hash containing all known test helpers. - @property _helpers - @private - @since 1.7.0 - */ - _helpers: _emberTestingTestHelpers.helpers, - - registerHelper: _emberTestingTestHelpers.registerHelper, - registerAsyncHelper: _emberTestingTestHelpers.registerAsyncHelper, - unregisterHelper: _emberTestingTestHelpers.unregisterHelper, - onInjectHelpers: _emberTestingTestOn_inject_helpers.onInjectHelpers, - Promise: _emberTestingTestPromise.default, - promise: _emberTestingTestPromise.promise, - resolve: _emberTestingTestPromise.resolve, - registerWaiter: _emberTestingTestWaiters.registerWaiter, - unregisterWaiter: _emberTestingTestWaiters.unregisterWaiter - }; - - if (false) { - Test.checkWaiters = _emberTestingTestWaiters.checkWaiters; - } - - /** - Used to allow ember-testing to communicate with a specific testing - framework. - - You can manually set it before calling `App.setupForTesting()`. - - Example: - - ```javascript - Ember.Test.adapter = MyCustomAdapter.create() - ``` - - If you do not set it, ember-testing will default to `Ember.Test.QUnitAdapter`. - - @public - @for Ember.Test - @property adapter - @type {Class} The adapter to be used. - @default Ember.Test.QUnitAdapter - */ - Object.defineProperty(Test, 'adapter', { - get: _emberTestingTestAdapter.getAdapter, - set: _emberTestingTestAdapter.setAdapter - }); - - Object.defineProperty(Test, 'waiters', { - get: _emberTestingTestWaiters.generateDeprecatedWaitersArray - }); - - exports.default = Test; }); requireModule("ember-testing"); }());