Skip to content

Commit 821e769

Browse files
author
shleewhite
committed
fix: actually fix copy test
1 parent b116201 commit 821e769

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

showcase/tests/integration/modifiers/hds-clipboard-test.gjs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
import sinon from 'sinon';
1616
import { TrackedObject } from 'tracked-built-ins';
1717
import style from 'ember-style-modifier';
18+
import { modifier } from 'ember-modifier';
1819

1920
import hdsClipboard, {
2021
getTextToCopy,
@@ -425,6 +426,7 @@ module('Integration | Modifier | hds-clipboard', function (hooks) {
425426
test('it should allow to target an element using a DOM node', async function (assert) {
426427
const context = new TrackedObject({
427428
success: undefined,
429+
target: undefined,
428430
});
429431

430432
const onSuccess = () => {
@@ -435,15 +437,22 @@ module('Integration | Modifier | hds-clipboard', function (hooks) {
435437
context.success = false;
436438
};
437439

438-
const target = find('#test-target');
440+
// need to use a modifier to set the target DOM node to make sure that it is defined
441+
const registerTarget = modifier((element) => {
442+
context.target = element;
443+
});
439444

440445
await render(
441446
<template>
442-
<p id="test-target">Hello world!</p>
447+
<p {{registerTarget}}>Hello world!</p>
443448
<button
444449
type="button"
445450
id="test-button"
446-
{{hdsClipboard target=target onSuccess=onSuccess onError=onError}}
451+
{{hdsClipboard
452+
target=context.target
453+
onSuccess=onSuccess
454+
onError=onError
455+
}}
447456
>Test</button>
448457
</template>,
449458
);

0 commit comments

Comments
 (0)