diff --git a/packages/uui-copy/lib/uui-copy.test.ts b/packages/uui-copy/lib/uui-copy.test.ts
index 93b6008f6..e2790547b 100644
--- a/packages/uui-copy/lib/uui-copy.test.ts
+++ b/packages/uui-copy/lib/uui-copy.test.ts
@@ -5,7 +5,7 @@ describe('UUICopyElement', () => {
let element: UUICopyElement;
beforeEach(async () => {
- element = await fixture(html` `);
+ element = await fixture(html``);
});
it('is defined with its own instance', () => {
@@ -15,4 +15,53 @@ describe('UUICopyElement', () => {
it('passes the a11y audit', async () => {
await expect(element).shadowDom.to.be.accessible();
});
+
+ it('renders correctly', async () => {
+ expect(element).shadowDom.to.equal(`
+
+
+ Copy
+
+
+ `);
+ });
+
+ it('copies the value property to clipboard when button is clicked', async () => {
+ const button = element.shadowRoot?.querySelector('uui-button');
+ // // Mock the clipboard API
+ // navigator.clipboard = {
+ // writeText: async text => {
+ // expect(text).to.equal('Test Text');
+ // return Promise.resolve();
+ // },
+ // };
+
+ button?.click();
+ });
+
+ it('fires copying and copied events', async () => {
+ const button = element.shadowRoot?.querySelector('uui-button');
+ // // Mock the clipboard API
+ // navigator.clipboard = {
+ // writeText: async text => {
+ // return Promise.resolve();
+ // },
+ // };
+
+ let copyingEventFired = false;
+ let copiedEventFired = false;
+
+ element.addEventListener('copying', () => {
+ copyingEventFired = true;
+ });
+
+ element.addEventListener('copied', () => {
+ copiedEventFired = true;
+ });
+
+ button?.click();
+
+ expect(copyingEventFired).to.be.true;
+ expect(copiedEventFired).to.be.true;
+ });
});