Skip to content

Commit

Permalink
fix: fix eslint scripts
Browse files Browse the repository at this point in the history
Signed-off-by: Kostiantyn Miakshyn <molodchick@gmail.com>
  • Loading branch information
Koc committed Dec 9, 2024
1 parent 474c4d9 commit 6867b82
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 17 deletions.
9 changes: 6 additions & 3 deletions __mocks__/@nextcloud/axios.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
/**
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
* @param timeout
* @param data
* @param signal
*/
// Fake cancellable timeout
// TODO: replace by import { setTimeout } from 'timers/promises' when min LTS is >= 16
// implemented in node 15
const timeout = (timeout: number, data = {}, signal: AbortSignal = new AbortController().signal) => {
return new Promise((resolve, reject) => {
if (signal?.aborted){
reject(new DOMException("Aborted", "AbortError"))
if (signal?.aborted) {
reject(new DOMException('Aborted', 'AbortError'))
return
}
signal.addEventListener('abort', () => {
reject(new DOMException("Aborted", "AbortError"))
reject(new DOMException('Aborted', 'AbortError'))
})

setTimeout(() => {
Expand Down
4 changes: 2 additions & 2 deletions __tests__/upload.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ describe('Cancellation', () => {
const upload = new Upload('http://domain.com/remote.php/dav/files/user/image.jpg', true, 10 * 1024 * 1024, file)

// Mock controller and spy on abort
upload['_controller'] = controller
upload._controller = controller
vi.spyOn(controller, 'abort')

expect(upload.signal).toBeInstanceOf(AbortSignal)
Expand All @@ -165,7 +165,7 @@ describe('Cancellation', () => {
const upload = new Upload('http://domain.com/remote.php/dav/files/user/image.jpg', true, 150 * 1024 * 1024, file)

// Mock controller and spy on abort
upload['_controller'] = controller
upload._controller = controller
vi.spyOn(controller, 'abort')

expect(upload.signal).toBeInstanceOf(AbortSignal)
Expand Down
16 changes: 8 additions & 8 deletions __tests__/utils/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,36 @@ import { getMaxChunksSize } from '../../lib/utils/config.js'

describe('Max chunk size tests', () => {
test('Returning valid config', () => {
Object.assign(window, {OC: {appConfig: {files: { max_chunk_size: 15 * 1024 * 1024 }}}})
Object.assign(window, { OC: { appConfig: { files: { max_chunk_size: 15 * 1024 * 1024 } } } })
expect(getMaxChunksSize()).toBe(15 * 1024 * 1024)
})

test('Returning valid config for chunking v2 minimum size', () => {
Object.assign(window, {OC: {appConfig: {files: { max_chunk_size: 4 * 1024 * 1024 }}}})
Object.assign(window, { OC: { appConfig: { files: { max_chunk_size: 4 * 1024 * 1024 } } } })
expect(getMaxChunksSize()).toBe(5 * 1024 * 1024)
})

test('Returning valid config for chunking v2 maximum chunk count', () => {
Object.assign(window, {OC: {appConfig: {files: { max_chunk_size: 5 * 1024 * 1024 }}}})
Object.assign(window, { OC: { appConfig: { files: { max_chunk_size: 5 * 1024 * 1024 } } } })
expect(getMaxChunksSize(50 * 1024 * 1024 * 10000)).toBe(5 * 1024 * 1024 * 10)
})

test('Returning disabled chunking config', () => {
Object.assign(window, {OC: {appConfig: {files: { max_chunk_size: 0 }}}})
Object.assign(window, { OC: { appConfig: { files: { max_chunk_size: 0 } } } })
expect(getMaxChunksSize()).toBe(0)

Object.assign(window, {OC: {appConfig: {files: { max_chunk_size: -1 }}}})
Object.assign(window, { OC: { appConfig: { files: { max_chunk_size: -1 } } } })
expect(getMaxChunksSize()).toBe(0)

Object.assign(window, {OC: {appConfig: {files: { max_chunk_size: null }}}})
Object.assign(window, { OC: { appConfig: { files: { max_chunk_size: null } } } })
expect(getMaxChunksSize()).toBe(0)
})

test('Returning invalid config', () => {
Object.assign(window, {OC: {appConfig: {files: { max_chunk_size: 'test' }}}})
Object.assign(window, { OC: { appConfig: { files: { max_chunk_size: 'test' } } } })
expect(getMaxChunksSize()).toBe(10 * 1024 * 1024)

Object.assign(window, {OC: {appConfig: {files: { max_chunk_size: undefined }}}})
Object.assign(window, { OC: { appConfig: { files: { max_chunk_size: undefined } } } })
expect(getMaxChunksSize()).toBe(10 * 1024 * 1024)
})
})
2 changes: 1 addition & 1 deletion cypress/components/UploadPicker/invalid-filenames.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,4 +474,4 @@ describe.only('UploadPicker: invalid filenames (server capabilities)', { testIso
expect(requests).to.contain('now-valid.jpg')
})
})
})
})
1 change: 0 additions & 1 deletion lib/components/UploadPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,6 @@ export default Vue.extend({
return Array.isArray(this.content) ? this.content : await this.content(path)
},


/**
* Start uploading
*/
Expand Down
1 change: 1 addition & 0 deletions lib/utils/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
* @param fileSize
*/
export const getMaxChunksSize = function(fileSize: number | undefined = undefined): number {
const maxChunkSize = window.OC?.appConfig?.files?.max_chunk_size
Expand Down
1 change: 1 addition & 0 deletions lib/utils/filesystem.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
* @param o
*/
// Helpers for the File and Directory API

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
"dev": "vite --mode development build",
"watch": "vite --mode development build --watch",
"build:doc": "typedoc --out dist/doc lib && touch dist/doc/.nojekyll",
"lint": "eslint --ext .js,.vue .",
"lint:fix": "eslint --ext .js,.vue --fix .",
"lint": "eslint --ext .js,.ts,.vue .",
"lint:fix": "eslint --ext .js,.ts,.vue, --fix .",
"cypress": "cypress run --component",
"cypress:gui": "cypress open --component",
"test": "vitest run",
Expand Down

0 comments on commit 6867b82

Please sign in to comment.