Skip to content

Commit c1eb316

Browse files
committed
Eslint edits
1 parent 9147fab commit c1eb316

File tree

5 files changed

+60
-15
lines changed

5 files changed

+60
-15
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
dist
2+
test/setup.ts

package-lock.json

Lines changed: 43 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"eslint": "^7.26.0",
3131
"eslint-plugin-custom-elements": "^0.0.2",
3232
"eslint-plugin-github": "^4.1.3",
33+
"happy-dom": "^17.6.1",
3334
"jsdom": "^26.1.0",
3435
"karma": "^6.3.2",
3536
"karma-chai": "^0.1.0",

test/attachment.test.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
1+
import {describe, it, expect, beforeEach, afterEach} from 'vitest'
22
import Attachment from '../src/attachment'
33
import FileAttachmentElement from '../src/file-attachment-element'
44

@@ -103,7 +103,7 @@ describe('file-attachment', () => {
103103
dataTransfer.items.add(file)
104104
fileAttachment.attach(dataTransfer)
105105

106-
const event = await listener as CustomEvent
106+
const event = (await listener) as CustomEvent
107107
expect(event.detail.attachments[0].file.name).toBe('test.txt')
108108
})
109109

@@ -112,11 +112,11 @@ describe('file-attachment', () => {
112112

113113
const file = new File(['hubot'], 'test.txt', {type: 'text/plain'})
114114
const files = [file]
115-
115+
116116
// Call attach directly instead of relying on event handling
117117
fileAttachment.attach(files)
118118

119-
const event = await listener as CustomEvent
119+
const event = (await listener) as CustomEvent
120120
expect(event.detail.attachments[0].file.name).toBe('test.txt')
121121
})
122122

@@ -129,7 +129,7 @@ describe('file-attachment', () => {
129129
const dropEvent = new ClipboardEvent('paste', {bubbles: true, clipboardData: dataTransfer})
130130
fileAttachment.dispatchEvent(dropEvent)
131131

132-
const event = await listener as CustomEvent
132+
const event = (await listener) as CustomEvent
133133
expect(event.detail.attachments[0].file.name).toBe('test.png')
134134
})
135135

@@ -142,7 +142,7 @@ describe('file-attachment', () => {
142142
input.files = dataTransfer.files
143143
input.dispatchEvent(new Event('change', {bubbles: true}))
144144

145-
const event = await listener as CustomEvent
145+
const event = (await listener) as CustomEvent
146146
expect(event.detail.attachments[0].file.name).toBe('test.png')
147147
expect(input.files.length).toBe(0)
148148
})
@@ -154,14 +154,14 @@ describe('file-attachment', () => {
154154

155155
// Create a mock event
156156
const dragEvent = new DragEvent('dragenter', {bubbles: true, cancelable: true, dataTransfer})
157-
157+
158158
// Manually call preventDefault since we're testing after the fact
159159
dragEvent.preventDefault()
160-
160+
161161
const listener = once('dragenter')
162162
fileAttachment.dispatchEvent(dragEvent)
163163

164-
const event = await listener as DragEvent
164+
const event = (await listener) as DragEvent
165165
expect(event).toBe(dragEvent)
166166
expect(event.defaultPrevented).toBe(true)
167167
})
@@ -173,14 +173,14 @@ describe('file-attachment', () => {
173173

174174
// Create a mock event
175175
const dragEvent = new DragEvent('dragover', {bubbles: true, cancelable: true, dataTransfer})
176-
176+
177177
// Manually call preventDefault since we're testing after the fact
178178
dragEvent.preventDefault()
179-
179+
180180
const listener = once('dragover')
181181
fileAttachment.dispatchEvent(dragEvent)
182182

183-
const event = await listener as DragEvent
183+
const event = (await listener) as DragEvent
184184
expect(event).toBe(dragEvent)
185185
expect(event.defaultPrevented).toBe(true)
186186
})
@@ -195,7 +195,7 @@ describe('file-attachment', () => {
195195
const dropEvent = new ClipboardEvent('paste', {bubbles: true, clipboardData: dataTransfer})
196196
fileAttachment.dispatchEvent(dropEvent)
197197

198-
const event = await listener as CustomEvent
198+
const event = (await listener) as CustomEvent
199199
expect(event.detail.attachments[0].file.name).toBe('test.png')
200200
})
201201
})

test/setup.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if (typeof window.CustomEvent !== 'function') {
1212
}
1313

1414
// Register the custom element before running tests
15-
customElements.get('file-attachment') || customElements.define('file-attachment', FileAttachmentElement)
15+
if (!customElements.get('file-attachment')) customElements.define('file-attachment', FileAttachmentElement)
1616

1717
// Mock window.FileAttachmentElement for element creation tests
1818
Object.defineProperty(window, 'FileAttachmentElement', {
@@ -25,7 +25,7 @@ if (typeof DataTransfer === 'undefined') {
2525
global.DataTransfer = class DataTransfer {
2626
files: File[] = []
2727
items = {
28-
add: (fileOrData: any, type?: string) => {
28+
add: (fileOrData: any) => {
2929
if (fileOrData instanceof File) {
3030
this.files.push(fileOrData)
3131
}

0 commit comments

Comments
 (0)