Skip to content

Commit 506ef09

Browse files
committed
updated integration tests for “link:standalone”
1 parent b196e52 commit 506ef09

File tree

1 file changed

+31
-10
lines changed

1 file changed

+31
-10
lines changed

packages/components/tests/integration/components/hds/link/standalone-test.js

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ module('Integration | Component | hds/link/standalone', function (hooks) {
1111

1212
test('it renders a link(standalone) with the defined text', async function (assert) {
1313
await render(
14-
hbs`<Hds::Link::Standalone @text="watch video" href="/" @icon="film" />`
14+
hbs`<Hds::Link::Standalone @text="watch video" @href="/" @icon="film" />`
1515
);
1616
assert.dom(this.element).hasText('watch video');
1717
});
1818
test('it should render with a CSS class that matches the component name', async function (assert) {
1919
await render(
20-
hbs`<Hds::Link::Standalone @text="watch video" href="/" @icon="film" id="test-link" />`
20+
hbs`<Hds::Link::Standalone @text="watch video" @href="/" @icon="film" id="test-link" />`
2121
);
2222
assert.dom('#test-link').hasClass('hds-link-standalone');
2323
});
@@ -26,13 +26,13 @@ module('Integration | Component | hds/link/standalone', function (hooks) {
2626

2727
test('it should render the medium size if no size is declared', async function (assert) {
2828
await render(
29-
hbs`<Hds::Link::Standalone @text="watch video" href="/" @icon="film" id="test-link" />`
29+
hbs`<Hds::Link::Standalone @text="watch video" @href="/" @icon="film" id="test-link" />`
3030
);
3131
assert.dom('#test-link').hasClass('hds-link-standalone--size-medium');
3232
});
3333
test('it should render the correct CSS size class if the @size prop is declared', async function (assert) {
3434
await render(
35-
hbs`<Hds::Link::Standalone @text="watch video" href="/" @icon="film" id="test-link" @size="small" />`
35+
hbs`<Hds::Link::Standalone @text="watch video" @href="/" @icon="film" id="test-link" @size="small" />`
3636
);
3737
assert.dom('#test-link').hasClass('hds-link-standalone--size-small');
3838
});
@@ -41,27 +41,48 @@ module('Integration | Component | hds/link/standalone', function (hooks) {
4141

4242
test('it should render the icon in the leading position by default', async function (assert) {
4343
await render(
44-
hbs`<Hds::Link::Standalone @text="watch video" href="/" @icon="film" id="test-link" />`
44+
hbs`<Hds::Link::Standalone @text="watch video" @href="/" @icon="film" id="test-link" />`
4545
);
4646
assert.dom('.hds-link-standalone__icon').matchesSelector(':first-child');
4747
});
4848
test('it should render the icon in the trailing position if @iconPosition is set to trailing', async function (assert) {
4949
await render(
50-
hbs`<Hds::Link::Standalone @text="watch video" href="/" @icon="film" @iconPosition="trailing" id="test-link" />`
50+
hbs`<Hds::Link::Standalone @text="watch video" @href="/" @icon="film" @iconPosition="trailing" id="test-link" />`
5151
);
5252
assert.dom('.hds-link-standalone__icon').matchesSelector(':last-child');
5353
});
5454

55+
// TEXT
56+
57+
test('it renders a link with the defined text', async function (assert) {
58+
await render(
59+
hbs`<Hds::Button @text="Copy to clipboard" id="test-toggle-button" />`
60+
);
61+
assert.dom('#test-toggle-button').hasText('Copy to clipboard');
62+
});
63+
5564
// ASSERTIONS
5665

66+
test('it should throw an assertion if both @href and @route are not defined', async function (assert) {
67+
const errorMessage =
68+
'@href or @route must be defined for <Hds::Link::Standalone>';
69+
assert.expect(2);
70+
setupOnerror(function (error) {
71+
assert.strictEqual(error.message, `Assertion Failed: ${errorMessage}`);
72+
});
73+
await render(hbs`<Hds::Link::Standalone @text="watch video" />`);
74+
assert.throws(function () {
75+
throw new Error(errorMessage);
76+
});
77+
});
5778
test('it should throw an assertion if @text is missing/has no value', async function (assert) {
5879
const errorMessage =
5980
'@text for "Hds::Link::Standalone" must have a valid value';
6081
assert.expect(2);
6182
setupOnerror(function (error) {
6283
assert.strictEqual(error.message, `Assertion Failed: ${errorMessage}`);
6384
});
64-
await render(hbs`<Hds::Link::Standalone @icon="film" href="/" />`);
85+
await render(hbs`<Hds::Link::Standalone @icon="film" @href="/" />`);
6586
assert.throws(function () {
6687
throw new Error(errorMessage);
6788
});
@@ -73,7 +94,7 @@ module('Integration | Component | hds/link/standalone', function (hooks) {
7394
setupOnerror(function (error) {
7495
assert.strictEqual(error.message, `Assertion Failed: ${errorMessage}`);
7596
});
76-
await render(hbs`<Hds::Link::Standalone href="/" @text="watch video" />`);
97+
await render(hbs`<Hds::Link::Standalone @href="/" @text="watch video" />`);
7798
assert.throws(function () {
7899
throw new Error(errorMessage);
79100
});
@@ -86,7 +107,7 @@ module('Integration | Component | hds/link/standalone', function (hooks) {
86107
assert.strictEqual(error.message, `Assertion Failed: ${errorMessage}`);
87108
});
88109
await render(
89-
hbs`<Hds::Link::Standalone @icon="film" href="/" @text="watch video" @iconPosition="after" />`
110+
hbs`<Hds::Link::Standalone @icon="film" @href="/" @text="watch video" @iconPosition="after" />`
90111
);
91112
assert.throws(function () {
92113
throw new Error(errorMessage);
@@ -100,7 +121,7 @@ module('Integration | Component | hds/link/standalone', function (hooks) {
100121
assert.strictEqual(error.message, `Assertion Failed: ${errorMessage}`);
101122
});
102123
await render(
103-
hbs`<Hds::Link::Standalone @icon="film" @text="watch video" href="/" @size="tiny" />`
124+
hbs`<Hds::Link::Standalone @icon="film" @text="watch video" @href="/" @size="tiny" />`
104125
);
105126
assert.throws(function () {
106127
throw new Error(errorMessage);

0 commit comments

Comments
 (0)