Files
threshold-ui/addons/rose/tests/integration/components/rose/button-test.js
T
hashicorp-copywrite[bot]andCameron Perera 3d610427d0 [COMPLIANCE] Add Copyright and License Headers (#1617)
* [COMPLIANCE] Add Copyright and License Headers

* chore: 🤖 update Copyright headers to satisfy our lint rules

---------

Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
Co-authored-by: Cameron Perera <cameron.perera@hashicorp.com>
2023-03-01 09:39:41 -06:00

59 lines
1.9 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, find } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
module('Integration | Component | rose/button', function (hooks) {
setupRenderingTest(hooks);
test('it renders', async function (assert) {
await render(hbs`<Rose::Button>Button</Rose::Button>`);
assert.strictEqual(this.element.textContent.trim(), 'Button');
});
test('it is type="button" by default', async function (assert) {
await render(hbs`<Rose::Button>Button</Rose::Button>`);
assert.strictEqual(find('button').type, 'button');
});
test('it is type="submit" when @submit={{true}}', async function (assert) {
await render(hbs`<Rose::Button @submit={{true}} />`);
assert.strictEqual(find('button').type, 'submit');
});
test('it is disabled when @disabled={{true}}', async function (assert) {
await render(hbs`<Rose::Button @disabled={{true}} />`);
assert.true(find('button').disabled);
});
test('it adds a style class', async function (assert) {
await render(hbs`<Rose::Button @style="primary" />`);
assert.ok(find('.rose-button-primary'));
await render(hbs`<Rose::Button @style="secondary" />`);
assert.ok(find('.rose-button-secondary'));
});
test('it supports left and right icons', async function (assert) {
await render(
hbs`<Rose::Button @iconLeft="flight-icons/svg/chevron-left-16" />`
);
assert.ok(find('.has-icon-left .rose-icon'));
await render(
hbs`<Rose::Button @iconRight="flight-icons/svg/chevron-left-16" />`
);
assert.ok(find('.has-icon-right .rose-icon'));
});
test('it supports an icon-only type', async function (assert) {
await render(
hbs`<Rose::Button @iconOnly="flight-icons/svg/chevron-left-16" />`
);
assert.ok(find('.has-icon-only .rose-icon'));
});
});