Skip to content

Commit

Permalink
Merge pull request #1448 from kaliber5/deprecations
Browse files Browse the repository at this point in the history
Fix deprecations failing the build
  • Loading branch information
simonihmig committed Mar 14, 2021
2 parents dd3db0c + d62bce9 commit 6aeead2
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 62 deletions.
7 changes: 6 additions & 1 deletion tests/helpers/setup-no-deprecations.js
Expand Up @@ -4,12 +4,17 @@ import { registerDeprecationHandler } from '@ember/debug';
let isRegistered = false;
let deprecations;

// Ignore deprecations that are not caused by our own code, and which we cannot fix easily.
const ignoredDeprecations = [/Versions of modifier manager capabilities prior to 3\.22 have been deprecated/];

export default function setupNoDeprecations({ beforeEach, afterEach }) {
beforeEach(function () {
deprecations = [];
if (!isRegistered) {
registerDeprecationHandler((message, options, next) => {
deprecations.push(message);
if (!ignoredDeprecations.some((regex) => message.match(regex))) {
deprecations.push(message);
}
next(message, options);
});
isRegistered = true;
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/components/bs-dropdown-test.js
Expand Up @@ -321,7 +321,7 @@ module('Integration | Component | bs-dropdown', function (hooks) {
<dd.toggle>Dropdown</dd.toggle>
<dd.menu as |menu|>
<menu.item>
{{menu.link-to "Home" "index"}}
<menu.link-to @route="index">Home</menu.link-to>
</menu.item>
</dd.menu>
</BsDropdown>`);
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/components/bs-dropdown/menu-test.js
Expand Up @@ -58,8 +58,8 @@ module('Integration | Component | bs-dropdown/menu', function (hooks) {
hbs`
<BsDropdown as |dd|>
<dd.menu @toggleElement={{this.element}} @isOpen={{true}} as |ddm|>
{{#ddm.link-to "index"}}Link{{/ddm.link-to}}
{{#ddm.linkTo "index"}}Link{{/ddm.linkTo}}
<ddm.link-to @route="index">Link</ddm.link-to>
<ddm.linkTo @route="index">Link</ddm.linkTo>
</dd.menu>
</BsDropdown>
`
Expand Down
46 changes: 20 additions & 26 deletions tests/integration/components/bs-dropdown/menu/link-to-test.js
Expand Up @@ -4,13 +4,9 @@ import { render } from '@ember/test-helpers';
import { testBS3, testBS4 } from '../../../../helpers/bootstrap';
import hbs from 'htmlbars-inline-precompile';
import setupNoDeprecations from '../../../../helpers/setup-no-deprecations';
import hasEmberVersion from '@ember/test-helpers/has-ember-version';

const supportsAngleBracketsLinkTo = hasEmberVersion(3, 10);

module('Integration | Component | bs-dropdown/menu/link-to', function (hooks) {
setupRenderingTest(hooks);
setupNoDeprecations(hooks);
hooks.beforeEach(function () {
this.owner.setupRouter();
});
Expand Down Expand Up @@ -64,32 +60,30 @@ module('Integration | Component | bs-dropdown/menu/link-to', function (hooks) {
});
});

if (supportsAngleBracketsLinkTo) {
module('<LinkTo> properties', function () {
test('simple route link', async function (assert) {
await render(hbs`<BsDropdown::menu::link-to @route="index">Link</BsDropdown::menu::link-to>`);
module('<LinkTo> properties', function (hooks) {
setupNoDeprecations(hooks);

test('simple route link', async function (assert) {
await render(hbs`<BsDropdown::menu::link-to @route="index">Link</BsDropdown::menu::link-to>`);

assert.dom('a').exists({ count: 1 });
assert.dom('a').hasText('Link');
assert.dom('a').hasAttribute('href', '/');
});
assert.dom('a').exists({ count: 1 });
assert.dom('a').hasText('Link');
assert.dom('a').hasAttribute('href', '/');
});

test('link with model', async function (assert) {
await render(
hbs`<BsDropdown::menu::link-to @route="acceptance.link" @model="1" @query={{hash foo="bar"}}>Link</BsDropdown::menu::link-to>`
);
test('link with model', async function (assert) {
await render(
hbs`<BsDropdown::menu::link-to @route="acceptance.link" @model="1" @query={{hash foo="bar"}}>Link</BsDropdown::menu::link-to>`
);

assert.dom('a').exists({ count: 1 });
assert.dom('a').hasAttribute('href', '/acceptance/link/1?foo=bar');
});
assert.dom('a').exists({ count: 1 });
assert.dom('a').hasAttribute('href', '/acceptance/link/1?foo=bar');
});

test('disabled link', async function (assert) {
await render(
hbs`<BsDropdown::menu::link-to @route="index" @disabled={{true}}>Link</BsDropdown::menu::link-to>`
);
test('disabled link', async function (assert) {
await render(hbs`<BsDropdown::menu::link-to @route="index" @disabled={{true}}>Link</BsDropdown::menu::link-to>`);

assert.dom('a').hasClass('disabled');
});
assert.dom('a').hasClass('disabled');
});
}
});
});
8 changes: 4 additions & 4 deletions tests/integration/components/bs-nav-test.js
Expand Up @@ -52,10 +52,10 @@ module('Integration | Component | bs-nav', function (hooks) {
await render(hbs`
<BsNav as |nav|>
<nav.item>
{{#nav.link-to "application"}}Dummy{{/nav.link-to}}
<nav.link-to @route="application">Dummy</nav.link-to>
</nav.item>
<nav.item>
{{#nav.linkTo "application"}}Dummy{{/nav.linkTo}}
<nav.linkTo @route="application">Dummy</nav.linkTo>
</nav.item>
<nav.dropdown as |dd|>
<dd.toggle>Dropdown <span class="caret"></span></dd.toggle>
Expand All @@ -76,10 +76,10 @@ module('Integration | Component | bs-nav', function (hooks) {
await render(hbs`
<BsNav as |nav|>
<nav.item>
{{#nav.link-to "application"}}Dummy{{/nav.link-to}}
<nav.link-to @route="application">Dummy</nav.link-to>
</nav.item>
<nav.item>
{{#nav.linkTo "application"}}Dummy{{/nav.linkTo}}
<nav.linkTo @route="application">Dummy</nav.linkTo>
</nav.item>
<nav.dropdown as |dd|>
<dd.toggle>Dropdown <span class="caret"></span></dd.toggle>
Expand Down
52 changes: 24 additions & 28 deletions tests/integration/components/bs-nav/link-to-test.js
Expand Up @@ -4,13 +4,9 @@ import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
import setupNoDeprecations from '../../../helpers/setup-no-deprecations';
import { testBS4 } from '../../../helpers/bootstrap';
import hasEmberVersion from '@ember/test-helpers/has-ember-version';

const supportsAngleBracketsLinkTo = hasEmberVersion(3, 10);

module('Integration | Component | bs-nav/link-to', function (hooks) {
setupRenderingTest(hooks);
setupNoDeprecations(hooks);
hooks.beforeEach(function () {
this.owner.setupRouter();
});
Expand Down Expand Up @@ -44,36 +40,36 @@ module('Integration | Component | bs-nav/link-to', function (hooks) {
});
});

if (supportsAngleBracketsLinkTo) {
module('<LinkTo> properties', function () {
test('simple route link', async function (assert) {
await render(hbs`<BsNav::link-to @route="index">Link</BsNav::link-to>`);
module('<LinkTo> properties', function (hooks) {
setupNoDeprecations(hooks);

assert.dom('a').exists({ count: 1 });
assert.dom('a').hasText('Link');
assert.dom('a').hasAttribute('href', '/');
});
test('simple route link', async function (assert) {
await render(hbs`<BsNav::link-to @route="index">Link</BsNav::link-to>`);

test('link with model', async function (assert) {
await render(
hbs`<BsNav::link-to @route="acceptance.link" @model="1" @query={{hash foo="bar"}}>Link</BsNav::link-to>`
);
assert.dom('a').exists({ count: 1 });
assert.dom('a').hasText('Link');
assert.dom('a').hasAttribute('href', '/');
});

assert.dom('a').exists({ count: 1 });
assert.dom('a').hasAttribute('href', '/acceptance/link/1?foo=bar');
});
test('link with model', async function (assert) {
await render(
hbs`<BsNav::link-to @route="acceptance.link" @model="1" @query={{hash foo="bar"}}>Link</BsNav::link-to>`
);

testBS4('link has nav-link class', async function (assert) {
await render(hbs`<BsNav::link-to @route="index">Link</BsNav::link-to>`);
assert.dom('a').exists({ count: 1 });
assert.dom('a').hasAttribute('href', '/acceptance/link/1?foo=bar');
});

testBS4('link has nav-link class', async function (assert) {
await render(hbs`<BsNav::link-to @route="index">Link</BsNav::link-to>`);

assert.dom('a').hasClass('nav-link');
});
assert.dom('a').hasClass('nav-link');
});

test('disabled link', async function (assert) {
await render(hbs`<BsNav::link-to @route="index" @disabled={{true}}>Link</BsNav::link-to>`);
test('disabled link', async function (assert) {
await render(hbs`<BsNav::link-to @route="index" @disabled={{true}}>Link</BsNav::link-to>`);

assert.dom('a').hasClass('disabled');
});
assert.dom('a').hasClass('disabled');
});
}
});
});

0 comments on commit 6aeead2

Please sign in to comment.