Skip to content

Commit

Permalink
chore: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lzl0304 committed Jul 16, 2024
1 parent 0752ca6 commit 29675b7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
4 changes: 2 additions & 2 deletions packages/vuetify/src/labs/VFileUpload/VFileUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export const VFileUpload = genericComponent<VFileUploadSlots>()({
model.value = array
}

emit('change', model.value)
emit('change', files)

if (props.autoUpload) {
upload(files).catch((e: Error) => {
Expand All @@ -247,7 +247,7 @@ export const VFileUpload = genericComponent<VFileUploadSlots>()({
}
model.value = props.multiple ? [...model.value, ...files] : files

emit('change', model.value)
emit('change', files)

if (props.autoUpload) {
upload(files).catch((e: Error) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,6 @@ describe('VFileUpload', () => {
.get('.v-list-item .v-list-item__content .v-list-item-title').eq(1).should('have.text', 'text.txt')
})

it('should upload file with params', () => {
cy.intercept('POST', '/users').as('upload')
cy.mount(() => <VFileUpload />)
.get('input[type="file"]').attachFile(['example.json'])
.wait('@upload').then(interception => {
expect(interception.request.method).to.eq('POST')
})
})

it('should upload single file', () => {
const model = ref()
const change = cy.spy().as('change')
Expand Down
2 changes: 1 addition & 1 deletion packages/vuetify/src/labs/VFileUpload/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const useUpload = (options: Options) => {
const { name, url, method, headers } = options
const xhr = new XMLHttpRequest()

xhr.open(method, url, true)
if (headers) {
Object.keys(headers).forEach(key => {
if (headers[key] !== null) {
Expand Down Expand Up @@ -79,7 +80,6 @@ const useUpload = (options: Options) => {
if (options.withCredentials && 'withCredentials' in xhr) {
xhr.withCredentials = true
}
xhr.open(method, url, true)
xhr.send(formData)

uploadMap.value.set(file, {
Expand Down

0 comments on commit 29675b7

Please sign in to comment.