/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
-import 'mocha'
-import * as chai from 'chai'
+import { expect } from 'chai'
import { pathExists, readdir, stat } from 'fs-extra'
import { join } from 'path'
import { buildAbsoluteFixturePath } from '@shared/core-utils'
import { HttpStatusCode, VideoPrivacy } from '@shared/models'
import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel } from '@shared/server-commands'
-const expect = chai.expect
-
// Most classic resumable upload tests are done in other test suites
describe('Test resumable upload', function () {
it('Should not accept more chunks than expected with an invalid content length/content range', async function () {
const uploadId = await prepareUpload({ size: 1500 })
- // Content length check seems to have changed in v16
- if (process.version.startsWith('v16')) {
+ // Content length check can be different depending on the node version
+ try {
await sendChunks({ pathUploadId: uploadId, expectedStatus: HttpStatusCode.CONFLICT_409, contentLength: 1000 })
- await checkFileSize(uploadId, 1000)
- } else {
+ await checkFileSize(uploadId, 0)
+ } catch {
await sendChunks({ pathUploadId: uploadId, expectedStatus: HttpStatusCode.BAD_REQUEST_400, contentLength: 1000 })
await checkFileSize(uploadId, 0)
}