Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deprecation for this.$ in rendering tests #543

Merged
merged 1 commit into from Jan 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions addon-test-support/@ember/test-helpers/setup-rendering-context.ts
Expand Up @@ -9,6 +9,7 @@ import settled from './settled';
import hbs, { TemplateFactory } from 'htmlbars-inline-precompile';
import getRootElement from './dom/get-root-element';
import { Owner } from './build-owner';
import { deprecate } from '@ember/application/deprecations';

export const RENDERING_CLEANUP = Object.create(null);
const OUTLET_TEMPLATE = hbs`{{outlet}}`;
Expand Down Expand Up @@ -53,6 +54,17 @@ function lookupOutletTemplate(owner: Owner): any {
@returns {jQuery} a jQuery object representing the selector (or element itself if no selector)
*/
function jQuerySelector(selector: string): any {
deprecate(
'Using this.$() in a rendering test has been deprecated, consider using this.element instead.',
false,
{
id: 'ember-test-helpers.rendering-context.jquery-element',
until: '2.0.0',
// @ts-ignore
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@types/ember does not have url in its options interface! 🤔Seems like a bug?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, I agree. Maybe file an issue (or PR) to fix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

url: 'https://emberjs.com/deprecations/v3.x#toc_jquery-apis',
}
);

let { element } = getContext() as RenderingTestContext;

// emulates Ember internal behavor of `this.$` in a component
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/setup-rendering-context-test.js
Expand Up @@ -128,6 +128,9 @@ module('setupRenderingContext', function(hooks) {
await this.render(hbs`<p>Hello!</p>`);

assert.equal(this.$().text(), 'Hello!');
assert.deprecationsInclude(
'Using this.$() in a rendering test has been deprecated, consider using this.element instead.'
);
});

test('can invoke template only components', async function(assert) {
Expand Down