Skip to content

Commit

Permalink
Merge pull request #445 from appuniversum/chore/deprecate-au-loader-s…
Browse files Browse the repository at this point in the history
…ize-argument

Deprecate the `@size` argument for the `AuLoader` component
  • Loading branch information
Windvis committed Oct 12, 2023
2 parents 8834b4b + e80bc28 commit 1ff9687
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
14 changes: 14 additions & 0 deletions addon/components/au-loader.gjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
import { deprecate } from '@ember/debug';
import Component from '@glimmer/component';

export default class AuLoader extends Component {
get padding() {
deprecate(
'[AuLoader] The `@size` argument is deprecated. Use `@padding` instead.',
!('size' in this.args),
{
id: '@appuniversum/ember-appuniversum.au-loader-size',
until: '3.0.0',
for: '@appuniversum/ember-appuniversum',
since: {
enabled: '2.17.0',
},
},
);

if (this.args.padding == 'small') return 'au-c-loader--small';
if (this.args.padding == 'large') return 'au-c-loader--large';
if (this.args.size == 'small')
Expand Down
37 changes: 32 additions & 5 deletions tests/integration/components/au-loader-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,43 @@ import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { hasDeprecationStartingWith } from '../../helpers/deprecations';

module('Integration | Component | au-loader', function (hooks) {
setupRenderingTest(hooks);

test('it renders', async function (assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.set('myAction', function(val) { ... });

test('it renders a hidden loading text for screen readers', async function (assert) {
await render(hbs`<AuLoader />`);

assert.dom(this.element).hasText('Aan het laden');
assert.dom().hasText('Aan het laden');
});

test('it supports rendering a custom hidden loading text', async function (assert) {
await render(hbs`<AuLoader @message="Loading" />`);

assert.dom().hasText('Loading');
});

test('it supports disabling the hidden message', async function (assert) {
await render(hbs`<AuLoader @disableMessage={{true}} />`);

assert.dom().hasNoText();
});

test('it triggers a deprecation when the `@size` argument is used', async function (assert) {
await render(hbs`<AuLoader @padding="small" />`);

assert.false(
hasDeprecationStartingWith(
'[AuLoader] The `@size` argument is deprecated. Use `@padding` instead.',
),
);

await render(hbs`<AuLoader @size="small" />`);
assert.true(
hasDeprecationStartingWith(
'[AuLoader] The `@size` argument is deprecated. Use `@padding` instead.',
),
);
});
});

0 comments on commit 1ff9687

Please sign in to comment.