Skip to content

Commit

Permalink
Remove jQuery usage from ember-testing
Browse files Browse the repository at this point in the history
  • Loading branch information
simonihmig committed Jul 22, 2021
1 parent 860f334 commit 6e00ef3
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 1,922 deletions.
1 change: 0 additions & 1 deletion packages/ember-testing/index.js
Expand Up @@ -3,7 +3,6 @@ export { default as Adapter } from './lib/adapters/adapter';
export { default as setupForTesting } from './lib/setup_for_testing';
export { default as QUnitAdapter } from './lib/adapters/qunit';

import './lib/support'; // to handle various edge cases
import './lib/ext/application';
import './lib/ext/rsvp'; // setup RSVP + run loop integration
import './lib/helpers'; // adds helpers to helpers object in Test
Expand Down
39 changes: 4 additions & 35 deletions packages/ember-testing/lib/helpers/find.js
@@ -1,41 +1,10 @@
/**
@module ember
*/
import { get } from '@ember/-internals/metal';
import { assert } from '@ember/debug';
import { jQueryDisabled } from '@ember/-internals/views';

/**
Finds an element in the context of the app's container element. A simple alias
for `app.$(selector)`.
Example:
```javascript
var $el = find('.my-selector');
```
With the `context` param:
```javascript
var $el = find('.my-selector', '.parent-element-class');
```
@method find
@param {String} selector jQuery selector for element lookup
@param {String} [context] (optional) jQuery selector that will limit the selector
argument to find only within the context's children
@return {Object} DOM element representing the results of the query
@public
*/
export default function find(app, selector, context) {
if (jQueryDisabled) {
assert(
'If jQuery is disabled, please import and use helpers from @ember/test-helpers [https://github.com/emberjs/ember-test-helpers]. Note: `find` is not an available helper.'
);
}
let $el;
context = context || get(app, 'rootElement');
$el = app.$(selector, context);
return $el;
export default function find() {
assert(
'Please import and use helpers from @ember/test-helpers [https://github.com/emberjs/ember-test-helpers]. Note: `find` is not an available helper.'
);
}
16 changes: 0 additions & 16 deletions packages/ember-testing/lib/setup_for_testing.js
@@ -1,13 +1,7 @@
/* global self */

import { setTesting } from '@ember/debug';
import { jQuery, jQueryDisabled } from '@ember/-internals/views';
import { getAdapter, setAdapter } from './test/adapter';
import {
incrementPendingRequests,
decrementPendingRequests,
clearPendingRequests,
} from './test/pending_requests';
import Adapter from './adapters/adapter';
import QUnitAdapter from './adapters/qunit';

Expand All @@ -31,14 +25,4 @@ export default function setupForTesting() {
if (!adapter) {
setAdapter(typeof self.QUnit === 'undefined' ? Adapter.create() : QUnitAdapter.create());
}

if (!jQueryDisabled) {
jQuery(document).off('ajaxSend', incrementPendingRequests);
jQuery(document).off('ajaxComplete', decrementPendingRequests);

clearPendingRequests();

jQuery(document).on('ajaxSend', incrementPendingRequests);
jQuery(document).on('ajaxComplete', decrementPendingRequests);
}
}
62 changes: 0 additions & 62 deletions packages/ember-testing/lib/support.js

This file was deleted.

0 comments on commit 6e00ef3

Please sign in to comment.