2019-05-13 19:05:25 +00:00
|
|
|
import { module, test } from 'qunit';
|
|
|
|
import { setupRenderingTest } from 'ember-qunit';
|
|
|
|
import { render } from '@ember/test-helpers';
|
|
|
|
import hbs from 'htmlbars-inline-precompile';
|
2019-05-16 19:49:38 +00:00
|
|
|
import waitForError from 'vault/tests/helpers/wait-for-error';
|
2019-05-13 19:05:25 +00:00
|
|
|
|
2021-12-17 03:44:29 +00:00
|
|
|
module('Integration | Component | icon', function (hooks) {
|
2019-05-13 19:05:25 +00:00
|
|
|
setupRenderingTest(hooks);
|
|
|
|
|
2021-12-17 03:44:29 +00:00
|
|
|
test('it renders', async function (assert) {
|
2019-05-13 19:05:25 +00:00
|
|
|
await render(hbs`<Icon class="i-con" />`);
|
|
|
|
assert.dom('.i-con').exists('renders');
|
|
|
|
|
2021-12-07 17:05:14 +00:00
|
|
|
await render(hbs`<Icon @name="vault-logo" />`);
|
2019-05-13 19:05:25 +00:00
|
|
|
assert.dom('.vault-logo').exists('inlines the SVG');
|
2021-12-07 17:05:14 +00:00
|
|
|
assert.dom('.hs-icon').hasClass('hs-icon-l', 'Default hs class applied');
|
2019-05-13 19:05:25 +00:00
|
|
|
|
|
|
|
await render(hbs`<Icon class="ah" aria-hidden="true" />`);
|
|
|
|
assert.dom('.ah').hasAttribute('aria-hidden', 'true', 'renders aria-hidden');
|
|
|
|
|
|
|
|
await render(hbs`<Icon class="al" aria-label="Testing" />`);
|
|
|
|
assert.dom('.al').hasAttribute('aria-label', 'Testing', 'renders aria-label');
|
2019-05-16 19:49:38 +00:00
|
|
|
|
2021-12-07 17:05:14 +00:00
|
|
|
await render(hbs`<Icon @name="vault-logo" @size="24"/>`);
|
|
|
|
assert.dom('.hs-icon').hasClass('hs-icon-xl', 'adds the larger size class');
|
2019-05-16 19:49:38 +00:00
|
|
|
|
2022-11-09 23:15:31 +00:00
|
|
|
const promise = waitForError();
|
2021-12-07 17:05:14 +00:00
|
|
|
render(hbs`<Icon @name="vault-logo" @size="12"/>`);
|
2022-11-09 23:15:31 +00:00
|
|
|
const err = await promise;
|
2022-10-18 15:46:02 +00:00
|
|
|
assert.strictEqual(
|
2021-12-07 17:05:14 +00:00
|
|
|
err.message,
|
|
|
|
'Assertion Failed: Icon component size argument must be either "16" or "24"',
|
|
|
|
'Error is thrown when supported size is not provided'
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2021-12-17 03:44:29 +00:00
|
|
|
test('it should render FlightIcon', async function (assert) {
|
2021-12-07 17:05:14 +00:00
|
|
|
assert.expect(4);
|
|
|
|
|
|
|
|
await render(hbs`<Icon @name="x" />`);
|
|
|
|
assert.dom('.flight-icon').exists('FlightIcon renders when provided name of icon in set');
|
|
|
|
assert.dom('.flight-icon').hasAttribute('width', '16', 'Default size applied svg');
|
|
|
|
|
|
|
|
await render(hbs`<Icon @name="x" @size="24" />`);
|
|
|
|
assert.dom('.flight-icon').hasAttribute('width', '24', 'Size applied to svg');
|
|
|
|
|
|
|
|
const promise = waitForError();
|
|
|
|
render(hbs`<Icon @name="x" @size="12"/>`);
|
|
|
|
const err = await promise;
|
2022-10-18 15:46:02 +00:00
|
|
|
assert.strictEqual(
|
2021-12-07 17:05:14 +00:00
|
|
|
err.message,
|
|
|
|
'Assertion Failed: Icon component size argument must be either "16" or "24"',
|
|
|
|
'Error is thrown when supported size is not provided'
|
|
|
|
);
|
2019-05-13 19:05:25 +00:00
|
|
|
});
|
|
|
|
});
|