From f2978651f03670c94afc4fd666ecefc1992f8e5c Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Sun, 21 Sep 2025 11:04:55 +0100 Subject: [PATCH] Migrate from mocha to Node.js native test runner Includes coverage reports when using Node.js 22 onwards --- .cirrus.yml | 2 +- .github/CONTRIBUTING.md | 3 -- .github/workflows/ci.yml | 2 +- .mocharc.jsonc | 7 --- lib/input.js | 2 - lib/libvips.js | 36 ++++++++------- lib/output.js | 3 +- lib/sharp.js | 5 +- lib/utility.js | 6 +-- package.json | 14 +----- test/beforeEach.js | 22 --------- test/leak/leak.sh | 2 +- test/unit.mjs | 16 +++++++ test/unit/affine.js | 1 + test/unit/alpha.js | 13 +++--- test/unit/avif.js | 10 ++-- test/unit/bandbool.js | 5 +- test/unit/blur.js | 13 +++--- test/unit/boolean.js | 7 +-- test/unit/clahe.js | 17 +++---- test/unit/clone.js | 3 +- test/unit/colourspace.js | 19 ++++---- test/unit/composite.js | 1 + test/unit/convolve.js | 7 +-- test/unit/dilate.js | 5 +- test/unit/erode.js | 5 +- test/unit/extend.js | 15 +++--- test/unit/extract.js | 33 +++++++------- test/unit/extractChannel.js | 13 +++--- test/unit/failOn.js | 11 +++-- test/unit/fixtures.js | 1 + test/unit/gamma.js | 11 +++-- test/unit/gif.js | 5 +- test/unit/heif.js | 1 + test/unit/io.js | 91 +++++++++++++++++++++---------------- test/unit/join.js | 1 + test/unit/joinChannel.js | 15 +++--- test/unit/jp2.js | 1 + test/unit/jpeg.js | 19 ++++---- test/unit/jxl.js | 1 + test/unit/libvips.js | 5 +- test/unit/linear.js | 17 +++---- test/unit/median.js | 1 + test/unit/metadata.js | 53 ++++++++++----------- test/unit/modulate.js | 1 + test/unit/negate.js | 29 ++++++------ test/unit/noise.js | 9 ++-- test/unit/normalize.js | 17 +++---- test/unit/png.js | 7 +-- test/unit/raw.js | 15 +++--- test/unit/recomb.js | 11 +++-- test/unit/resize-contain.js | 91 +++++++++++++++++++------------------ test/unit/resize-cover.js | 23 +++++----- test/unit/resize.js | 87 +++++++++++++++++------------------ test/unit/rotate.js | 63 ++++++++++++------------- test/unit/sharpen.js | 17 +++---- test/unit/stats.js | 27 +++++------ test/unit/svg.js | 13 +++--- test/unit/text.js | 27 ++++++----- test/unit/threshold.js | 23 +++++----- test/unit/tiff.js | 31 +++++++------ test/unit/tile.js | 59 ++++++++++++------------ test/unit/timeout.js | 1 + test/unit/tint.js | 15 +++--- test/unit/toBuffer.js | 1 + test/unit/toFormat.js | 1 + test/unit/trim.js | 9 ++-- test/unit/unflatten.js | 7 +-- test/unit/util.js | 5 +- test/unit/webp.js | 15 +++--- 70 files changed, 583 insertions(+), 541 deletions(-) delete mode 100644 .mocharc.jsonc delete mode 100644 test/beforeEach.js create mode 100644 test/unit.mjs diff --git a/.cirrus.yml b/.cirrus.yml index eb240b5b..0dbadc40 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -14,4 +14,4 @@ task: install_script: - npm install --build-from-source test_script: - - npx mocha --no-config --spec=test/unit/io.js --timeout=30000 + - node --test test/unit/io.js diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index c806fc5e..eeb6dd19 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -6,8 +6,6 @@ Hello, thank you for your interest in helping! Please create a [new issue](https://github.com/lovell/sharp/issues/new) containing the steps to reproduce the problem. -If you're having installation problems, please include the output of running `npm install --verbose sharp`. - New bugs are assigned a `triage` label whilst under investigation. ## Submit a new feature request @@ -32,7 +30,6 @@ To test C++ changes, you can compile the module using `npm install --build-from- ## Submit a Pull Request with a new feature Please add JavaScript [unit tests](https://github.com/lovell/sharp/tree/main/test/unit) to cover your new feature. -A test coverage report for the JavaScript code is generated in the `coverage/lcov-report` directory. Please also update the [TypeScript definitions](https://github.com/lovell/sharp/tree/main/lib/index.d.ts), along with the [type definition tests](https://github.com/lovell/sharp/tree/main/test/types/sharp.test-d.ts). Where possible, the functional tests use gradient-based perceptual hashes diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c815127f..25fb7c2d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -267,7 +267,7 @@ jobs: curl --silent https://${{ matrix.nodejs_hostname }}/download/release/v${{ matrix.nodejs_version}}/node-v${{ matrix.nodejs_version}}-linux-${{ matrix.nodejs_arch }}.tar.xz | tar xJC /opt/nodejs --strip-components=1 export PATH=$PATH:/opt/nodejs/bin npm install --build-from-source - npx mocha --no-config --spec=test/unit/io.js --timeout=30000 + node --test test/unit/io.js npm run package-from-local-build - uses: actions/upload-artifact@v4 with: diff --git a/.mocharc.jsonc b/.mocharc.jsonc deleted file mode 100644 index 06df4ac9..00000000 --- a/.mocharc.jsonc +++ /dev/null @@ -1,7 +0,0 @@ -{ - "parallel": true, - "slow": 1000, - "timeout": 30000, - "require": "./test/beforeEach.js", - "spec": "./test/unit/*.js" -} diff --git a/lib/input.js b/lib/input.js index f6a86922..403ee31e 100644 --- a/lib/input.js +++ b/lib/input.js @@ -524,9 +524,7 @@ function _createInputDescriptor (input, inputOptions, containerOptions) { * @param {Function} callback */ function _write (chunk, _encoding, callback) { - /* istanbul ignore else */ if (Array.isArray(this.options.input.buffer)) { - /* istanbul ignore else */ if (is.buffer(chunk)) { if (this.options.input.buffer.length === 0) { this.on('finish', () => { diff --git a/lib/libvips.js b/lib/libvips.js index 96edde12..9c2917fc 100644 --- a/lib/libvips.js +++ b/lib/libvips.js @@ -10,8 +10,8 @@ const detectLibc = require('detect-libc'); const { config, engines, optionalDependencies } = require('../package.json'); -const minimumLibvipsVersionLabelled = process.env.npm_package_config_libvips || /* istanbul ignore next */ - config.libvips; +/* node:coverage ignore next */ +const minimumLibvipsVersionLabelled = process.env.npm_package_config_libvips || config.libvips; const minimumLibvipsVersion = semverCoerce(minimumLibvipsVersionLabelled).version; const prebuiltPlatforms = [ @@ -34,17 +34,16 @@ const log = (item) => { } }; -/* istanbul ignore next */ +/* node:coverage ignore next */ const runtimeLibc = () => detectLibc.isNonGlibcLinuxSync() ? detectLibc.familySync() : ''; const runtimePlatformArch = () => `${process.platform}${runtimeLibc()}-${process.arch}`; -/* istanbul ignore next */ const buildPlatformArch = () => { + /* node:coverage ignore next 3 */ if (isEmscripten()) { return 'wasm32'; } - /* eslint camelcase: ["error", { allow: ["^npm_config_"] }] */ const { npm_config_arch, npm_config_platform, npm_config_libc } = process.env; const libc = typeof npm_config_libc === 'string' ? npm_config_libc : runtimeLibc(); return `${npm_config_platform || process.platform}${libc}-${npm_config_arch || process.arch}`; @@ -54,19 +53,19 @@ const buildSharpLibvipsIncludeDir = () => { try { return require(`@img/sharp-libvips-dev-${buildPlatformArch()}/include`); } catch { + /* node:coverage ignore next 5 */ try { return require('@img/sharp-libvips-dev/include'); } catch {} } - /* istanbul ignore next */ return ''; }; const buildSharpLibvipsCPlusPlusDir = () => { + /* node:coverage ignore next 4 */ try { return require('@img/sharp-libvips-dev/cplusplus'); } catch {} - /* istanbul ignore next */ return ''; }; @@ -74,16 +73,17 @@ const buildSharpLibvipsLibDir = () => { try { return require(`@img/sharp-libvips-dev-${buildPlatformArch()}/lib`); } catch { + /* node:coverage ignore next 5 */ try { return require(`@img/sharp-libvips-${buildPlatformArch()}/lib`); } catch {} } - /* istanbul ignore next */ return ''; }; +/* node:coverage disable */ + const isUnsupportedNodeRuntime = () => { - /* istanbul ignore next */ if (process.release?.name === 'node' && process.versions) { if (!semverSatisfies(process.versions.node, engines.node)) { return { found: process.versions.node, expected: engines.node }; @@ -91,14 +91,12 @@ const isUnsupportedNodeRuntime = () => { } }; -/* istanbul ignore next */ const isEmscripten = () => { const { CC } = process.env; return Boolean(CC?.endsWith('/emcc')); }; const isRosetta = () => { - /* istanbul ignore next */ if (process.platform === 'darwin' && process.arch === 'x64') { const translated = spawnSync('sysctl sysctl.proc_translated', spawnSyncOptions).stdout; return (translated || '').trim() === 'sysctl.proc_translated: 1'; @@ -106,6 +104,8 @@ const isRosetta = () => { return false; }; +/* node:coverage enable */ + const sha512 = (s) => createHash('sha512').update(s).digest('hex'); const yarnLocator = () => { @@ -119,7 +119,8 @@ const yarnLocator = () => { return ''; }; -/* istanbul ignore next */ +/* node:coverage disable */ + const spawnRebuild = () => spawnSync(`node-gyp rebuild --directory=src ${isEmscripten() ? '--nodedir=emscripten' : ''}`, { ...spawnSyncOptions, @@ -135,16 +136,17 @@ const globalLibvipsVersion = () => { PKG_CONFIG_PATH: pkgConfigPath() } }).stdout; - /* istanbul ignore next */ return (globalLibvipsVersion || '').trim(); } else { return ''; } }; -/* istanbul ignore next */ +/* node:coverage enable */ + const pkgConfigPath = () => { if (process.platform !== 'win32') { + /* node:coverage ignore next 4 */ const brewPkgConfigPath = spawnSync( 'which brew >/dev/null 2>&1 && brew environment --plain | grep PKG_CONFIG_LIBDIR | cut -d" " -f2', spawnSyncOptions @@ -176,13 +178,13 @@ const useGlobalLibvips = (logger) => { if (Boolean(process.env.SHARP_FORCE_GLOBAL_LIBVIPS) === true) { return skipSearch(true, 'SHARP_FORCE_GLOBAL_LIBVIPS', logger); } - /* istanbul ignore next */ + /* node:coverage ignore next 3 */ if (isRosetta()) { return skipSearch(false, 'Rosetta', logger); } const globalVipsVersion = globalLibvipsVersion(); - return !!globalVipsVersion && /* istanbul ignore next */ - semverGreaterThanOrEqualTo(globalVipsVersion, minimumLibvipsVersion); + /* node:coverage ignore next */ + return !!globalVipsVersion && semverGreaterThanOrEqualTo(globalVipsVersion, minimumLibvipsVersion); }; module.exports = { diff --git a/lib/output.js b/lib/output.js index 65321559..1178d625 100644 --- a/lib/output.js +++ b/lib/output.js @@ -843,7 +843,6 @@ function gif (options) { return this._updateFormatOut('gif', options); } -/* istanbul ignore next */ /** * Use these JP2 options for output image. * @@ -878,6 +877,7 @@ function gif (options) { * @throws {Error} Invalid options */ function jp2 (options) { + /* node:coverage ignore next 41 */ if (!this.constructor.format.jp2k.output.buffer) { throw errJp2Save(); } @@ -1500,7 +1500,6 @@ function _setBooleanOption (key, val) { * @private */ function _read () { - /* istanbul ignore else */ if (!this.options.streamOut) { this.options.streamOut = true; const stack = Error(); diff --git a/lib/sharp.js b/lib/sharp.js index 8a90d826..5cd4a40f 100644 --- a/lib/sharp.js +++ b/lib/sharp.js @@ -15,6 +15,8 @@ const paths = [ '@img/sharp-wasm32/sharp.node' ]; +/* node:coverage disable */ + let path, sharp; const errors = []; for (path of paths) { @@ -22,12 +24,10 @@ for (path of paths) { sharp = require(path); break; } catch (err) { - /* istanbul ignore next */ errors.push(err); } } -/* istanbul ignore next */ if (sharp && path.startsWith('@img/sharp-linux-x64') && !sharp._isUsingX64V2()) { const err = new Error('Prebuilt binaries for linux-x64 require v2 microarchitecture'); err.code = 'Unsupported CPU'; @@ -35,7 +35,6 @@ if (sharp && path.startsWith('@img/sharp-linux-x64') && !sharp._isUsingX64V2()) sharp = null; } -/* istanbul ignore next */ if (sharp) { module.exports = sharp; } else { diff --git a/lib/utility.js b/lib/utility.js index d91605e5..6dd9b19f 100644 --- a/lib/utility.js +++ b/lib/utility.js @@ -55,7 +55,7 @@ const interpolators = { let versions = { vips: libvipsVersion.semver }; -/* istanbul ignore next */ +/* node:coverage ignore next 15 */ if (!libvipsVersion.isGlobal) { if (!libvipsVersion.isWasm) { try { @@ -73,7 +73,7 @@ if (!libvipsVersion.isGlobal) { } versions.sharp = require('../package.json').version; -/* istanbul ignore next */ +/* node:coverage ignore next 5 */ if (versions.heif && format.heif) { // Prebuilt binaries provide AV1 format.heif.input.fileSuffix = ['.avif']; @@ -148,7 +148,7 @@ cache(true); function concurrency (concurrency) { return sharp.concurrency(is.integer(concurrency) ? concurrency : null); } -/* istanbul ignore next */ +/* node:coverage ignore next 7 */ if (detectLibc.familySync() === detectLibc.GLIBC && !sharp._isUsingJemalloc()) { // Reduce default concurrency to 1 when using glibc memory allocator sharp.concurrency(1); diff --git a/package.json b/package.json index 4dd62386..115e3c4f 100644 --- a/package.json +++ b/package.json @@ -99,9 +99,9 @@ "lint-cpp": "cpplint", "lint-js": "biome lint", "lint-licensing": "license-checker --production --summary --onlyAllow=\"Apache-2.0;BSD;ISC;LGPL-3.0-or-later;MIT\"", - "lint-types": "tsd", + "lint-types": "tsd --files ./test/types/sharp.test-d.ts", "test-leak": "./test/leak/leak.sh", - "test-unit": "nyc --reporter=lcov --reporter=text --check-coverage --branches=100 mocha", + "test-unit": "node --experimental-test-coverage test/unit.mjs", "package-from-local-build": "node npm/from-local-build.js", "package-release-notes": "node npm/release-notes.js", "docs-build": "node docs/build.mjs", @@ -183,10 +183,8 @@ "icc": "^3.0.0", "jsdoc-to-markdown": "^9.1.2", "license-checker": "^25.0.1", - "mocha": "^11.7.2", "node-addon-api": "^8.5.0", "node-gyp": "^11.4.2", - "nyc": "^17.1.0", "tar-fs": "^3.1.1", "tsd": "^0.33.0" }, @@ -205,13 +203,5 @@ "filter": [ "build/include" ] - }, - "nyc": { - "include": [ - "lib" - ] - }, - "tsd": { - "directory": "test/types/" } } diff --git a/test/beforeEach.js b/test/beforeEach.js deleted file mode 100644 index 586869fe..00000000 --- a/test/beforeEach.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2013 Lovell Fuller and others. -// SPDX-License-Identifier: Apache-2.0 - -const sharp = require('../'); - -const usingCache = !process.env.G_DEBUG; -const usingSimd = !process.env.VIPS_NOVECTOR; -const concurrency = Number(process.env.VIPS_CONCURRENCY) || 0; - -exports.mochaHooks = { - beforeEach () { - sharp.cache(usingCache); - sharp.simd(usingSimd); - sharp.concurrency(concurrency); - }, - - afterEach () { - if (global.gc) { - global.gc(); - } - } -}; diff --git a/test/leak/leak.sh b/test/leak/leak.sh index c707a6a4..c1e5a0a3 100755 --- a/test/leak/leak.sh +++ b/test/leak/leak.sh @@ -18,5 +18,5 @@ for test in $TESTS; do --show-leak-kinds=definite,indirect \ --num-callers=20 \ --trace-children=yes \ - node --expose-gc --zero-fill-buffers node_modules/.bin/mocha --no-config --slow=60000 --timeout=120000 --require test/beforeEach.js "test/unit/$test"; + node --zero-fill-buffers --test "test/unit/$test"; done diff --git a/test/unit.mjs b/test/unit.mjs new file mode 100644 index 00000000..0a1aa3c0 --- /dev/null +++ b/test/unit.mjs @@ -0,0 +1,16 @@ +import { readdir } from 'node:fs/promises'; +import { run } from 'node:test'; +import { spec } from 'node:test/reporters'; + +const files = (await readdir('./test/unit')).map((f) => `./test/unit/${f}`); + +run({ + files, + concurrency: true, + timeout: 60000, + coverage: true, + coverageIncludeGlobs: ['lib/*.js'], + branchCoverage: 100, +}) + .compose(new spec()) + .pipe(process.stdout); diff --git a/test/unit/affine.js b/test/unit/affine.js index 6ff523be..7c76776c 100644 --- a/test/unit/affine.js +++ b/test/unit/affine.js @@ -1,6 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); diff --git a/test/unit/alpha.js b/test/unit/alpha.js index 13b3bc27..3cb61aaa 100644 --- a/test/unit/alpha.js +++ b/test/unit/alpha.js @@ -1,12 +1,13 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const fixtures = require('../fixtures'); const sharp = require('../../'); describe('Alpha transparency', function () { - it('Flatten to black', function (done) { + it('Flatten to black', function (_t, done) { sharp(fixtures.inputPngWithTransparency) .flatten() .resize(400, 300) @@ -18,7 +19,7 @@ describe('Alpha transparency', function () { }); }); - it('Flatten to RGB orange', function (done) { + it('Flatten to RGB orange', function (_t, done) { sharp(fixtures.inputPngWithTransparency) .resize(400, 300) .flatten({ @@ -33,7 +34,7 @@ describe('Alpha transparency', function () { }); }); - it('Flatten to CSS/hex orange', function (done) { + it('Flatten to CSS/hex orange', function (_t, done) { sharp(fixtures.inputPngWithTransparency) .resize(400, 300) .flatten({ background: '#ff6600' }) @@ -46,7 +47,7 @@ describe('Alpha transparency', function () { }); }); - it('Flatten 16-bit PNG with transparency to orange', function (done) { + it('Flatten 16-bit PNG with transparency to orange', function (_t, done) { const output = fixtures.path('output.flatten-rgb16-orange.jpg'); sharp(fixtures.inputPngWithTransparency16bit) .flatten({ @@ -62,7 +63,7 @@ describe('Alpha transparency', function () { }); }); - it('Do not flatten', function (done) { + it('Do not flatten', function (_t, done) { sharp(fixtures.inputPngWithTransparency) .flatten(false) .toBuffer(function (err, _data, info) { @@ -73,7 +74,7 @@ describe('Alpha transparency', function () { }); }); - it('Ignored for JPEG', function (done) { + it('Ignored for JPEG', function (_t, done) { sharp(fixtures.inputJpg) .flatten({ background: '#ff0000' }) .toBuffer(function (err, _data, info) { diff --git a/test/unit/avif.js b/test/unit/avif.js index 8f3cb606..1c28a975 100644 --- a/test/unit/avif.js +++ b/test/unit/avif.js @@ -1,6 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); @@ -172,9 +173,10 @@ describe('AVIF', () => { ) ); - it('Invalid bitdepth value throws error', async () => { - assert.rejects( + it('Invalid bitdepth value throws error', () => + assert.throws( () => sharp().avif({ bitdepth: 11 }), - /Error: Expected 8, 10 or 12 for bitdepth but received 11 of type number/); - }); + /Expected 8, 10 or 12 for bitdepth but received 11 of type number/ + ) + ); }); diff --git a/test/unit/bandbool.js b/test/unit/bandbool.js index 5fad6590..67574522 100644 --- a/test/unit/bandbool.js +++ b/test/unit/bandbool.js @@ -1,6 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const fixtures = require('../fixtures'); const sharp = require('../../'); @@ -12,7 +13,7 @@ describe('Bandbool per-channel boolean operations', function () { sharp.bool.eor ] .forEach(function (op) { - it(`${op} operation`, function (done) { + it(`${op} operation`, function (_t, done) { sharp(fixtures.inputPngBooleanNoAlpha) .bandbool(op) .toColourspace('b-w') @@ -26,7 +27,7 @@ describe('Bandbool per-channel boolean operations', function () { }); }); - it('sRGB image retains 3 channels', function (done) { + it('sRGB image retains 3 channels', function (_t, done) { sharp(fixtures.inputJpg) .bandbool('and') .toBuffer(function (err, _data, info) { diff --git a/test/unit/blur.js b/test/unit/blur.js index efa7163e..41414bf2 100644 --- a/test/unit/blur.js +++ b/test/unit/blur.js @@ -1,13 +1,14 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); describe('Blur', function () { - it('specific radius 1', function (done) { + it('specific radius 1', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .blur(1) @@ -20,7 +21,7 @@ describe('Blur', function () { }); }); - it('specific radius 10', function (done) { + it('specific radius 10', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .blur(10) @@ -33,7 +34,7 @@ describe('Blur', function () { }); }); - it('specific options.sigma 10', function (done) { + it('specific options.sigma 10', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .blur({ sigma: 10 }) @@ -46,7 +47,7 @@ describe('Blur', function () { }); }); - it('specific radius 0.3', function (done) { + it('specific radius 0.3', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .blur(0.3) @@ -59,7 +60,7 @@ describe('Blur', function () { }); }); - it('mild blur', function (done) { + it('mild blur', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .blur() @@ -78,7 +79,7 @@ describe('Blur', function () { }); }); - it('blurred image is smaller than non-blurred', function (done) { + it('blurred image is smaller than non-blurred', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .blur(false) diff --git a/test/unit/boolean.js b/test/unit/boolean.js index e1c3e3f2..c7fcdb4d 100644 --- a/test/unit/boolean.js +++ b/test/unit/boolean.js @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 const fs = require('node:fs'); +const { describe, it } = require('node:test'); const assert = require('node:assert'); const fixtures = require('../fixtures'); @@ -16,7 +17,7 @@ describe('Boolean operation between two images', function () { sharp.bool.eor ] .forEach(function (op) { - it(`${op} operation, file`, function (done) { + it(`${op} operation, file`, function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .boolean(fixtures.inputJpgBooleanTest, op) @@ -28,7 +29,7 @@ describe('Boolean operation between two images', function () { }); }); - it(`${op} operation, buffer`, function (done) { + it(`${op} operation, buffer`, function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .boolean(inputJpgBooleanTestBuffer, op) @@ -40,7 +41,7 @@ describe('Boolean operation between two images', function () { }); }); - it(`${op} operation, raw`, function (done) { + it(`${op} operation, raw`, function (_t, done) { sharp(fixtures.inputJpgBooleanTest) .raw() .toBuffer(function (err, data, info) { diff --git a/test/unit/clahe.js b/test/unit/clahe.js index 8f459c4b..a7277025 100644 --- a/test/unit/clahe.js +++ b/test/unit/clahe.js @@ -1,13 +1,14 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../lib'); const fixtures = require('../fixtures'); describe('Clahe', function () { - it('width 5 width 5 maxSlope 0', function (done) { + it('width 5 width 5 maxSlope 0', function (_t, done) { sharp(fixtures.inputJpgClahe) .clahe({ width: 5, height: 5, maxSlope: 0 }) .toBuffer(function (err, data, info) { @@ -17,7 +18,7 @@ describe('Clahe', function () { }); }); - it('width 5 width 5 maxSlope 5', function (done) { + it('width 5 width 5 maxSlope 5', function (_t, done) { sharp(fixtures.inputJpgClahe) .clahe({ width: 5, height: 5, maxSlope: 5 }) .toBuffer(function (err, data, info) { @@ -27,7 +28,7 @@ describe('Clahe', function () { }); }); - it('width 11 width 25 maxSlope 14', function (done) { + it('width 11 width 25 maxSlope 14', function (_t, done) { sharp(fixtures.inputJpgClahe) .clahe({ width: 11, height: 25, maxSlope: 14 }) .toBuffer(function (err, data, info) { @@ -37,7 +38,7 @@ describe('Clahe', function () { }); }); - it('width 50 width 50 maxSlope 0', function (done) { + it('width 50 width 50 maxSlope 0', function (_t, done) { sharp(fixtures.inputJpgClahe) .clahe({ width: 50, height: 50, maxSlope: 0 }) .toBuffer(function (err, data, info) { @@ -47,7 +48,7 @@ describe('Clahe', function () { }); }); - it('width 50 width 50 maxSlope 14', function (done) { + it('width 50 width 50 maxSlope 14', function (_t, done) { sharp(fixtures.inputJpgClahe) .clahe({ width: 50, height: 50, maxSlope: 14 }) .toBuffer(function (err, data, info) { @@ -57,7 +58,7 @@ describe('Clahe', function () { }); }); - it('width 100 width 50 maxSlope 3', function (done) { + it('width 100 width 50 maxSlope 3', function (_t, done) { sharp(fixtures.inputJpgClahe) .clahe({ width: 100, height: 50, maxSlope: 3 }) .toBuffer(function (err, data, info) { @@ -67,7 +68,7 @@ describe('Clahe', function () { }); }); - it('width 100 width 100 maxSlope 0', function (done) { + it('width 100 width 100 maxSlope 0', function (_t, done) { sharp(fixtures.inputJpgClahe) .clahe({ width: 100, height: 100, maxSlope: 0 }) .toBuffer(function (err, data, info) { @@ -128,7 +129,7 @@ describe('Clahe', function () { }); }); - it('uses default maxSlope of 3', function (done) { + it('uses default maxSlope of 3', function (_t, done) { sharp(fixtures.inputJpgClahe) .clahe({ width: 100, height: 50 }) .toBuffer(function (err, data, info) { diff --git a/test/unit/clone.js b/test/unit/clone.js index 3ac46cee..2075c560 100644 --- a/test/unit/clone.js +++ b/test/unit/clone.js @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 const fs = require('node:fs'); +const { afterEach, beforeEach, describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); @@ -15,7 +16,7 @@ describe('Clone', function () { sharp.cache(true); }); - it('Read from Stream and write to multiple Streams', function (done) { + it('Read from Stream and write to multiple Streams', function (_t, done) { let finishEventsExpected = 2; // Output stream 1 const output1 = fixtures.path('output.multi-stream.1.jpg'); diff --git a/test/unit/colourspace.js b/test/unit/colourspace.js index e311f5fe..f373db34 100644 --- a/test/unit/colourspace.js +++ b/test/unit/colourspace.js @@ -1,20 +1,21 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); describe('Colour space conversion', function () { - it('To greyscale', function (done) { + it('To greyscale', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .greyscale() .toFile(fixtures.path('output.greyscale-gamma-0.0.jpg'), done); }); - it('To greyscale with gamma correction', function (done) { + it('To greyscale with gamma correction', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .gamma() @@ -22,14 +23,14 @@ describe('Colour space conversion', function () { .toFile(fixtures.path('output.greyscale-gamma-2.2.jpg'), done); }); - it('Not to greyscale', function (done) { + it('Not to greyscale', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .greyscale(false) .toFile(fixtures.path('output.greyscale-not.jpg'), done); }); - it('Greyscale with single channel output', function (done) { + it('Greyscale with single channel output', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .greyscale() @@ -53,7 +54,7 @@ describe('Colour space conversion', function () { assert.strictEqual(format, 'webp'); }); - it('From CMYK to sRGB', function (done) { + it('From CMYK to sRGB', function (_t, done) { sharp(fixtures.inputJpgWithCmykProfile) .resize(320) .toBuffer(function (err, data, info) { @@ -65,7 +66,7 @@ describe('Colour space conversion', function () { }); }); - it('From CMYK to sRGB with white background, not yellow', function (done) { + it('From CMYK to sRGB with white background, not yellow', function (_t, done) { sharp(fixtures.inputJpgWithCmykProfile) .resize(320, 240, { fit: sharp.fit.contain, @@ -80,7 +81,7 @@ describe('Colour space conversion', function () { }); }); - it('From profile-less CMYK to sRGB', function (done) { + it('From profile-less CMYK to sRGB', function (_t, done) { sharp(fixtures.inputJpgWithCmykNoProfile) .resize(320) .toBuffer(function (err, data, info) { @@ -120,7 +121,7 @@ describe('Colour space conversion', function () { ); }); - it('CMYK profile to CMYK profile with negate', (done) => { + it('CMYK profile to CMYK profile with negate', (_t, done) => { sharp(fixtures.inputTiffFogra) .resize(320, 240) .toColourspace('cmyk') @@ -141,7 +142,7 @@ describe('Colour space conversion', function () { }); }); - it('From sRGB with RGB16 pipeline, resize with gamma, to sRGB', function (done) { + it('From sRGB with RGB16 pipeline, resize with gamma, to sRGB', function (_t, done) { sharp(fixtures.inputPngGradients) .pipelineColourspace('rgb16') .resize(320) diff --git a/test/unit/composite.js b/test/unit/composite.js index c027b027..c442c829 100644 --- a/test/unit/composite.js +++ b/test/unit/composite.js @@ -1,6 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const fixtures = require('../fixtures'); diff --git a/test/unit/convolve.js b/test/unit/convolve.js index 31b2fb3e..29c7a8f6 100644 --- a/test/unit/convolve.js +++ b/test/unit/convolve.js @@ -1,13 +1,14 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); describe('Convolve', function () { - it('specific convolution kernel 1', function (done) { + it('specific convolution kernel 1', function (_t, done) { sharp(fixtures.inputPngStripesV) .convolve({ width: 3, @@ -29,7 +30,7 @@ describe('Convolve', function () { }); }); - it('specific convolution kernel 2', function (done) { + it('specific convolution kernel 2', function (_t, done) { sharp(fixtures.inputPngStripesH) .convolve({ width: 3, @@ -49,7 +50,7 @@ describe('Convolve', function () { }); }); - it('horizontal Sobel operator', function (done) { + it('horizontal Sobel operator', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .convolve({ diff --git a/test/unit/dilate.js b/test/unit/dilate.js index eb092a14..d3de3b47 100644 --- a/test/unit/dilate.js +++ b/test/unit/dilate.js @@ -1,10 +1,11 @@ +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); describe('Dilate', function () { - it('dilate 1 png', function (done) { + it('dilate 1 png', function (_t, done) { sharp(fixtures.inputPngDotAndLines) .dilate(1) .toBuffer(function (err, data, info) { @@ -16,7 +17,7 @@ describe('Dilate', function () { }); }); - it('dilate 1 png - default width', function (done) { + it('dilate 1 png - default width', function (_t, done) { sharp(fixtures.inputPngDotAndLines) .dilate() .toBuffer(function (err, data, info) { diff --git a/test/unit/erode.js b/test/unit/erode.js index 1a149305..60d10e89 100644 --- a/test/unit/erode.js +++ b/test/unit/erode.js @@ -1,10 +1,11 @@ +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); describe('Erode', function () { - it('erode 1 png', function (done) { + it('erode 1 png', function (_t, done) { sharp(fixtures.inputPngDotAndLines) .erode(1) .toBuffer(function (err, data, info) { @@ -16,7 +17,7 @@ describe('Erode', function () { }); }); - it('erode 1 png - default width', function (done) { + it('erode 1 png - default width', function (_t, done) { sharp(fixtures.inputPngDotAndLines) .erode() .toBuffer(function (err, data, info) { diff --git a/test/unit/extend.js b/test/unit/extend.js index 1c8eb307..c36424d2 100644 --- a/test/unit/extend.js +++ b/test/unit/extend.js @@ -1,6 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); @@ -8,7 +9,7 @@ const fixtures = require('../fixtures'); describe('Extend', function () { describe('extend all sides equally via a single value', function () { - it('JPEG', function (done) { + it('JPEG', function (_t, done) { sharp(fixtures.inputJpg) .resize(120) .extend(10) @@ -20,7 +21,7 @@ describe('Extend', function () { }); }); - it('Animated WebP', function (done) { + it('Animated WebP', function (_t, done) { sharp(fixtures.inputWebPAnimated, { pages: -1 }) .resize(120) .extend(10) @@ -34,7 +35,7 @@ describe('Extend', function () { }); ['background', 'copy', 'mirror', 'repeat'].forEach(extendWith => { - it(`extends all sides with animated WebP (${extendWith})`, function (done) { + it(`extends all sides with animated WebP (${extendWith})`, function (_t, done) { sharp(fixtures.inputWebPAnimated, { pages: -1 }) .resize(120) .extend({ @@ -52,7 +53,7 @@ describe('Extend', function () { }); }); - it(`extend all sides equally with RGB (${extendWith})`, function (done) { + it(`extend all sides equally with RGB (${extendWith})`, function (_t, done) { sharp(fixtures.inputJpg) .resize(120) .extend({ @@ -71,7 +72,7 @@ describe('Extend', function () { }); }); - it(`extend sides unequally with RGBA (${extendWith})`, function (done) { + it(`extend sides unequally with RGBA (${extendWith})`, function (_t, done) { sharp(fixtures.inputPngWithTransparency16bit) .resize(120) .extend({ @@ -89,7 +90,7 @@ describe('Extend', function () { }); }); - it(`PNG with 2 channels (${extendWith})`, function (done) { + it(`PNG with 2 channels (${extendWith})`, function (_t, done) { sharp(fixtures.inputPngWithGreyAlpha) .extend({ extendWith, @@ -188,7 +189,7 @@ describe('Extend', function () { assert.doesNotThrow(() => sharp().extend({ top: 1, left: 2, bottom: 3 })); }); - it('should add alpha channel before extending with a transparent Background', function (done) { + it('should add alpha channel before extending with a transparent Background', function (_t, done) { sharp(fixtures.inputJpgWithLandscapeExif1) .extend({ bottom: 10, diff --git a/test/unit/extract.js b/test/unit/extract.js index 53e4f8a0..d1e14ecb 100644 --- a/test/unit/extract.js +++ b/test/unit/extract.js @@ -1,13 +1,14 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); describe('Partial image extraction', function () { - it('JPEG', function (done) { + it('JPEG', function (_t, done) { sharp(fixtures.inputJpg) .extract({ left: 2, top: 2, width: 20, height: 20 }) .toBuffer(function (err, data, info) { @@ -18,7 +19,7 @@ describe('Partial image extraction', function () { }); }); - it('PNG', function (done) { + it('PNG', function (_t, done) { sharp(fixtures.inputPng) .extract({ left: 200, top: 300, width: 400, height: 200 }) .toBuffer(function (err, data, info) { @@ -29,7 +30,7 @@ describe('Partial image extraction', function () { }); }); - it('WebP', function (done) { + it('WebP', function (_t, done) { sharp(fixtures.inputWebP) .extract({ left: 100, top: 50, width: 125, height: 200 }) .toBuffer(function (err, data, info) { @@ -41,7 +42,7 @@ describe('Partial image extraction', function () { }); describe('Animated WebP', function () { - it('Before resize', function (done) { + it('Before resize', function (_t, done) { sharp(fixtures.inputWebPAnimated, { pages: -1 }) .extract({ left: 0, top: 30, width: 80, height: 20 }) .resize(320, 80) @@ -53,7 +54,7 @@ describe('Partial image extraction', function () { }); }); - it('After resize', function (done) { + it('After resize', function (_t, done) { sharp(fixtures.inputWebPAnimated, { pages: -1 }) .resize(320, 320) .extract({ left: 0, top: 120, width: 320, height: 80 }) @@ -66,7 +67,7 @@ describe('Partial image extraction', function () { }); }); - it('TIFF', function (done) { + it('TIFF', function (_t, done) { sharp(fixtures.inputTiff) .extract({ left: 34, top: 63, width: 341, height: 529 }) .toBuffer(function (err, data, info) { @@ -77,7 +78,7 @@ describe('Partial image extraction', function () { }); }); - it('Before resize', function (done) { + it('Before resize', function (_t, done) { sharp(fixtures.inputJpg) .extract({ left: 10, top: 10, width: 10, height: 500 }) .resize(100, 100) @@ -89,7 +90,7 @@ describe('Partial image extraction', function () { }); }); - it('After resize and crop', function (done) { + it('After resize and crop', function (_t, done) { sharp(fixtures.inputJpg) .resize(500, 500, { position: sharp.gravity.north @@ -103,7 +104,7 @@ describe('Partial image extraction', function () { }); }); - it('Before and after resize and crop', function (done) { + it('Before and after resize and crop', function (_t, done) { sharp(fixtures.inputJpg) .extract({ left: 0, top: 0, width: 700, height: 700 }) .resize(500, 500, { @@ -118,7 +119,7 @@ describe('Partial image extraction', function () { }); }); - it('Extract then rotate', function (done) { + it('Extract then rotate', function (_t, done) { sharp(fixtures.inputPngWithGreyAlpha) .extract({ left: 20, top: 10, width: 380, height: 280 }) .rotate(90) @@ -131,7 +132,7 @@ describe('Partial image extraction', function () { }); }); - it('Rotate then extract', function (done) { + it('Rotate then extract', function (_t, done) { sharp(fixtures.inputPngWithGreyAlpha) .rotate(90) .extract({ left: 20, top: 10, width: 280, height: 380 }) @@ -143,7 +144,7 @@ describe('Partial image extraction', function () { }); }); - it('Extract then rotate then extract', function (done) { + it('Extract then rotate then extract', function (_t, done) { sharp(fixtures.inputPngWithGreyAlpha) .extract({ left: 20, top: 10, width: 180, height: 280 }) .rotate(90) @@ -156,7 +157,7 @@ describe('Partial image extraction', function () { }); }); - it('Extract then rotate non-90 anagle', function (done) { + it('Extract then rotate non-90 anagle', function (_t, done) { sharp(fixtures.inputPngWithGreyAlpha) .extract({ left: 20, top: 10, width: 380, height: 280 }) .rotate(45) @@ -169,7 +170,7 @@ describe('Partial image extraction', function () { }); }); - it('Rotate then extract non-90 angle', function (done) { + it('Rotate then extract non-90 angle', function (_t, done) { sharp(fixtures.inputPngWithGreyAlpha) .rotate(45) .extract({ left: 20, top: 10, width: 380, height: 280 }) @@ -217,7 +218,7 @@ describe('Partial image extraction', function () { image: fixtures.inputJpgWithLandscapeExif8 } ].forEach(({ name, image }) => { - it(name, function (done) { + it(name, function (_t, done) { sharp(image) .rotate() .extract({ left: 0, top: 208, width: 60, height: 40 }) @@ -286,7 +287,7 @@ describe('Partial image extraction', function () { }); }); - it('Bad image area', function (done) { + it('Bad image area', function (_t, done) { sharp(fixtures.inputJpg) .extract({ left: 3000, top: 10, width: 10, height: 10 }) .toBuffer(function (err) { diff --git a/test/unit/extractChannel.js b/test/unit/extractChannel.js index edb3978c..4f05c1ac 100644 --- a/test/unit/extractChannel.js +++ b/test/unit/extractChannel.js @@ -1,13 +1,14 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); describe('Image channel extraction', function () { - it('Red channel', function (done) { + it('Red channel', function (_t, done) { sharp(fixtures.inputJpg) .extractChannel('red') .resize(320, 240) @@ -19,7 +20,7 @@ describe('Image channel extraction', function () { }); }); - it('Green channel', function (done) { + it('Green channel', function (_t, done) { sharp(fixtures.inputJpg) .extractChannel('green') .resize(320, 240) @@ -31,7 +32,7 @@ describe('Image channel extraction', function () { }); }); - it('Blue channel', function (done) { + it('Blue channel', function (_t, done) { sharp(fixtures.inputJpg) .extractChannel('blue') .resize(320, 240) @@ -43,7 +44,7 @@ describe('Image channel extraction', function () { }); }); - it('Blue channel by number', function (done) { + it('Blue channel by number', function (_t, done) { sharp(fixtures.inputJpg) .extractChannel(2) .resize(320, 240) @@ -64,7 +65,7 @@ describe('Image channel extraction', function () { assert.strictEqual(chroma, 104); }); - it('Alpha from 16-bit PNG', function (done) { + it('Alpha from 16-bit PNG', function (_t, done) { const output = fixtures.path('output.extract-alpha-16bit.png'); sharp(fixtures.inputPngWithTransparency16bit) .resize(16) @@ -76,7 +77,7 @@ describe('Image channel extraction', function () { }); }); - it('Alpha from 2-channel input', function (done) { + it('Alpha from 2-channel input', function (_t, done) { const output = fixtures.path('output.extract-alpha-2-channel.png'); sharp(fixtures.inputPngWithGreyAlpha) .extractChannel('alpha') diff --git a/test/unit/failOn.js b/test/unit/failOn.js index 48e758c0..3e0dbabf 100644 --- a/test/unit/failOn.js +++ b/test/unit/failOn.js @@ -1,6 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const fs = require('node:fs'); @@ -8,7 +9,7 @@ const sharp = require('../../lib'); const fixtures = require('../fixtures'); describe('failOn', () => { - it('handles truncated JPEG', function (done) { + it('handles truncated JPEG', function (_t, done) { sharp(fixtures.inputJpgTruncated, { failOn: 'none' }) .resize(32, 24) .toBuffer(function (err, data, info) { @@ -20,7 +21,7 @@ describe('failOn', () => { }); }); - it('handles truncated PNG, emits warnings', function (done) { + it('handles truncated PNG, emits warnings', function (_t, done) { let isWarningEmitted = false; sharp(fixtures.inputPngTruncated, { failOn: 'none' }) .on('warning', function (warning) { @@ -68,7 +69,7 @@ describe('failOn', () => { ); }); - it('returns errors to callback for truncated JPEG', function (done) { + it('returns errors to callback for truncated JPEG', function (_t, done) { sharp(fixtures.inputJpgTruncated, { failOn: 'truncated' }).toBuffer(function (err, data, info) { assert.ok(err.message.includes('VipsJpeg: premature end of'), err); assert.strictEqual(data, undefined); @@ -77,7 +78,7 @@ describe('failOn', () => { }); }); - it('returns errors to callback for truncated PNG', function (done) { + it('returns errors to callback for truncated PNG', function (_t, done) { sharp(fixtures.inputPngTruncated, { failOn: 'truncated' }).toBuffer(function (err, data, info) { assert.ok(err.message.includes('read error'), err); assert.strictEqual(data, undefined); @@ -86,7 +87,7 @@ describe('failOn', () => { }); }); - it('rejects promises for truncated JPEG', function (done) { + it('rejects promises for truncated JPEG', function (_t, done) { sharp(fixtures.inputJpgTruncated, { failOn: 'error' }) .toBuffer() .then(() => { diff --git a/test/unit/fixtures.js b/test/unit/fixtures.js index ee398958..ca975627 100644 --- a/test/unit/fixtures.js +++ b/test/unit/fixtures.js @@ -1,6 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const fixtures = require('../fixtures'); diff --git a/test/unit/gamma.js b/test/unit/gamma.js index 21a33343..b58567c7 100644 --- a/test/unit/gamma.js +++ b/test/unit/gamma.js @@ -1,13 +1,14 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); describe('Gamma correction', function () { - it('value of 0.0 (disabled)', function (done) { + it('value of 0.0 (disabled)', function (_t, done) { sharp(fixtures.inputJpgWithGammaHoliness) .resize(129, 111) .toBuffer(function (err, data, info) { @@ -19,7 +20,7 @@ describe('Gamma correction', function () { }); }); - it('value of 2.2 (default)', function (done) { + it('value of 2.2 (default)', function (_t, done) { sharp(fixtures.inputJpgWithGammaHoliness) .resize(129, 111) .gamma() @@ -32,7 +33,7 @@ describe('Gamma correction', function () { }); }); - it('value of 3.0', function (done) { + it('value of 3.0', function (_t, done) { sharp(fixtures.inputJpgWithGammaHoliness) .resize(129, 111) .gamma(3) @@ -45,7 +46,7 @@ describe('Gamma correction', function () { }); }); - it('input value of 2.2, output value of 3.0', function (done) { + it('input value of 2.2, output value of 3.0', function (_t, done) { sharp(fixtures.inputJpgWithGammaHoliness) .resize(129, 111) .gamma(2.2, 3.0) @@ -58,7 +59,7 @@ describe('Gamma correction', function () { }); }); - it('alpha transparency', function (done) { + it('alpha transparency', function (_t, done) { sharp(fixtures.inputPngOverlayLayer1) .resize(320) .gamma() diff --git a/test/unit/gif.js b/test/unit/gif.js index 8ae20e95..4921be72 100644 --- a/test/unit/gif.js +++ b/test/unit/gif.js @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 const fs = require('node:fs'); +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); @@ -196,7 +197,7 @@ describe('GIF input', () => { ); }); - it('should work with streams when only animated is set', function (done) { + it('should work with streams when only animated is set', function (_t, done) { fs.createReadStream(fixtures.inputGifAnimated) .pipe(sharp({ animated: true })) .gif() @@ -208,7 +209,7 @@ describe('GIF input', () => { }); }); - it('should work with streams when only pages is set', function (done) { + it('should work with streams when only pages is set', function (_t, done) { fs.createReadStream(fixtures.inputGifAnimated) .pipe(sharp({ pages: -1 })) .gif() diff --git a/test/unit/heif.js b/test/unit/heif.js index af3ee62e..9cb5355b 100644 --- a/test/unit/heif.js +++ b/test/unit/heif.js @@ -1,6 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); diff --git a/test/unit/io.js b/test/unit/io.js index ed6decaf..75a7959f 100644 --- a/test/unit/io.js +++ b/test/unit/io.js @@ -3,6 +3,7 @@ const fs = require('node:fs'); const path = require('node:path'); +const { afterEach, beforeEach, describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); @@ -18,7 +19,7 @@ describe('Input/output', function () { sharp.cache(true); }); - it('Read from File and write to Stream', function (done) { + it('Read from File and write to Stream', function (_t, done) { const writable = fs.createWriteStream(outputJpg); writable.on('close', function () { sharp(outputJpg).toBuffer(function (err, data, info) { @@ -34,7 +35,7 @@ describe('Input/output', function () { sharp(fixtures.inputJpg).resize(320, 240).pipe(writable); }); - it('Read from Buffer and write to Stream', function (done) { + it('Read from Buffer and write to Stream', function (_t, done) { const inputJpgBuffer = fs.readFileSync(fixtures.inputJpg); const writable = fs.createWriteStream(outputJpg); writable.on('close', function () { @@ -51,7 +52,7 @@ describe('Input/output', function () { sharp(inputJpgBuffer).resize(320, 240).pipe(writable); }); - it('Read from Stream and write to File', function (done) { + it('Read from Stream and write to File', function (_t, done) { const readable = fs.createReadStream(fixtures.inputJpg); const pipeline = sharp().resize(320, 240).toFile(outputJpg, function (err, info) { if (err) throw err; @@ -64,7 +65,7 @@ describe('Input/output', function () { readable.pipe(pipeline); }); - it('Read from Stream and write to Buffer', function (done) { + it('Read from Stream and write to Buffer', function (_t, done) { const readable = fs.createReadStream(fixtures.inputJpg); const pipeline = sharp().resize(320, 240).toBuffer(function (err, data, info) { if (err) throw err; @@ -132,7 +133,7 @@ describe('Input/output', function () { }); }); - it('Read from Stream and write to Stream', function (done) { + it('Read from Stream and write to Stream', function (_t, done) { const readable = fs.createReadStream(fixtures.inputJpg); const writable = fs.createWriteStream(outputJpg); writable.on('close', function () { @@ -217,7 +218,7 @@ describe('Input/output', function () { assert.strictEqual(info.height, 1); }); - it('Stream should emit info event', function (done) { + it('Stream should emit info event', function (_t, done) { const readable = fs.createReadStream(fixtures.inputJpg); const writable = fs.createWriteStream(outputJpg); const pipeline = sharp().resize(320, 240); @@ -236,7 +237,7 @@ describe('Input/output', function () { readable.pipe(pipeline).pipe(writable); }); - it('Stream should emit close event', function (done) { + it('Stream should emit close event', function (_t, done) { const readable = fs.createReadStream(fixtures.inputJpg); const writable = fs.createWriteStream(outputJpg); const pipeline = sharp().resize(320, 240); @@ -251,7 +252,7 @@ describe('Input/output', function () { readable.pipe(pipeline).pipe(writable); }); - it('Handle Stream to Stream error ', function (done) { + it('Handle Stream to Stream error ', function (_t, done) { const pipeline = sharp().resize(320, 240); let anErrorWasEmitted = false; pipeline.on('error', function (err) { @@ -265,7 +266,7 @@ describe('Input/output', function () { readableButNotAnImage.pipe(pipeline).pipe(writable); }); - it('Handle File to Stream error', function (done) { + it('Handle File to Stream error', function (_t, done) { const readableButNotAnImage = sharp(__filename).resize(320, 240); let anErrorWasEmitted = false; readableButNotAnImage.on('error', function (err) { @@ -278,7 +279,7 @@ describe('Input/output', function () { readableButNotAnImage.pipe(writable); }); - it('Readable side of Stream can start flowing after Writable side has finished', function (done) { + it('Readable side of Stream can start flowing after Writable side has finished', function (_t, done) { const readable = fs.createReadStream(fixtures.inputJpg); const writable = fs.createWriteStream(outputJpg); writable.on('close', function () { @@ -299,6 +300,20 @@ describe('Input/output', function () { }); }); + it('Non-Stream input generates error when provided Stream-like data', (_t, done) => { + sharp('input')._write('fail', null, (err) => { + assert.strictEqual(err.message, 'Unexpected data on Writable Stream'); + done(); + }); + }); + + it('Non-Buffer chunk on Stream input generates error', (_t, done) => { + sharp()._write('fail', null, (err) => { + assert.strictEqual(err.message, 'Non-Buffer data on Writable Stream'); + done(); + }); + }); + it('Invalid sequential read option throws', () => { assert.throws(() => { sharp({ sequentialRead: 'fail' }); @@ -333,7 +348,7 @@ describe('Input/output', function () { }) ); - it('Support output to jpg format', function (done) { + it('Support output to jpg format', function (_t, done) { sharp(fixtures.inputPng) .resize(320, 240) .toFormat('jpg') @@ -348,7 +363,7 @@ describe('Input/output', function () { }); }); - it('Support output to tif format', function (done) { + it('Support output to tif format', function (_t, done) { sharp(fixtures.inputTiff) .resize(320, 240) .toFormat('tif') @@ -377,7 +392,7 @@ describe('Input/output', function () { assert.strictEqual(Buffer.isBuffer(data), true); }); - it('Fail when output File is input File', function (done) { + it('Fail when output File is input File', function (_t, done) { sharp(fixtures.inputJpg).toFile(fixtures.inputJpg, function (err) { assert(err instanceof Error); assert.strictEqual('Cannot use same file for input and output', err.message); @@ -385,7 +400,7 @@ describe('Input/output', function () { }); }); - it('Fail when output File is input File via Promise', function (done) { + it('Fail when output File is input File via Promise', function (_t, done) { sharp(fixtures.inputJpg).toFile(fixtures.inputJpg).then(function () { done(new Error('Unexpectedly resolved Promise')); }).catch(function (err) { @@ -395,7 +410,7 @@ describe('Input/output', function () { }); }); - it('Fail when output File is input File (relative output, absolute input)', function (done) { + it('Fail when output File is input File (relative output, absolute input)', function (_t, done) { const relativePath = path.relative(process.cwd(), fixtures.inputJpg); sharp(fixtures.inputJpg).toFile(relativePath, function (err) { assert(err instanceof Error); @@ -404,7 +419,7 @@ describe('Input/output', function () { }); }); - it('Fail when output File is input File via Promise (relative output, absolute input)', function (done) { + it('Fail when output File is input File via Promise (relative output, absolute input)', function (_t, done) { const relativePath = path.relative(process.cwd(), fixtures.inputJpg); sharp(fixtures.inputJpg).toFile(relativePath).then(function () { done(new Error('Unexpectedly resolved Promise')); @@ -415,7 +430,7 @@ describe('Input/output', function () { }); }); - it('Fail when output File is input File (relative input, absolute output)', function (done) { + it('Fail when output File is input File (relative input, absolute output)', function (_t, done) { const relativePath = path.relative(process.cwd(), fixtures.inputJpg); sharp(relativePath).toFile(fixtures.inputJpg, function (err) { assert(err instanceof Error); @@ -424,7 +439,7 @@ describe('Input/output', function () { }); }); - it('Fail when output File is input File via Promise (relative input, absolute output)', function (done) { + it('Fail when output File is input File via Promise (relative input, absolute output)', function (_t, done) { const relativePath = path.relative(process.cwd(), fixtures.inputJpg); sharp(relativePath).toFile(fixtures.inputJpg).then(function () { done(new Error('Unexpectedly resolved Promise')); @@ -435,7 +450,7 @@ describe('Input/output', function () { }); }); - it('Fail when output File is empty', function (done) { + it('Fail when output File is empty', function (_t, done) { sharp(fixtures.inputJpg).toFile('', function (err) { assert(err instanceof Error); assert.strictEqual('Missing output file path', err.message); @@ -443,7 +458,7 @@ describe('Input/output', function () { }); }); - it('Fail when output File is empty via Promise', function (done) { + it('Fail when output File is empty via Promise', function (_t, done) { sharp(fixtures.inputJpg).toFile('').then(function () { done(new Error('Unexpectedly resolved Promise')); }).catch(function (err) { @@ -511,7 +526,7 @@ describe('Input/output', function () { .toBuffer(); }); - it('Invalid output format', function (done) { + it('Invalid output format', function (_t, done) { let isValid = false; try { sharp().toFormat('zoinks'); @@ -521,7 +536,7 @@ describe('Input/output', function () { done(); }); - it('File input with corrupt header fails gracefully', function (done) { + it('File input with corrupt header fails gracefully', function (_t, done) { sharp(fixtures.inputJpgWithCorruptHeader) .toBuffer(function (err) { assert.strictEqual(true, !!err); @@ -529,7 +544,7 @@ describe('Input/output', function () { }); }); - it('Buffer input with corrupt header fails gracefully', function (done) { + it('Buffer input with corrupt header fails gracefully', function (_t, done) { sharp(fs.readFileSync(fixtures.inputJpgWithCorruptHeader)) .toBuffer(function (err) { assert.strictEqual(true, !!err); @@ -537,7 +552,7 @@ describe('Input/output', function () { }); }); - it('Stream input with corrupt header fails gracefully', function (done) { + it('Stream input with corrupt header fails gracefully', function (_t, done) { const transformer = sharp(); transformer .toBuffer() @@ -556,7 +571,7 @@ describe('Input/output', function () { describe('Output filename with unknown extension', function () { const outputZoinks = fixtures.path('output.zoinks'); - it('Match JPEG input', function (done) { + it('Match JPEG input', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 80) .toFile(outputZoinks, function (err, info) { @@ -569,7 +584,7 @@ describe('Input/output', function () { }); }); - it('Match PNG input', function (done) { + it('Match PNG input', function (_t, done) { sharp(fixtures.inputPng) .resize(320, 80) .toFile(outputZoinks, function (err, info) { @@ -582,7 +597,7 @@ describe('Input/output', function () { }); }); - it('Match WebP input', function (done) { + it('Match WebP input', function (_t, done) { sharp(fixtures.inputWebP) .resize(320, 80) .toFile(outputZoinks, function (err, info) { @@ -595,7 +610,7 @@ describe('Input/output', function () { }); }); - it('Match TIFF input', function (done) { + it('Match TIFF input', function (_t, done) { sharp(fixtures.inputTiff) .resize(320, 80) .toFile(outputZoinks, function (err, info) { @@ -608,7 +623,7 @@ describe('Input/output', function () { }); }); - it('Force JPEG format for PNG input', function (done) { + it('Force JPEG format for PNG input', function (_t, done) { sharp(fixtures.inputPng) .resize(320, 80) .jpeg() @@ -623,7 +638,7 @@ describe('Input/output', function () { }); }); - it('Input and output formats match when not forcing', function (done) { + it('Input and output formats match when not forcing', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .png({ compressionLevel: 1, force: false }) @@ -647,7 +662,7 @@ describe('Input/output', function () { }); }); - it('toFormat=JPEG takes precedence over WebP extension', function (done) { + it('toFormat=JPEG takes precedence over WebP extension', function (_t, done) { const outputWebP = fixtures.path('output.webp'); sharp(fixtures.inputPng) .resize(8) @@ -659,7 +674,7 @@ describe('Input/output', function () { }); }); - it('toFormat=WebP takes precedence over JPEG extension', function (done) { + it('toFormat=WebP takes precedence over JPEG extension', function (_t, done) { sharp(fixtures.inputPng) .resize(8) .webp() @@ -670,7 +685,7 @@ describe('Input/output', function () { }); }); - it('Load Vips V file', function (done) { + it('Load Vips V file', function (_t, done) { sharp(fixtures.inputV) .jpeg() .toBuffer(function (err, data, info) { @@ -683,7 +698,7 @@ describe('Input/output', function () { }); }); - it('Save Vips V file', function (done) { + it('Save Vips V file', function (_t, done) { const outputV = fixtures.path('output.v'); sharp(fixtures.inputJpg) .extract({ left: 910, top: 1105, width: 70, height: 60 }) @@ -963,7 +978,7 @@ describe('Input/output', function () { }); describe('create new image', function () { - it('RGB', function (done) { + it('RGB', function (_t, done) { const create = { width: 10, height: 20, @@ -981,7 +996,7 @@ describe('Input/output', function () { fixtures.assertSimilar(fixtures.expected('create-rgb.jpg'), data, done); }); }); - it('RGBA', function (done) { + it('RGBA', function (_t, done) { const create = { width: 20, height: 10, @@ -1022,7 +1037,7 @@ describe('Input/output', function () { }); }); - it('Queue length change events', function (done) { + it('Queue length change events', function (_t, done) { let eventCounter = 0; const queueListener = function (queueLength) { assert.strictEqual(true, queueLength === 0 || queueLength === 1); @@ -1041,7 +1056,7 @@ describe('Input/output', function () { }); }); - it('Info event data', function (done) { + it('Info event data', function (_t, done) { const readable = fs.createReadStream(fixtures.inputJPGBig); const inPipeline = sharp() .resize(840, 472) diff --git a/test/unit/join.js b/test/unit/join.js index 600ffb9a..6538346f 100644 --- a/test/unit/join.js +++ b/test/unit/join.js @@ -1,6 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); diff --git a/test/unit/joinChannel.js b/test/unit/joinChannel.js index 42bc2383..814565eb 100644 --- a/test/unit/joinChannel.js +++ b/test/unit/joinChannel.js @@ -1,6 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const fs = require('node:fs'); @@ -8,7 +9,7 @@ const sharp = require('../../'); const fixtures = require('../fixtures'); describe('Image channel insertion', function () { - it('Grayscale to RGB, buffer', function (done) { + it('Grayscale to RGB, buffer', function (_t, done) { sharp(fixtures.inputPng) // gray -> red .resize(320, 240) .joinChannel(fixtures.inputPngTestJoinChannel) // new green channel @@ -22,7 +23,7 @@ describe('Image channel insertion', function () { }); }); - it('Grayscale to RGB, file', function (done) { + it('Grayscale to RGB, file', function (_t, done) { sharp(fixtures.inputPng) // gray -> red .resize(320, 240) .joinChannel(fs.readFileSync(fixtures.inputPngTestJoinChannel)) // new green channel @@ -36,7 +37,7 @@ describe('Image channel insertion', function () { }); }); - it('Grayscale to RGBA, buffer', function (done) { + it('Grayscale to RGBA, buffer', function (_t, done) { sharp(fixtures.inputPng) // gray -> red .resize(320, 240) .joinChannel([ @@ -54,7 +55,7 @@ describe('Image channel insertion', function () { }); }); - it('Grayscale to RGBA, file', function (done) { + it('Grayscale to RGBA, file', function (_t, done) { sharp(fixtures.inputPng) // gray -> red .resize(320, 240) .joinChannel([ @@ -72,7 +73,7 @@ describe('Image channel insertion', function () { }); }); - it('Grayscale to CMYK, buffers', function (done) { + it('Grayscale to CMYK, buffers', function (_t, done) { sharp(fixtures.inputPng) // gray -> magenta .resize(320, 240) .joinChannel([ @@ -91,7 +92,7 @@ describe('Image channel insertion', function () { }); }); - it('Join raw buffers to RGB', function (done) { + it('Join raw buffers to RGB', function (_t, done) { Promise.all([ sharp(fixtures.inputPngTestJoinChannel).toColourspace('b-w').raw().toBuffer(), sharp(fixtures.inputPngStripesH).toColourspace('b-w').raw().toBuffer() @@ -119,7 +120,7 @@ describe('Image channel insertion', function () { }); }); - it('Grayscale to RGBA, files, two arrays', function (done) { + it('Grayscale to RGBA, files, two arrays', function (_t, done) { sharp(fixtures.inputPng) // gray -> red .resize(320, 240) .joinChannel([fs.readFileSync(fixtures.inputPngTestJoinChannel)]) // new green channel diff --git a/test/unit/jp2.js b/test/unit/jp2.js index 30b458ac..3445c90f 100644 --- a/test/unit/jp2.js +++ b/test/unit/jp2.js @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 const fs = require('node:fs'); +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); diff --git a/test/unit/jpeg.js b/test/unit/jpeg.js index 916d2358..0954439e 100644 --- a/test/unit/jpeg.js +++ b/test/unit/jpeg.js @@ -1,13 +1,14 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); describe('JPEG', function () { - it('JPEG quality', function (done) { + it('JPEG quality', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .jpeg({ quality: 70 }) @@ -50,7 +51,7 @@ describe('JPEG', function () { }); }); - it('Progressive JPEG image', function (done) { + it('Progressive JPEG image', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .jpeg({ progressive: false }) @@ -77,7 +78,7 @@ describe('JPEG', function () { }); }); - it('Without chroma subsampling generates larger file', function (done) { + it('Without chroma subsampling generates larger file', function (_t, done) { // First generate with chroma subsampling (default) sharp(fixtures.inputJpg) .resize(320, 240) @@ -112,7 +113,7 @@ describe('JPEG', function () { }); }); - it('Trellis quantisation', function (done) { + it('Trellis quantisation', function (_t, done) { // First generate without sharp(fixtures.inputJpg) .resize(320, 240) @@ -142,7 +143,7 @@ describe('JPEG', function () { }); }); - it('Overshoot deringing', function (done) { + it('Overshoot deringing', function (_t, done) { // First generate without sharp(fixtures.inputJpg) .resize(320, 240) @@ -170,7 +171,7 @@ describe('JPEG', function () { }); }); - it('Optimise scans generates different output length', function (done) { + it('Optimise scans generates different output length', function (_t, done) { // First generate without sharp(fixtures.inputJpg) .resize(320, 240) @@ -200,7 +201,7 @@ describe('JPEG', function () { }); }); - it('Optimise coding generates smaller output length', function (done) { + it('Optimise coding generates smaller output length', function (_t, done) { // First generate with optimize coding enabled (default) sharp(fixtures.inputJpg) .resize(320, 240) @@ -230,7 +231,7 @@ describe('JPEG', function () { }); }); - it('Specifying quantisation table provides different JPEG', function (done) { + it('Specifying quantisation table provides different JPEG', function (_t, done) { // First generate with default quantisation table sharp(fixtures.inputJpg) .resize(320, 240) @@ -261,7 +262,7 @@ describe('JPEG', function () { }); }); - it('Specifying quantization table provides different JPEG', function (done) { + it('Specifying quantization table provides different JPEG', function (_t, done) { // First generate with default quantization table sharp(fixtures.inputJpg) .resize(320, 240) diff --git a/test/unit/jxl.js b/test/unit/jxl.js index 7fcfd75f..20af7de0 100644 --- a/test/unit/jxl.js +++ b/test/unit/jxl.js @@ -1,6 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); diff --git a/test/unit/libvips.js b/test/unit/libvips.js index dfd61b26..79f70dc4 100644 --- a/test/unit/libvips.js +++ b/test/unit/libvips.js @@ -1,6 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { after, before, describe, it } = require('node:test'); const assert = require('node:assert'); const fs = require('node:fs'); const semver = require('semver'); @@ -152,7 +153,7 @@ describe('libvips binaries', function () { console.error = consoleError; }); - it('logs an info message', function (done) { + it('logs an info message', function (_t, done) { console.log = function (msg) { assert.strictEqual(msg, 'sharp: progress'); done(); @@ -160,7 +161,7 @@ describe('libvips binaries', function () { libvips.log('progress'); }); - it('logs an error message', function (done) { + it('logs an error message', function (_t, done) { console.error = function (msg) { assert.strictEqual(msg, 'sharp: Installation error: problem'); done(); diff --git a/test/unit/linear.js b/test/unit/linear.js index 0ac952f2..dba44a2e 100644 --- a/test/unit/linear.js +++ b/test/unit/linear.js @@ -4,6 +4,7 @@ const sharp = require('../../'); const fixtures = require('../fixtures'); +const { describe, it } = require('node:test'); const assert = require('node:assert'); describe('Linear adjustment', function () { @@ -12,7 +13,7 @@ describe('Linear adjustment', function () { const a = 255 / (whitePoint - blackPoint); const b = -blackPoint * a; - it('applies linear levels adjustment w/o alpha ch', function (done) { + it('applies linear levels adjustment w/o alpha ch', function (_t, done) { sharp(fixtures.inputJpgWithLowContrast) .linear(a, b) .toBuffer(function (err, data) { @@ -21,7 +22,7 @@ describe('Linear adjustment', function () { }); }); - it('applies slope level adjustment w/o alpha ch', function (done) { + it('applies slope level adjustment w/o alpha ch', function (_t, done) { sharp(fixtures.inputJpgWithLowContrast) .linear(a) .toBuffer(function (err, data) { @@ -30,7 +31,7 @@ describe('Linear adjustment', function () { }); }); - it('applies offset level adjustment w/o alpha ch', function (done) { + it('applies offset level adjustment w/o alpha ch', function (_t, done) { sharp(fixtures.inputJpgWithLowContrast) .linear(null, b) .toBuffer(function (err, data) { @@ -39,7 +40,7 @@ describe('Linear adjustment', function () { }); }); - it('applies linear levels adjustment w alpha ch', function (done) { + it('applies linear levels adjustment w alpha ch', function (_t, done) { sharp(fixtures.inputPngOverlayLayer1) .resize(240) .linear(a, b) @@ -49,7 +50,7 @@ describe('Linear adjustment', function () { }); }); - it('applies linear levels adjustment to 16-bit w alpha ch', function (done) { + it('applies linear levels adjustment to 16-bit w alpha ch', function (_t, done) { sharp(fixtures.inputPngWithTransparency16bit) .linear(a, b) .png({ compressionLevel: 0 }) @@ -59,7 +60,7 @@ describe('Linear adjustment', function () { }); }); - it('applies slope level adjustment w alpha ch', function (done) { + it('applies slope level adjustment w alpha ch', function (_t, done) { sharp(fixtures.inputPngOverlayLayer1) .resize(240) .linear(a) @@ -69,7 +70,7 @@ describe('Linear adjustment', function () { }); }); - it('applies offset level adjustment w alpha ch', function (done) { + it('applies offset level adjustment w alpha ch', function (_t, done) { sharp(fixtures.inputPngOverlayLayer1) .resize(240) .linear(null, b) @@ -79,7 +80,7 @@ describe('Linear adjustment', function () { }); }); - it('per channel level adjustment', function (done) { + it('per channel level adjustment', function (_t, done) { sharp(fixtures.inputWebP) .linear([0.25, 0.5, 0.75], [150, 100, 50]).toBuffer(function (err, data) { if (err) throw err; diff --git a/test/unit/median.js b/test/unit/median.js index 227e4c60..5a2f6b3d 100644 --- a/test/unit/median.js +++ b/test/unit/median.js @@ -1,6 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); diff --git a/test/unit/metadata.js b/test/unit/metadata.js index 4b3ee6c5..73875a54 100644 --- a/test/unit/metadata.js +++ b/test/unit/metadata.js @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 const fs = require('node:fs'); +const { describe, it } = require('node:test'); const assert = require('node:assert'); const exifReader = require('exif-reader'); const icc = require('icc'); @@ -12,7 +13,7 @@ const fixtures = require('../fixtures'); const create = { width: 1, height: 1, channels: 3, background: 'red' }; describe('Image metadata', function () { - it('JPEG', function (done) { + it('JPEG', function (_t, done) { sharp(fixtures.inputJpg).metadata(function (err, metadata) { if (err) throw err; assert.strictEqual('jpeg', metadata.format); @@ -34,7 +35,7 @@ describe('Image metadata', function () { }); }); - it('JPEG with EXIF/ICC', function (done) { + it('JPEG with EXIF/ICC', function (_t, done) { sharp(fixtures.inputJpgWithExif).metadata(function (err, metadata) { if (err) throw err; assert.strictEqual('jpeg', metadata.format); @@ -67,7 +68,7 @@ describe('Image metadata', function () { }); }); - it('JPEG with IPTC/XMP', function (done) { + it('JPEG with IPTC/XMP', function (_t, done) { sharp(fixtures.inputJpgWithIptcAndXmp).metadata(function (err, metadata) { if (err) throw err; // IPTC @@ -85,7 +86,7 @@ describe('Image metadata', function () { }); }); - it('TIFF', function (done) { + it('TIFF', function (_t, done) { sharp(fixtures.inputTiff).metadata(function (err, metadata) { if (err) throw err; assert.strictEqual('tiff', metadata.format); @@ -112,7 +113,7 @@ describe('Image metadata', function () { }); }); - it('Multipage TIFF', function (done) { + it('Multipage TIFF', function (_t, done) { sharp(fixtures.inputTiffMultipage).metadata(function (err, metadata) { if (err) throw err; assert.strictEqual('tiff', metadata.format); @@ -135,7 +136,7 @@ describe('Image metadata', function () { }); }); - it('PNG', function (done) { + it('PNG', function (_t, done) { sharp(fixtures.inputPng).metadata(function (err, metadata) { if (err) throw err; assert.strictEqual('png', metadata.format); @@ -159,7 +160,7 @@ describe('Image metadata', function () { }); }); - it('PNG with comment', function (done) { + it('PNG with comment', function (_t, done) { sharp(fixtures.inputPngTestJoinChannel).metadata(function (err, metadata) { if (err) throw err; assert.strictEqual('png', metadata.format); @@ -184,7 +185,7 @@ describe('Image metadata', function () { }); }); - it('Transparent PNG', function (done) { + it('Transparent PNG', function (_t, done) { sharp(fixtures.inputPngWithTransparency).metadata(function (err, metadata) { if (err) throw err; assert.strictEqual('png', metadata.format); @@ -256,7 +257,7 @@ describe('Image metadata', function () { }); }); - it('WebP', function (done) { + it('WebP', function (_t, done) { sharp(fixtures.inputWebP).metadata(function (err, metadata) { if (err) throw err; assert.strictEqual('webp', metadata.format); @@ -348,7 +349,7 @@ describe('Image metadata', function () { }) ); - it('GIF', function (done) { + it('GIF', function (_t, done) { sharp(fixtures.inputGif).metadata(function (err, metadata) { if (err) throw err; assert.strictEqual('gif', metadata.format); @@ -368,7 +369,7 @@ describe('Image metadata', function () { done(); }); }); - it('GIF grey+alpha', function (done) { + it('GIF grey+alpha', function (_t, done) { sharp(fixtures.inputGifGreyPlusAlpha).metadata(function (err, metadata) { if (err) throw err; assert.strictEqual('gif', metadata.format); @@ -456,7 +457,7 @@ describe('Image metadata', function () { }) ); - it('File in, Promise out', function (done) { + it('File in, Promise out', function (_t, done) { sharp(fixtures.inputJpg).metadata().then(function (metadata) { assert.strictEqual('jpeg', metadata.format); assert.strictEqual('undefined', typeof metadata.size); @@ -489,7 +490,7 @@ describe('Image metadata', function () { ) ); - it('Invalid stream in, callback out', (done) => { + it('Invalid stream in, callback out', (_t, done) => { fs.createReadStream(__filename).pipe( sharp().metadata((err) => { assert.strictEqual(err.message, 'Input buffer contains unsupported image format'); @@ -500,7 +501,7 @@ describe('Image metadata', function () { ); }); - it('Stream in, Promise out', function (done) { + it('Stream in, Promise out', function (_t, done) { const readable = fs.createReadStream(fixtures.inputJpg); const pipeline = sharp(); pipeline.metadata().then(function (metadata) { @@ -520,7 +521,7 @@ describe('Image metadata', function () { assert.strictEqual('undefined', typeof metadata.exif); assert.strictEqual('undefined', typeof metadata.icc); done(); - }).catch(done); + }).catch(_t, done); readable.pipe(pipeline); }); @@ -538,7 +539,7 @@ describe('Image metadata', function () { ); }); - it('Stream in, finish event fires before metadata is requested', (done) => { + it('Stream in, finish event fires before metadata is requested', (_t, done) => { const create = { width: 1, height: 1, channels: 3, background: 'red' }; const image1 = sharp({ create }).png().pipe(sharp()); const image2 = sharp({ create }).png().pipe(sharp()); @@ -551,7 +552,7 @@ describe('Image metadata', function () { }, 500); }); - it('Stream', function (done) { + it('Stream', function (_t, done) { const readable = fs.createReadStream(fixtures.inputJpg); const pipeline = sharp().metadata(function (err, metadata) { if (err) throw err; @@ -575,7 +576,7 @@ describe('Image metadata', function () { readable.pipe(pipeline); }); - it('Resize to half width using metadata', function (done) { + it('Resize to half width using metadata', function (_t, done) { const image = sharp(fixtures.inputJpg); image.metadata(function (err, metadata) { if (err) throw err; @@ -604,7 +605,7 @@ describe('Image metadata', function () { }); }); - it('Keep EXIF metadata and add sRGB profile after a resize', function (done) { + it('Keep EXIF metadata and add sRGB profile after a resize', function (_t, done) { sharp(fixtures.inputJpgWithExif) .resize(320, 240) .withMetadata() @@ -724,7 +725,7 @@ describe('Image metadata', function () { assert.strictEqual(undefined, metadata.icc); }); - it('Apply CMYK output ICC profile', function (done) { + it('Apply CMYK output ICC profile', function (_t, done) { const output = fixtures.path('output.icc-cmyk.jpg'); sharp(fixtures.inputJpg) .resize(64) @@ -749,7 +750,7 @@ describe('Image metadata', function () { }); }); - it('Apply custom output ICC profile', function (done) { + it('Apply custom output ICC profile', function (_t, done) { const output = fixtures.path('output.hilutite.jpg'); sharp(fixtures.inputJpg) .resize(64) @@ -789,7 +790,7 @@ describe('Image metadata', function () { ) ); - it('Remove EXIF metadata after a resize', function (done) { + it('Remove EXIF metadata after a resize', function (_t, done) { sharp(fixtures.inputJpgWithExif) .resize(320, 240) .toBuffer(function (err, buffer) { @@ -805,7 +806,7 @@ describe('Image metadata', function () { }); }); - it('Remove metadata from PNG output', function (done) { + it('Remove metadata from PNG output', function (_t, done) { sharp(fixtures.inputJpgWithExif) .png() .toBuffer(function (err, buffer) { @@ -992,7 +993,7 @@ describe('Image metadata', function () { assert.strictEqual(description, 'sP3C'); }); - it('File input with corrupt header fails gracefully', function (done) { + it('File input with corrupt header fails gracefully', function (_t, done) { sharp(fixtures.inputJpgWithCorruptHeader) .metadata(function (err) { assert.strictEqual(true, !!err); @@ -1001,7 +1002,7 @@ describe('Image metadata', function () { }); }); - it('Buffer input with corrupt header fails gracefully', function (done) { + it('Buffer input with corrupt header fails gracefully', function (_t, done) { sharp(fs.readFileSync(fixtures.inputJpgWithCorruptHeader)) .metadata(function (err) { assert.strictEqual(true, !!err); @@ -1010,7 +1011,7 @@ describe('Image metadata', function () { }); }); - it('Unsupported lossless JPEG passes underlying error message', function (done) { + it('Unsupported lossless JPEG passes underlying error message', function (_t, done) { sharp(fixtures.inputJpgLossless) .metadata(function (err) { assert.strictEqual(true, !!err); diff --git a/test/unit/modulate.js b/test/unit/modulate.js index 04d27281..50267762 100644 --- a/test/unit/modulate.js +++ b/test/unit/modulate.js @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 const sharp = require('../../'); +const { describe, it } = require('node:test'); const assert = require('node:assert'); const fixtures = require('../fixtures'); diff --git a/test/unit/negate.js b/test/unit/negate.js index c442d7cf..bd0c0a94 100644 --- a/test/unit/negate.js +++ b/test/unit/negate.js @@ -1,13 +1,14 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); describe('Negate', function () { - it('negate (jpeg)', function (done) { + it('negate (jpeg)', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .negate() @@ -20,7 +21,7 @@ describe('Negate', function () { }); }); - it('negate (png)', function (done) { + it('negate (png)', function (_t, done) { sharp(fixtures.inputPng) .resize(320, 240) .negate() @@ -33,7 +34,7 @@ describe('Negate', function () { }); }); - it('negate (png, trans)', function (done) { + it('negate (png, trans)', function (_t, done) { sharp(fixtures.inputPngWithTransparency) .resize(320, 240) .negate() @@ -46,7 +47,7 @@ describe('Negate', function () { }); }); - it('negate (png, alpha)', function (done) { + it('negate (png, alpha)', function (_t, done) { sharp(fixtures.inputPngWithGreyAlpha) .resize(320, 240) .negate() @@ -59,7 +60,7 @@ describe('Negate', function () { }); }); - it('negate (webp)', function (done) { + it('negate (webp)', function (_t, done) { sharp(fixtures.inputWebP) .resize(320, 240) .negate() @@ -72,7 +73,7 @@ describe('Negate', function () { }); }); - it('negate (webp, trans)', function (done) { + it('negate (webp, trans)', function (_t, done) { sharp(fixtures.inputWebPWithTransparency) .resize(320, 240) .negate() @@ -85,7 +86,7 @@ describe('Negate', function () { }); }); - it('negate (true)', function (done) { + it('negate (true)', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .negate(true) @@ -98,7 +99,7 @@ describe('Negate', function () { }); }); - it('negate (false)', function (done) { + it('negate (false)', function (_t, done) { const output = fixtures.path('output.unmodified-by-negate.png'); sharp(fixtures.inputJpgWithLowContrast) .negate(false) @@ -109,7 +110,7 @@ describe('Negate', function () { }); }); - it('negate ({alpha: true})', function (done) { + it('negate ({alpha: true})', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .negate({ alpha: true }) @@ -122,7 +123,7 @@ describe('Negate', function () { }); }); - it('negate non-alpha channels (png)', function (done) { + it('negate non-alpha channels (png)', function (_t, done) { sharp(fixtures.inputPng) .resize(320, 240) .negate({ alpha: false }) @@ -135,7 +136,7 @@ describe('Negate', function () { }); }); - it('negate non-alpha channels (png, trans)', function (done) { + it('negate non-alpha channels (png, trans)', function (_t, done) { sharp(fixtures.inputPngWithTransparency) .resize(320, 240) .negate({ alpha: false }) @@ -148,7 +149,7 @@ describe('Negate', function () { }); }); - it('negate non-alpha channels (png, alpha)', function (done) { + it('negate non-alpha channels (png, alpha)', function (_t, done) { sharp(fixtures.inputPngWithGreyAlpha) .resize(320, 240) .negate({ alpha: false }) @@ -161,7 +162,7 @@ describe('Negate', function () { }); }); - it('negate non-alpha channels (webp)', function (done) { + it('negate non-alpha channels (webp)', function (_t, done) { sharp(fixtures.inputWebP) .resize(320, 240) .negate({ alpha: false }) @@ -174,7 +175,7 @@ describe('Negate', function () { }); }); - it('negate non-alpha channels (webp, trans)', function (done) { + it('negate non-alpha channels (webp, trans)', function (_t, done) { sharp(fixtures.inputWebPWithTransparency) .resize(320, 240) .negate({ alpha: false }) diff --git a/test/unit/noise.js b/test/unit/noise.js index 97b8b16f..3578fbec 100644 --- a/test/unit/noise.js +++ b/test/unit/noise.js @@ -1,13 +1,14 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); describe('Gaussian noise', function () { - it('generate single-channel gaussian noise', function (done) { + it('generate single-channel gaussian noise', function (_t, done) { const output = fixtures.path('output.noise-1-channel.png'); const noise = sharp({ create: { @@ -36,7 +37,7 @@ describe('Gaussian noise', function () { }); }); - it('generate 3-channels gaussian noise', function (done) { + it('generate 3-channels gaussian noise', function (_t, done) { const output = fixtures.path('output.noise-3-channels.png'); const noise = sharp({ create: { @@ -65,7 +66,7 @@ describe('Gaussian noise', function () { }); }); - it('overlay 3-channels gaussian noise over image', function (done) { + it('overlay 3-channels gaussian noise over image', function (_t, done) { const output = fixtures.path('output.noise-image.jpg'); const noise = sharp({ create: { @@ -110,7 +111,7 @@ describe('Gaussian noise', function () { }); }); - it('overlay strong single-channel (sRGB) gaussian noise with 25% transparency over transparent png image', function (done) { + it('overlay strong single-channel (sRGB) gaussian noise with 25% transparency over transparent png image', function (_t, done) { const output = fixtures.path('output.noise-image-transparent.png'); const width = 320; const height = 240; diff --git a/test/unit/normalize.js b/test/unit/normalize.js index 843c01df..0c9a9b28 100644 --- a/test/unit/normalize.js +++ b/test/unit/normalize.js @@ -1,6 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); @@ -18,7 +19,7 @@ const assertNormalized = function (data) { }; describe('Normalization', function () { - it('spreads rgb image values between 0 and 255', function (done) { + it('spreads rgb image values between 0 and 255', function (_t, done) { sharp(fixtures.inputJpgWithLowContrast) .normalise() .raw() @@ -29,7 +30,7 @@ describe('Normalization', function () { }); }); - it('spreads grayscaled image values between 0 and 255', function (done) { + it('spreads grayscaled image values between 0 and 255', function (_t, done) { sharp(fixtures.inputJpgWithLowContrast) .greyscale() .normalize() @@ -41,7 +42,7 @@ describe('Normalization', function () { }); }); - it('stretches greyscale images with alpha channel', function (done) { + it('stretches greyscale images with alpha channel', function (_t, done) { sharp(fixtures.inputPngWithGreyAlpha) .normalise() .raw() @@ -52,7 +53,7 @@ describe('Normalization', function () { }); }); - it('keeps an existing alpha channel', function (done) { + it('keeps an existing alpha channel', function (_t, done) { sharp(fixtures.inputPngWithTransparency) .resize(8, 8) .normalize() @@ -68,7 +69,7 @@ describe('Normalization', function () { }); }); - it('keeps the alpha channel of greyscale images intact', function (done) { + it('keeps the alpha channel of greyscale images intact', function (_t, done) { sharp(fixtures.inputPngWithGreyAlpha) .resize(8, 8) .normalise() @@ -84,7 +85,7 @@ describe('Normalization', function () { }); }); - it('does not alter images with only one color', function (done) { + it('does not alter images with only one color', function (_t, done) { const output = fixtures.path('output.unmodified-png-with-one-color.png'); sharp(fixtures.inputPngWithOneColor) .normalize() @@ -95,7 +96,7 @@ describe('Normalization', function () { }); }); - it('works with 16-bit RGBA images', function (done) { + it('works with 16-bit RGBA images', function (_t, done) { sharp(fixtures.inputPngWithTransparency16bit) .normalise() .raw() @@ -106,7 +107,7 @@ describe('Normalization', function () { }); }); - it('should handle luminance range', function (done) { + it('should handle luminance range', function (_t, done) { sharp(fixtures.inputJpgWithLowContrast) .normalise({ lower: 10, upper: 70 }) .raw() diff --git a/test/unit/png.js b/test/unit/png.js index 9e8b4db4..d5f487ae 100644 --- a/test/unit/png.js +++ b/test/unit/png.js @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 const fs = require('node:fs'); +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); @@ -20,7 +21,7 @@ describe('PNG', function () { }); }); - it('default compressionLevel generates smaller file than compressionLevel=0', function (done) { + it('default compressionLevel generates smaller file than compressionLevel=0', function (_t, done) { // First generate with default compressionLevel sharp(fixtures.inputPng) .resize(320, 240) @@ -43,7 +44,7 @@ describe('PNG', function () { }); }); - it('without adaptiveFiltering generates smaller file', function (done) { + it('without adaptiveFiltering generates smaller file', function (_t, done) { // First generate with adaptive filtering sharp(fixtures.inputPng) .resize(320, 240) @@ -78,7 +79,7 @@ describe('PNG', function () { }); }); - it('Progressive PNG image', function (done) { + it('Progressive PNG image', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .png({ progressive: false }) diff --git a/test/unit/raw.js b/test/unit/raw.js index 28f4d392..3d9c1b77 100644 --- a/test/unit/raw.js +++ b/test/unit/raw.js @@ -1,6 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); @@ -82,7 +83,7 @@ describe('Raw pixel data', function () { ); }); - it('RGB', function (done) { + it('RGB', function (_t, done) { // Convert to raw pixel data sharp(fixtures.inputJpg) .resize(256) @@ -111,7 +112,7 @@ describe('Raw pixel data', function () { }); }); - it('RGBA', function (done) { + it('RGBA', function (_t, done) { // Convert to raw pixel data sharp(fixtures.inputPngOverlayLayer1) .resize(256) @@ -140,7 +141,7 @@ describe('Raw pixel data', function () { }); }); - it('RGBA premultiplied', function (done) { + it('RGBA premultiplied', function (_t, done) { // Convert to raw pixel data sharp(fixtures.inputPngSolidAlpha) .resize(256) @@ -186,7 +187,7 @@ describe('Raw pixel data', function () { }); }); - it('JPEG to raw Stream and back again', function (done) { + it('JPEG to raw Stream and back again', function (_t, done) { const width = 32; const height = 24; const writable = sharp({ @@ -213,7 +214,7 @@ describe('Raw pixel data', function () { }); describe('Output raw, uncompressed image data', function () { - it('1 channel greyscale image', function (done) { + it('1 channel greyscale image', function (_t, done) { sharp(fixtures.inputJpg) .greyscale() .resize(32, 24) @@ -230,7 +231,7 @@ describe('Raw pixel data', function () { }); }); - it('3 channel colour image without transparency', function (done) { + it('3 channel colour image without transparency', function (_t, done) { sharp(fixtures.inputJpg) .resize(32, 24) .toFormat('raw') @@ -245,7 +246,7 @@ describe('Raw pixel data', function () { }); }); - it('4 channel colour image with transparency', function (done) { + it('4 channel colour image with transparency', function (_t, done) { sharp(fixtures.inputPngWithTransparency) .resize(32, 24) .toFormat(sharp.format.raw) diff --git a/test/unit/recomb.js b/test/unit/recomb.js index b894371a..78d1bf42 100644 --- a/test/unit/recomb.js +++ b/test/unit/recomb.js @@ -1,6 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); @@ -13,7 +14,7 @@ const sepia = [ ]; describe('Recomb', function () { - it('applies a sepia filter using recomb', function (done) { + it('applies a sepia filter using recomb', function (_t, done) { const output = fixtures.path('output.recomb-sepia.jpg'); sharp(fixtures.inputJpgWithLandscapeExif1) .recomb(sepia) @@ -31,7 +32,7 @@ describe('Recomb', function () { }); }); - it('applies a sepia filter using recomb to an PNG with Alpha', function (done) { + it('applies a sepia filter using recomb to an PNG with Alpha', function (_t, done) { const output = fixtures.path('output.recomb-sepia.png'); sharp(fixtures.inputPngAlphaPremultiplicationSmall) .recomb(sepia) @@ -63,7 +64,7 @@ describe('Recomb', function () { assert.strictEqual(3, info.channels); }); - it('applies a different sepia filter using recomb', function (done) { + it('applies a different sepia filter using recomb', function (_t, done) { const output = fixtures.path('output.recomb-sepia2.jpg'); sharp(fixtures.inputJpgWithLandscapeExif1) .recomb([ @@ -84,7 +85,7 @@ describe('Recomb', function () { done(); }); }); - it('increases the saturation of the image', function (done) { + it('increases the saturation of the image', function (_t, done) { const saturationLevel = 1; const output = fixtures.path('output.recomb-saturation.jpg'); sharp(fixtures.inputJpgWithLandscapeExif1) @@ -119,7 +120,7 @@ describe('Recomb', function () { }); }); - it('applies opacity 30% to the image', function (done) { + it('applies opacity 30% to the image', function (_t, done) { const output = fixtures.path('output.recomb-opacity.png'); sharp(fixtures.inputPngWithTransparent) .recomb([ diff --git a/test/unit/resize-contain.js b/test/unit/resize-contain.js index 8dcc908c..ec5424c8 100644 --- a/test/unit/resize-contain.js +++ b/test/unit/resize-contain.js @@ -1,13 +1,14 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); describe('Resize fit=contain', function () { - it('Allows specifying the position as a string', function (done) { + it('Allows specifying the position as a string', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240, { fit: 'contain', @@ -22,7 +23,7 @@ describe('Resize fit=contain', function () { }); }); - it('JPEG within PNG, no alpha channel', function (done) { + it('JPEG within PNG, no alpha channel', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240, { fit: 'contain' }) .png() @@ -37,7 +38,7 @@ describe('Resize fit=contain', function () { }); }); - it('JPEG within WebP, to include alpha channel', function (done) { + it('JPEG within WebP, to include alpha channel', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240, { fit: 'contain', @@ -55,7 +56,7 @@ describe('Resize fit=contain', function () { }); }); - it('PNG with alpha channel', function (done) { + it('PNG with alpha channel', function (_t, done) { sharp(fixtures.inputPngWithTransparency) .resize(50, 50, { fit: 'contain' }) .toBuffer(function (err, data, info) { @@ -69,7 +70,7 @@ describe('Resize fit=contain', function () { }); }); - it('16-bit PNG with alpha channel', function (done) { + it('16-bit PNG with alpha channel', function (_t, done) { sharp(fixtures.inputPngWithTransparency16bit) .resize(32, 16, { fit: 'contain' }) .toBuffer(function (err, data, info) { @@ -83,7 +84,7 @@ describe('Resize fit=contain', function () { }); }); - it('16-bit PNG with alpha channel onto RGBA', function (done) { + it('16-bit PNG with alpha channel onto RGBA', function (_t, done) { sharp(fixtures.inputPngWithTransparency16bit) .resize(32, 16, { fit: 'contain', @@ -100,7 +101,7 @@ describe('Resize fit=contain', function () { }); }); - it('PNG with 2 channels', function (done) { + it('PNG with 2 channels', function (_t, done) { sharp(fixtures.inputPngWithGreyAlpha) .resize(32, 16, { fit: 'contain', @@ -117,7 +118,7 @@ describe('Resize fit=contain', function () { }); }); - it('TIFF in LAB colourspace onto RGBA background', function (done) { + it('TIFF in LAB colourspace onto RGBA background', function (_t, done) { sharp(fixtures.inputTiffCielab) .resize(64, 128, { fit: 'contain', @@ -135,7 +136,7 @@ describe('Resize fit=contain', function () { }); }); - it('Enlarge', function (done) { + it('Enlarge', function (_t, done) { sharp(fixtures.inputPngWithOneColor) .resize(320, 240, { fit: 'contain' }) .toBuffer(function (err, data, info) { @@ -150,7 +151,7 @@ describe('Resize fit=contain', function () { }); describe('Animated WebP', function () { - it('Width only', function (done) { + it('Width only', function (_t, done) { sharp(fixtures.inputWebPAnimated, { pages: -1 }) .resize(320, 240, { fit: 'contain', @@ -167,7 +168,7 @@ describe('Resize fit=contain', function () { }); }); - it('Height only', function (done) { + it('Height only', function (_t, done) { sharp(fixtures.inputWebPAnimated, { pages: -1 }) .resize(240, 320, { fit: 'contain', @@ -193,7 +194,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position horizontal top', function (done) { + it('Position horizontal top', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 100, { fit: sharp.fit.contain, @@ -211,7 +212,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position horizontal right top', function (done) { + it('Position horizontal right top', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 100, { fit: sharp.fit.contain, @@ -229,7 +230,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position horizontal right', function (done) { + it('Position horizontal right', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 100, { fit: sharp.fit.contain, @@ -247,7 +248,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position horizontal right bottom', function (done) { + it('Position horizontal right bottom', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 100, { fit: sharp.fit.contain, @@ -265,7 +266,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position horizontal bottom', function (done) { + it('Position horizontal bottom', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 100, { fit: sharp.fit.contain, @@ -283,7 +284,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position horizontal left bottom', function (done) { + it('Position horizontal left bottom', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 100, { fit: sharp.fit.contain, @@ -301,7 +302,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position horizontal left', function (done) { + it('Position horizontal left', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 100, { fit: sharp.fit.contain, @@ -319,7 +320,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position horizontal left top', function (done) { + it('Position horizontal left top', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 100, { fit: sharp.fit.contain, @@ -337,7 +338,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position horizontal north', function (done) { + it('Position horizontal north', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 100, { fit: sharp.fit.contain, @@ -355,7 +356,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position horizontal northeast', function (done) { + it('Position horizontal northeast', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 100, { fit: sharp.fit.contain, @@ -373,7 +374,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position horizontal east', function (done) { + it('Position horizontal east', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 100, { fit: sharp.fit.contain, @@ -391,7 +392,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position horizontal southeast', function (done) { + it('Position horizontal southeast', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 100, { fit: sharp.fit.contain, @@ -409,7 +410,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position horizontal south', function (done) { + it('Position horizontal south', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 100, { fit: sharp.fit.contain, @@ -427,7 +428,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position horizontal southwest', function (done) { + it('Position horizontal southwest', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 100, { fit: sharp.fit.contain, @@ -445,7 +446,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position horizontal west', function (done) { + it('Position horizontal west', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 100, { fit: sharp.fit.contain, @@ -463,7 +464,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position horizontal northwest', function (done) { + it('Position horizontal northwest', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 100, { fit: sharp.fit.contain, @@ -481,7 +482,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position horizontal center', function (done) { + it('Position horizontal center', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 100, { fit: sharp.fit.contain, @@ -499,7 +500,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position vertical top', function (done) { + it('Position vertical top', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 200, { fit: sharp.fit.contain, @@ -517,7 +518,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position vertical right top', function (done) { + it('Position vertical right top', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 200, { fit: sharp.fit.contain, @@ -535,7 +536,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position vertical right', function (done) { + it('Position vertical right', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 200, { fit: sharp.fit.contain, @@ -553,7 +554,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position vertical right bottom', function (done) { + it('Position vertical right bottom', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 200, { fit: sharp.fit.contain, @@ -571,7 +572,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position vertical bottom', function (done) { + it('Position vertical bottom', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 200, { fit: sharp.fit.contain, @@ -589,7 +590,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position vertical left bottom', function (done) { + it('Position vertical left bottom', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 200, { fit: sharp.fit.contain, @@ -607,7 +608,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position vertical left', function (done) { + it('Position vertical left', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 200, { fit: sharp.fit.contain, @@ -625,7 +626,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position vertical left top', function (done) { + it('Position vertical left top', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 200, { fit: sharp.fit.contain, @@ -643,7 +644,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position vertical north', function (done) { + it('Position vertical north', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 200, { fit: sharp.fit.contain, @@ -661,7 +662,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position vertical northeast', function (done) { + it('Position vertical northeast', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 200, { fit: sharp.fit.contain, @@ -679,7 +680,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position vertical east', function (done) { + it('Position vertical east', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 200, { fit: sharp.fit.contain, @@ -697,7 +698,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position vertical southeast', function (done) { + it('Position vertical southeast', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 200, { fit: sharp.fit.contain, @@ -715,7 +716,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position vertical south', function (done) { + it('Position vertical south', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 200, { fit: sharp.fit.contain, @@ -733,7 +734,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position vertical southwest', function (done) { + it('Position vertical southwest', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 200, { fit: sharp.fit.contain, @@ -751,7 +752,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position vertical west', function (done) { + it('Position vertical west', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 200, { fit: sharp.fit.contain, @@ -769,7 +770,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position vertical northwest', function (done) { + it('Position vertical northwest', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 200, { fit: sharp.fit.contain, @@ -787,7 +788,7 @@ describe('Resize fit=contain', function () { }); }); - it('Position vertical center', function (done) { + it('Position vertical center', function (_t, done) { sharp(fixtures.inputPngEmbed) .resize(200, 200, { fit: sharp.fit.contain, diff --git a/test/unit/resize-cover.js b/test/unit/resize-cover.js index b93670d3..f5bdd515 100644 --- a/test/unit/resize-cover.js +++ b/test/unit/resize-cover.js @@ -1,6 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); @@ -200,7 +201,7 @@ describe('Resize fit=cover', function () { fixture: 'gravity-west.jpg' } ].forEach(function (settings) { - it(settings.name, function (done) { + it(settings.name, function (_t, done) { sharp(fixtures.inputJpg) .resize(settings.width, settings.height, { fit: sharp.fit.cover, @@ -215,7 +216,7 @@ describe('Resize fit=cover', function () { }); }); - it('Allows specifying the gravity as a string', function (done) { + it('Allows specifying the gravity as a string', function (_t, done) { sharp(fixtures.inputJpg) .resize(80, 320, { fit: sharp.fit.cover, @@ -271,7 +272,7 @@ describe('Resize fit=cover', function () { }); describe('Animated WebP', function () { - it('Width only', function (done) { + it('Width only', function (_t, done) { sharp(fixtures.inputWebPAnimated, { pages: -1 }) .resize(80, 320, { fit: sharp.fit.cover }) .toBuffer(function (err, data, info) { @@ -282,7 +283,7 @@ describe('Resize fit=cover', function () { }); }); - it('Height only', function (done) { + it('Height only', function (_t, done) { sharp(fixtures.inputWebPAnimated, { pages: -1 }) .resize(320, 80, { fit: sharp.fit.cover }) .toBuffer(function (err, data, info) { @@ -295,7 +296,7 @@ describe('Resize fit=cover', function () { }); describe('Entropy-based strategy', function () { - it('JPEG', function (done) { + it('JPEG', function (_t, done) { sharp(fixtures.inputJpg) .resize(80, 320, { fit: 'cover', @@ -313,7 +314,7 @@ describe('Resize fit=cover', function () { }); }); - it('PNG', function (done) { + it('PNG', function (_t, done) { sharp(fixtures.inputPngWithTransparency) .resize(320, 80, { fit: 'cover', @@ -331,7 +332,7 @@ describe('Resize fit=cover', function () { }); }); - it('supports the strategy passed as a string', function (done) { + it('supports the strategy passed as a string', function (_t, done) { sharp(fixtures.inputPngWithTransparency) .resize(320, 80, { fit: 'cover', @@ -363,7 +364,7 @@ describe('Resize fit=cover', function () { }); describe('Attention strategy', function () { - it('JPEG', function (done) { + it('JPEG', function (_t, done) { sharp(fixtures.inputJpg) .resize(80, 320, { fit: 'cover', @@ -383,7 +384,7 @@ describe('Resize fit=cover', function () { }); }); - it('PNG', function (done) { + it('PNG', function (_t, done) { sharp(fixtures.inputPngWithTransparency) .resize(320, 80, { fit: 'cover', @@ -403,7 +404,7 @@ describe('Resize fit=cover', function () { }); }); - it('WebP', function (done) { + it('WebP', function (_t, done) { sharp(fixtures.inputWebP) .resize(320, 80, { fit: 'cover', @@ -423,7 +424,7 @@ describe('Resize fit=cover', function () { }); }); - it('supports the strategy passed as a string', function (done) { + it('supports the strategy passed as a string', function (_t, done) { sharp(fixtures.inputPngWithTransparency) .resize(320, 80, { fit: 'cover', diff --git a/test/unit/resize.js b/test/unit/resize.js index b59a049d..ce59d4d5 100644 --- a/test/unit/resize.js +++ b/test/unit/resize.js @@ -1,13 +1,14 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); describe('Resize dimensions', function () { - it('Exact crop', function (done) { + it('Exact crop', function (_t, done) { sharp(fixtures.inputJpg).resize(320, 240).toBuffer(function (err, data, info) { if (err) throw err; assert.strictEqual(true, data.length > 0); @@ -18,7 +19,7 @@ describe('Resize dimensions', function () { }); }); - it('Fixed width', function (done) { + it('Fixed width', function (_t, done) { sharp(fixtures.inputJpg).resize(320).toBuffer(function (err, data, info) { if (err) throw err; assert.strictEqual(true, data.length > 0); @@ -29,7 +30,7 @@ describe('Resize dimensions', function () { }); }); - it('Fixed height', function (done) { + it('Fixed height', function (_t, done) { sharp(fixtures.inputJpg).resize(null, 320).toBuffer(function (err, data, info) { if (err) throw err; assert.strictEqual(true, data.length > 0); @@ -40,7 +41,7 @@ describe('Resize dimensions', function () { }); }); - it('Identity transform', function (done) { + it('Identity transform', function (_t, done) { sharp(fixtures.inputJpg).toBuffer(function (err, data, info) { if (err) throw err; assert.strictEqual(true, data.length > 0); @@ -51,7 +52,7 @@ describe('Resize dimensions', function () { }); }); - it('Upscale', function (done) { + it('Upscale', function (_t, done) { sharp(fixtures.inputJpg) .resize(3000) .toBuffer(function (err, data, info) { @@ -100,7 +101,7 @@ describe('Resize dimensions', function () { }, /Expected positive integer for height but received 1.5 of type number/); }); - it('Invalid width - too large', function (done) { + it('Invalid width - too large', function (_t, done) { sharp(fixtures.inputJpg) .resize(0x4000, 1) .webp() @@ -111,7 +112,7 @@ describe('Resize dimensions', function () { }); }); - it('Invalid height - too large', function (done) { + it('Invalid height - too large', function (_t, done) { sharp(fixtures.inputJpg) .resize(1, 0x4000) .webp() @@ -122,7 +123,7 @@ describe('Resize dimensions', function () { }); }); - it('Webp resize then extract large image', function (done) { + it('Webp resize then extract large image', function (_t, done) { sharp(fixtures.inputWebP) .resize(0x4000, 0x4000) .extract({ top: 0x2000, left: 0x2000, width: 256, height: 256 }) @@ -136,7 +137,7 @@ describe('Resize dimensions', function () { }); }); - it('WebP shrink-on-load rounds to zero, ensure recalculation is correct', function (done) { + it('WebP shrink-on-load rounds to zero, ensure recalculation is correct', function (_t, done) { sharp(fixtures.inputJpg) .resize(1080, 607) .webp() @@ -157,7 +158,7 @@ describe('Resize dimensions', function () { }); }); - it('JPEG shrink-on-load with 90 degree rotation, ensure recalculation is correct', function (done) { + it('JPEG shrink-on-load with 90 degree rotation, ensure recalculation is correct', function (_t, done) { sharp(fixtures.inputJpg) .resize(1920, 1280) .toBuffer(function (err, data, info) { @@ -176,7 +177,7 @@ describe('Resize dimensions', function () { }); }); - it('TIFF embed known to cause rounding errors', function (done) { + it('TIFF embed known to cause rounding errors', function (_t, done) { sharp(fixtures.inputTiff) .resize(240, 320, { fit: sharp.fit.contain }) .jpeg() @@ -190,7 +191,7 @@ describe('Resize dimensions', function () { }); }); - it('TIFF known to cause rounding errors', function (done) { + it('TIFF known to cause rounding errors', function (_t, done) { sharp(fixtures.inputTiff) .resize(240, 320) .jpeg() @@ -204,7 +205,7 @@ describe('Resize dimensions', function () { }); }); - it('fit=inside, portrait', function (done) { + it('fit=inside, portrait', function (_t, done) { sharp(fixtures.inputTiff) .resize(320, 320, { fit: sharp.fit.inside }) .jpeg() @@ -218,7 +219,7 @@ describe('Resize dimensions', function () { }); }); - it('fit=outside, portrait', function (done) { + it('fit=outside, portrait', function (_t, done) { sharp(fixtures.inputTiff) .resize(320, 320, { fit: sharp.fit.outside }) .jpeg() @@ -232,7 +233,7 @@ describe('Resize dimensions', function () { }); }); - it('fit=inside, landscape', function (done) { + it('fit=inside, landscape', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 320, { fit: sharp.fit.inside }) .toBuffer(function (err, data, info) { @@ -245,7 +246,7 @@ describe('Resize dimensions', function () { }); }); - it('fit=outside, landscape', function (done) { + it('fit=outside, landscape', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 320, { fit: sharp.fit.outside }) .toBuffer(function (err, data, info) { @@ -258,7 +259,7 @@ describe('Resize dimensions', function () { }); }); - it('fit=inside, provide only one dimension', function (done) { + it('fit=inside, provide only one dimension', function (_t, done) { sharp(fixtures.inputJpg) .resize({ width: 320, @@ -274,7 +275,7 @@ describe('Resize dimensions', function () { }); }); - it('fit=outside, provide only one dimension', function (done) { + it('fit=outside, provide only one dimension', function (_t, done) { sharp(fixtures.inputJpg) .resize({ width: 320, @@ -290,7 +291,7 @@ describe('Resize dimensions', function () { }); }); - it('Do not enlarge when input width is already less than output width', function (done) { + it('Do not enlarge when input width is already less than output width', function (_t, done) { sharp(fixtures.inputJpg) .resize({ width: 2800, @@ -306,7 +307,7 @@ describe('Resize dimensions', function () { }); }); - it('Do not enlarge when input height is already less than output height', function (done) { + it('Do not enlarge when input height is already less than output height', function (_t, done) { sharp(fixtures.inputJpg) .resize({ height: 2300, @@ -322,7 +323,7 @@ describe('Resize dimensions', function () { }); }); - it('Do crop when fit = cover and withoutEnlargement = true and width >= outputWidth, and height < outputHeight', function (done) { + it('Do crop when fit = cover and withoutEnlargement = true and width >= outputWidth, and height < outputHeight', function (_t, done) { sharp(fixtures.inputJpg) .resize({ width: 3000, @@ -339,7 +340,7 @@ describe('Resize dimensions', function () { }); }); - it('Do crop when fit = cover and withoutEnlargement = true and width < outputWidth, and height >= outputHeight', function (done) { + it('Do crop when fit = cover and withoutEnlargement = true and width < outputWidth, and height >= outputHeight', function (_t, done) { sharp(fixtures.inputJpg) .resize({ width: 1500, @@ -356,7 +357,7 @@ describe('Resize dimensions', function () { }); }); - it('Do enlarge when input width is less than output width', function (done) { + it('Do enlarge when input width is less than output width', function (_t, done) { sharp(fixtures.inputJpg) .resize({ width: 2800, @@ -372,7 +373,7 @@ describe('Resize dimensions', function () { }); }); - it('Do enlarge when input width is less than output width', function (done) { + it('Do enlarge when input width is less than output width', function (_t, done) { sharp(fixtures.inputJpg) .resize({ width: 2800, @@ -388,7 +389,7 @@ describe('Resize dimensions', function () { }); }); - it('Do enlarge when input height is less than output height', function (done) { + it('Do enlarge when input height is less than output height', function (_t, done) { sharp(fixtures.inputJpg) .resize({ height: 2300, @@ -404,7 +405,7 @@ describe('Resize dimensions', function () { }); }); - it('Do enlarge when input width is less than output width', function (done) { + it('Do enlarge when input width is less than output width', function (_t, done) { sharp(fixtures.inputJpg) .resize({ width: 2800, @@ -420,7 +421,7 @@ describe('Resize dimensions', function () { }); }); - it('Do not resize when both withoutEnlargement and withoutReduction are true', function (done) { + it('Do not resize when both withoutEnlargement and withoutReduction are true', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 320, { fit: 'fill', withoutEnlargement: true, withoutReduction: true }) .toBuffer(function (err, data, info) { @@ -433,7 +434,7 @@ describe('Resize dimensions', function () { }); }); - it('Do not reduce size when fit = outside and withoutReduction are true and height > outputHeight and width > outputWidth', function (done) { + it('Do not reduce size when fit = outside and withoutReduction are true and height > outputHeight and width > outputWidth', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 320, { fit: 'outside', withoutReduction: true }) .toBuffer(function (err, data, info) { @@ -446,7 +447,7 @@ describe('Resize dimensions', function () { }); }); - it('Do resize when fit = outside and withoutReduction are true and input height > height and input width > width ', function (done) { + it('Do resize when fit = outside and withoutReduction are true and input height > height and input width > width ', function (_t, done) { sharp(fixtures.inputJpg) .resize(3000, 3000, { fit: 'outside', withoutReduction: true }) .toBuffer(function (err, data, info) { @@ -459,7 +460,7 @@ describe('Resize dimensions', function () { }); }); - it('fit=fill, downscale width and height', function (done) { + it('fit=fill, downscale width and height', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 320, { fit: 'fill' }) .toBuffer(function (err, data, info) { @@ -472,7 +473,7 @@ describe('Resize dimensions', function () { }); }); - it('fit=fill, downscale width', function (done) { + it('fit=fill, downscale width', function (_t, done) { sharp(fixtures.inputJpg) .resize({ width: 320, @@ -488,7 +489,7 @@ describe('Resize dimensions', function () { }); }); - it('fit=fill, downscale height', function (done) { + it('fit=fill, downscale height', function (_t, done) { sharp(fixtures.inputJpg) .resize({ height: 320, @@ -504,7 +505,7 @@ describe('Resize dimensions', function () { }); }); - it('fit=fill, upscale width and height', function (done) { + it('fit=fill, upscale width and height', function (_t, done) { sharp(fixtures.inputJpg) .resize(3000, 3000, { fit: 'fill' }) .toBuffer(function (err, data, info) { @@ -517,7 +518,7 @@ describe('Resize dimensions', function () { }); }); - it('fit=fill, upscale width', function (done) { + it('fit=fill, upscale width', function (_t, done) { sharp(fixtures.inputJpg) .resize(3000, null, { fit: 'fill' }) .toBuffer(function (err, data, info) { @@ -530,7 +531,7 @@ describe('Resize dimensions', function () { }); }); - it('fit=fill, upscale height', function (done) { + it('fit=fill, upscale height', function (_t, done) { sharp(fixtures.inputJpg) .resize(null, 3000, { fit: 'fill' }) .toBuffer(function (err, data, info) { @@ -543,7 +544,7 @@ describe('Resize dimensions', function () { }); }); - it('fit=fill, downscale width, upscale height', function (done) { + it('fit=fill, downscale width, upscale height', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 3000, { fit: 'fill' }) .toBuffer(function (err, data, info) { @@ -556,7 +557,7 @@ describe('Resize dimensions', function () { }); }); - it('fit=fill, upscale width, downscale height', function (done) { + it('fit=fill, upscale width, downscale height', function (_t, done) { sharp(fixtures.inputJpg) .resize(3000, 320, { fit: 'fill' }) .toBuffer(function (err, data, info) { @@ -569,7 +570,7 @@ describe('Resize dimensions', function () { }); }); - it('fit=fill, identity transform', function (done) { + it('fit=fill, identity transform', function (_t, done) { sharp(fixtures.inputJpg) .resize(null, null, { fit: 'fill' }) .toBuffer(function (err, data, info) { @@ -582,7 +583,7 @@ describe('Resize dimensions', function () { }); }); - it('Dimensions that result in differing even shrinks on each axis', function (done) { + it('Dimensions that result in differing even shrinks on each axis', function (_t, done) { sharp(fixtures.inputJpg) .resize(645, 399) .toBuffer(function (err, data, info) { @@ -600,7 +601,7 @@ describe('Resize dimensions', function () { }); }); - it('Dimensions that result in differing odd shrinks on each axis', function (done) { + it('Dimensions that result in differing odd shrinks on each axis', function (_t, done) { return sharp(fixtures.inputJpg) .resize(600, 399) .toBuffer(function (err, data, info) { @@ -622,7 +623,7 @@ describe('Resize dimensions', function () { true, false ].forEach(function (value) { - it(`fastShrinkOnLoad: ${value} does not causes image shifts`, function (done) { + it(`fastShrinkOnLoad: ${value} does not causes image shifts`, function (_t, done) { sharp(fixtures.inputJpgCenteredImage) .resize(9, 8, { fastShrinkOnLoad: value }) .png() @@ -642,7 +643,7 @@ describe('Resize dimensions', function () { sharp.kernel.lanczos2, sharp.kernel.lanczos3 ].forEach(function (kernel) { - it(`kernel ${kernel}`, function (done) { + it(`kernel ${kernel}`, function (_t, done) { sharp(fixtures.inputJpg) .resize(320, null, { kernel }) .toBuffer(function (err, data, info) { @@ -654,7 +655,7 @@ describe('Resize dimensions', function () { }); }); - it('nearest upsampling with integral factor', function (done) { + it('nearest upsampling with integral factor', function (_t, done) { sharp(fixtures.inputTiff8BitDepth) .resize(210, 210, { kernel: 'nearest' }) .png() diff --git a/test/unit/rotate.js b/test/unit/rotate.js index 25303ce8..6d8422c4 100644 --- a/test/unit/rotate.js +++ b/test/unit/rotate.js @@ -1,6 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); @@ -15,7 +16,7 @@ describe('Rotation', function () { [1, 2, 3, 4, 5, 6, 7, 8].forEach(function (exifTag) { const input = fixtures[`inputJpgWith${orientation}Exif${exifTag}`]; const expectedOutput = fixtures.expected(`${orientation}_${exifTag}-out.jpg`); - it(`${orientation} image with EXIF Orientation ${exifTag}: Auto-rotate`, function (done) { + it(`${orientation} image with EXIF Orientation ${exifTag}: Auto-rotate`, function (_t, done) { const [expectedWidth, expectedHeight] = orientation === 'Landscape' ? [600, 450] : [450, 600]; const img = sharp(input, options); @@ -29,7 +30,7 @@ describe('Rotation', function () { }); }); - it(`${orientation} image with EXIF Orientation ${exifTag}: Auto-rotate then resize`, function (done) { + it(`${orientation} image with EXIF Orientation ${exifTag}: Auto-rotate then resize`, function (_t, done) { const [expectedWidth, expectedHeight] = orientation === 'Landscape' ? [320, 240] : [320, 427]; const img = sharp(input, options); @@ -45,7 +46,7 @@ describe('Rotation', function () { }); if (rotateMethod !== 'constructor') { - it(`${orientation} image with EXIF Orientation ${exifTag}: Resize then auto-rotate`, function (done) { + it(`${orientation} image with EXIF Orientation ${exifTag}: Resize then auto-rotate`, function (_t, done) { const [expectedWidth, expectedHeight] = orientation === 'Landscape' ? (exifTag < 5) ? [320, 240] : [320, 240] : [320, 427]; @@ -67,7 +68,7 @@ describe('Rotation', function () { [90, 180, 270, 45].forEach(function (angle) { const [inputWidth, inputHeight] = orientation === 'Landscape' ? [600, 450] : [450, 600]; const expectedOutput = fixtures.expected(`${orientation}_${exifTag}_rotate${angle}-out.jpg`); - it(`${orientation} image with EXIF Orientation ${exifTag}: Auto-rotate then rotate ${angle} ${doResize ? 'and resize' : ''}`, function (done) { + it(`${orientation} image with EXIF Orientation ${exifTag}: Auto-rotate then rotate ${angle} ${doResize ? 'and resize' : ''}`, function (_t, done) { const [width, height] = (angle === 45 ? [742, 742] : [inputWidth, inputHeight]).map((x) => doResize ? Math.floor(x / 1.875) : x); const [expectedWidth, expectedHeight] = angle % 180 === 0 ? [width, height] : [height, width]; @@ -90,7 +91,7 @@ describe('Rotation', function () { const [inputWidth, inputHeight] = orientation === 'Landscape' ? [600, 450] : [450, 600]; const flipFlopFileName = [flip && 'flip', flop && 'flop'].filter(Boolean).join('_'); const flipFlopTestName = [flip && 'flip', flop && 'flop'].filter(Boolean).join(' & '); - it(`${orientation} image with EXIF Orientation ${exifTag}: Auto-rotate then ${flipFlopTestName} ${doResize ? 'and resize' : ''}`, function (done) { + it(`${orientation} image with EXIF Orientation ${exifTag}: Auto-rotate then ${flipFlopTestName} ${doResize ? 'and resize' : ''}`, function (_t, done) { const expectedOutput = fixtures.expected(`${orientation}_${exifTag}_${flipFlopFileName}-out.jpg`); const img = sharp(input, options); @@ -115,7 +116,7 @@ describe('Rotation', function () { }); }); - it('Rotate by 30 degrees with semi-transparent background', function (done) { + it('Rotate by 30 degrees with semi-transparent background', function (_t, done) { sharp(fixtures.inputJpg) .resize(320) .rotate(30, { background: { r: 255, g: 0, b: 0, alpha: 0.5 } }) @@ -129,7 +130,7 @@ describe('Rotation', function () { }); }); - it('Rotate by 30 degrees with solid background', function (done) { + it('Rotate by 30 degrees with solid background', function (_t, done) { sharp(fixtures.inputJpg) .resize(320) .rotate(30, { background: { r: 255, g: 0, b: 0 } }) @@ -142,7 +143,7 @@ describe('Rotation', function () { }); }); - it('Rotate by 90 degrees, respecting output input size', function (done) { + it('Rotate by 90 degrees, respecting output input size', function (_t, done) { sharp(fixtures.inputJpg) .rotate(90) .resize(320, 240) @@ -156,7 +157,7 @@ describe('Rotation', function () { }); }); - it('Resize then rotate by 30 degrees, respecting output input size', function (done) { + it('Resize then rotate by 30 degrees, respecting output input size', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .rotate(30) @@ -171,7 +172,7 @@ describe('Rotation', function () { }); [-3690, -450, -90, 90, 450, 3690].forEach(function (angle) { - it(`Rotate by any 90-multiple angle (${angle}deg)`, function (done) { + it(`Rotate by any 90-multiple angle (${angle}deg)`, function (_t, done) { sharp(fixtures.inputJpg320x240).rotate(angle).toBuffer(function (err, _data, info) { if (err) throw err; assert.strictEqual(240, info.width); @@ -182,7 +183,7 @@ describe('Rotation', function () { }); [-3750, -510, -150, 30, 390, 3630].forEach(function (angle) { - it(`Rotate by any 30-multiple angle (${angle}deg)`, function (done) { + it(`Rotate by any 30-multiple angle (${angle}deg)`, function (_t, done) { sharp(fixtures.inputJpg320x240).rotate(angle).toBuffer(function (err, _data, info) { if (err) throw err; assert.strictEqual(397, info.width); @@ -193,7 +194,7 @@ describe('Rotation', function () { }); [-3780, -540, 0, 180, 540, 3780].forEach(function (angle) { - it(`Rotate by any 180-multiple angle (${angle}deg)`, function (done) { + it(`Rotate by any 180-multiple angle (${angle}deg)`, function (_t, done) { sharp(fixtures.inputJpg320x240).rotate(angle).toBuffer(function (err, _data, info) { if (err) throw err; assert.strictEqual(320, info.width); @@ -203,7 +204,7 @@ describe('Rotation', function () { }); }); - it('Rotate by 270 degrees, square output ignoring aspect ratio', function (done) { + it('Rotate by 270 degrees, square output ignoring aspect ratio', function (_t, done) { sharp(fixtures.inputJpg) .resize(240, 240, { fit: sharp.fit.fill }) .rotate(270) @@ -220,7 +221,7 @@ describe('Rotation', function () { }); }); - it('Rotate by 315 degrees, square output ignoring aspect ratio', function (done) { + it('Rotate by 315 degrees, square output ignoring aspect ratio', function (_t, done) { sharp(fixtures.inputJpg) .resize(240, 240, { fit: sharp.fit.fill }) .rotate(315) @@ -237,7 +238,7 @@ describe('Rotation', function () { }); }); - it('Rotate by 270 degrees, rectangular output ignoring aspect ratio', function (done) { + it('Rotate by 270 degrees, rectangular output ignoring aspect ratio', function (_t, done) { sharp(fixtures.inputJpg) .rotate(270) .resize(320, 240, { fit: sharp.fit.fill }) @@ -254,7 +255,7 @@ describe('Rotation', function () { }); }); - it('Auto-rotate by 270 degrees, rectangular output ignoring aspect ratio', function (done) { + it('Auto-rotate by 270 degrees, rectangular output ignoring aspect ratio', function (_t, done) { sharp(fixtures.inputJpgWithLandscapeExif8) .resize(320, 240, { fit: sharp.fit.fill }) .rotate() @@ -271,7 +272,7 @@ describe('Rotation', function () { }); }); - it('Rotate by 30 degrees, rectangular output ignoring aspect ratio', function (done) { + it('Rotate by 30 degrees, rectangular output ignoring aspect ratio', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240, { fit: sharp.fit.fill }) .rotate(30) @@ -288,7 +289,7 @@ describe('Rotation', function () { }); }); - it('Input image has Orientation EXIF tag but do not rotate output', function (done) { + it('Input image has Orientation EXIF tag but do not rotate output', function (_t, done) { sharp(fixtures.inputJpgWithExif) .resize(320) .withMetadata() @@ -306,7 +307,7 @@ describe('Rotation', function () { }); }); - it('Input image has Orientation EXIF tag value of 8 (270 degrees), auto-rotate', function (done) { + it('Input image has Orientation EXIF tag value of 8 (270 degrees), auto-rotate', function (_t, done) { sharp(fixtures.inputJpgWithExif) .rotate() .resize(320) @@ -319,7 +320,7 @@ describe('Rotation', function () { }); }); - it('Override EXIF Orientation tag metadata after auto-rotate', function (done) { + it('Override EXIF Orientation tag metadata after auto-rotate', function (_t, done) { sharp(fixtures.inputJpgWithExif) .rotate() .resize(320) @@ -337,7 +338,7 @@ describe('Rotation', function () { }); }); - it('Input image has Orientation EXIF tag value of 5 (270 degrees + flip), auto-rotate', function (done) { + it('Input image has Orientation EXIF tag value of 5 (270 degrees + flip), auto-rotate', function (_t, done) { sharp(fixtures.inputJpgWithExifMirroring) .rotate() .resize(320) @@ -355,7 +356,7 @@ describe('Rotation', function () { }); }); - it('Attempt to auto-rotate using image that has no EXIF', function (done) { + it('Attempt to auto-rotate using image that has no EXIF', function (_t, done) { sharp(fixtures.inputJpg).rotate().resize(320).toBuffer(function (err, data, info) { if (err) throw err; assert.strictEqual(true, data.length > 0); @@ -366,7 +367,7 @@ describe('Rotation', function () { }); }); - it('Attempt to auto-rotate image format without EXIF support', function (done) { + it('Attempt to auto-rotate image format without EXIF support', function (_t, done) { sharp(fixtures.inputPng) .rotate() .resize(320) @@ -440,7 +441,7 @@ describe('Rotation', function () { assert.strictEqual(warningMessage, 'ignoring previous rotate options'); }); - it('Multiple rotate: last one wins (cardinal)', function (done) { + it('Multiple rotate: last one wins (cardinal)', function (_t, done) { sharp(fixtures.inputJpg) .rotate(45) .rotate(90) @@ -452,7 +453,7 @@ describe('Rotation', function () { }); }); - it('Multiple rotate: last one wins (non cardinal)', function (done) { + it('Multiple rotate: last one wins (non cardinal)', function (_t, done) { sharp(fixtures.inputJpg) .rotate(90) .rotate(45) @@ -464,7 +465,7 @@ describe('Rotation', function () { }); }); - it('Flip - vertical', function (done) { + it('Flip - vertical', function (_t, done) { sharp(fixtures.inputJpg) .resize(320) .flip() @@ -482,7 +483,7 @@ describe('Rotation', function () { }); }); - it('Flop - horizontal', function (done) { + it('Flop - horizontal', function (_t, done) { sharp(fixtures.inputJpg) .resize(320) .flop() @@ -500,7 +501,7 @@ describe('Rotation', function () { }); }); - it('Flip and flop', function (done) { + it('Flip and flop', function (_t, done) { sharp(fixtures.inputJpg) .resize(320) .flip() @@ -514,7 +515,7 @@ describe('Rotation', function () { }); }); - it('Neither flip nor flop', function (done) { + it('Neither flip nor flop', function (_t, done) { sharp(fixtures.inputJpg) .resize(320) .flip(false) @@ -528,7 +529,7 @@ describe('Rotation', function () { }); }); - it('Auto-rotate and flip', function (done) { + it('Auto-rotate and flip', function (_t, done) { sharp(fixtures.inputJpgWithExif) .rotate() .flip() @@ -542,7 +543,7 @@ describe('Rotation', function () { }); }); - it('Auto-rotate and flop', function (done) { + it('Auto-rotate and flop', function (_t, done) { sharp(fixtures.inputJpgWithExif) .rotate() .flop() diff --git a/test/unit/sharpen.js b/test/unit/sharpen.js index 78b6f98f..28b3db54 100644 --- a/test/unit/sharpen.js +++ b/test/unit/sharpen.js @@ -1,13 +1,14 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); describe('Sharpen', function () { - it('specific radius 10 (sigma 6)', function (done) { + it('specific radius 10 (sigma 6)', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .sharpen(6) @@ -20,7 +21,7 @@ describe('Sharpen', function () { }); }); - it('specific radius 3 (sigma 1.5) and levels 0.5, 2.5', function (done) { + it('specific radius 3 (sigma 1.5) and levels 0.5, 2.5', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .sharpen(1.5, 0.5, 2.5) @@ -33,7 +34,7 @@ describe('Sharpen', function () { }); }); - it('specific radius 5 (sigma 3.5) and levels 2, 4', function (done) { + it('specific radius 5 (sigma 3.5) and levels 2, 4', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .sharpen(3.5, 2, 4) @@ -46,7 +47,7 @@ describe('Sharpen', function () { }); }); - it('sigma=3.5, m1=2, m2=4', (done) => { + it('sigma=3.5, m1=2, m2=4', (_t, done) => { sharp(fixtures.inputJpg) .resize(320, 240) .sharpen({ sigma: 3.5, m1: 2, m2: 4 }) @@ -54,7 +55,7 @@ describe('Sharpen', function () { .then(data => fixtures.assertSimilar(fixtures.expected('sharpen-5-2-4.jpg'), data, done)); }); - it('sigma=3.5, m1=2, m2=4, x1=2, y2=5, y3=25', (done) => { + it('sigma=3.5, m1=2, m2=4, x1=2, y2=5, y3=25', (_t, done) => { sharp(fixtures.inputJpg) .resize(320, 240) .sharpen({ sigma: 3.5, m1: 2, m2: 4, x1: 2, y2: 5, y3: 25 }) @@ -63,7 +64,7 @@ describe('Sharpen', function () { }); if (!process.env.SHARP_TEST_WITHOUT_CACHE) { - it('specific radius/levels with alpha channel', function (done) { + it('specific radius/levels with alpha channel', function (_t, done) { sharp(fixtures.inputPngWithTransparency) .resize(320, 240) .sharpen(5, 4, 8) @@ -78,7 +79,7 @@ describe('Sharpen', function () { }); } - it('mild sharpen', function (done) { + it('mild sharpen', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .sharpen() @@ -139,7 +140,7 @@ describe('Sharpen', function () { /Expected number between 0 and 1000000 for options\.y3 but received -1 of type number/ )); - it('sharpened image is larger than non-sharpened', function (done) { + it('sharpened image is larger than non-sharpened', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .sharpen(false) diff --git a/test/unit/stats.js b/test/unit/stats.js index 9f3a73da..89102cd6 100644 --- a/test/unit/stats.js +++ b/test/unit/stats.js @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 const fs = require('node:fs'); +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); @@ -20,7 +21,7 @@ function isInteger (val) { } describe('Image Stats', function () { - it('JPEG', function (done) { + it('JPEG', function (_t, done) { sharp(fixtures.inputJpg).stats(function (err, stats) { if (err) throw err; @@ -85,7 +86,7 @@ describe('Image Stats', function () { }); }); - it('PNG without transparency', function (done) { + it('PNG without transparency', function (_t, done) { sharp(fixtures.inputPng).stats(function (err, stats) { if (err) throw err; @@ -117,7 +118,7 @@ describe('Image Stats', function () { }); }); - it('PNG with transparency', function (done) { + it('PNG with transparency', function (_t, done) { sharp(fixtures.inputPngWithTransparency).stats(function (err, stats) { if (err) throw err; @@ -198,7 +199,7 @@ describe('Image Stats', function () { }); }); - it('PNG fully transparent', function (done) { + it('PNG fully transparent', function (_t, done) { sharp(fixtures.inputPngCompleteTransparency).stats(function (err, stats) { if (err) throw err; @@ -231,7 +232,7 @@ describe('Image Stats', function () { }); }); - it('Tiff', function (done) { + it('Tiff', function (_t, done) { sharp(fixtures.inputTiff).stats(function (err, stats) { if (err) throw err; @@ -264,7 +265,7 @@ describe('Image Stats', function () { }); }); - it('WebP', function (done) { + it('WebP', function (_t, done) { sharp(fixtures.inputWebP).stats(function (err, stats) { if (err) throw err; @@ -329,7 +330,7 @@ describe('Image Stats', function () { }); }); - it('GIF', function (done) { + it('GIF', function (_t, done) { sharp(fixtures.inputGif).stats(function (err, stats) { if (err) throw err; @@ -394,7 +395,7 @@ describe('Image Stats', function () { }); }); - it('Grayscale GIF with alpha', function (done) { + it('Grayscale GIF with alpha', function (_t, done) { sharp(fixtures.inputGifGreyPlusAlpha).stats(function (err, stats) { if (err) throw err; @@ -476,7 +477,7 @@ describe('Image Stats', function () { assert.strictEqual(sharpness, 0); }); - it('Stream in, Callback out', function (done) { + it('Stream in, Callback out', function (_t, done) { const readable = fs.createReadStream(fixtures.inputJpg); const pipeline = sharp().stats(function (err, stats) { if (err) throw err; @@ -685,7 +686,7 @@ describe('Image Stats', function () { }); }); - it('File input with corrupt header fails gracefully', function (done) { + it('File input with corrupt header fails gracefully', function (_t, done) { sharp(fixtures.inputJpgWithCorruptHeader) .stats(function (err) { assert(err.message.includes('Input file has corrupt header')); @@ -695,7 +696,7 @@ describe('Image Stats', function () { }); }); - it('Stream input with corrupt header fails gracefully', function (done) { + it('Stream input with corrupt header fails gracefully', function (_t, done) { fs.createReadStream(fixtures.inputJpgWithCorruptHeader).pipe( sharp() .stats(function (err) { @@ -729,7 +730,7 @@ describe('Image Stats', function () { }); }); - it('Buffer input with corrupt header fails gracefully', function (done) { + it('Buffer input with corrupt header fails gracefully', function (_t, done) { sharp(fs.readFileSync(fixtures.inputJpgWithCorruptHeader)) .stats(function (err) { assert.strictEqual(true, !!err); @@ -737,7 +738,7 @@ describe('Image Stats', function () { }); }); - it('Non-existent file in, Promise out', function (done) { + it('Non-existent file in, Promise out', function (_t, done) { sharp('fail').stats().then(function () { throw new Error('Non-existent file'); }, function (err) { diff --git a/test/unit/svg.js b/test/unit/svg.js index f79f3efa..a12932ac 100644 --- a/test/unit/svg.js +++ b/test/unit/svg.js @@ -2,13 +2,14 @@ // SPDX-License-Identifier: Apache-2.0 const fs = require('node:fs'); +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); describe('SVG input', function () { - it('Convert SVG to PNG at default 72DPI', function (done) { + it('Convert SVG to PNG at default 72DPI', function (_t, done) { sharp(fixtures.inputSvg) .resize(1024) .extract({ left: 290, top: 760, width: 40, height: 40 }) @@ -29,7 +30,7 @@ describe('SVG input', function () { }); }); - it('Convert SVG to PNG at 1200DPI', function (done) { + it('Convert SVG to PNG at 1200DPI', function (_t, done) { sharp(fixtures.inputSvg, { density: 1200 }) .resize(1024) .extract({ left: 290, top: 760, width: 40, height: 40 }) @@ -50,7 +51,7 @@ describe('SVG input', function () { }); }); - it('Convert SVG to PNG at DPI larger than 2400', function (done) { + it('Convert SVG to PNG at DPI larger than 2400', function (_t, done) { const size = 1024; sharp(fixtures.inputSvgSmallViewBox).metadata(function (err, metadata) { if (err) throw err; @@ -75,7 +76,7 @@ describe('SVG input', function () { }); }); - it('Convert SVG to PNG utilizing scale-on-load', function (done) { + it('Convert SVG to PNG utilizing scale-on-load', function (_t, done) { const size = 1024; sharp(fixtures.inputSvgSmallViewBox) .resize(size) @@ -96,7 +97,7 @@ describe('SVG input', function () { }); }); - it('Convert SVG to PNG at 14.4DPI', function (done) { + it('Convert SVG to PNG at 14.4DPI', function (_t, done) { sharp(fixtures.inputSvg, { density: 14.4 }) .toFormat('png') .toBuffer(function (err, data, info) { @@ -111,7 +112,7 @@ describe('SVG input', function () { }); }); - it('Convert SVG with embedded images to PNG, respecting dimensions, autoconvert to PNG', function (done) { + it('Convert SVG with embedded images to PNG, respecting dimensions, autoconvert to PNG', function (_t, done) { sharp(fixtures.inputSvgWithEmbeddedImages) .toBuffer(function (err, data, info) { if (err) throw err; diff --git a/test/unit/text.js b/test/unit/text.js index 25885997..3e5c0a92 100644 --- a/test/unit/text.js +++ b/test/unit/text.js @@ -1,6 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); @@ -8,9 +9,7 @@ const fixtures = require('../fixtures'); const { inRange } = require('../../lib/is'); describe('Text to image', function () { - this.retries(3); - - it('text with default values', async function () { + it('text with default values', async function (t) { const output = fixtures.path('output.text-default.png'); const text = sharp({ text: { @@ -18,7 +17,7 @@ describe('Text to image', function () { } }); if (!sharp.versions.pango) { - return this.skip(); + return t.skip(); } const info = await text.png().toFile(output); assert.strictEqual('png', info.format); @@ -40,7 +39,7 @@ describe('Text to image', function () { assert.ok(info.textAutofitDpi > 0); }); - it('text with width and height', function (done) { + it('text with width and height', function (t, done) { const output = fixtures.path('output.text-width-height.png'); const text = sharp({ text: { @@ -50,7 +49,7 @@ describe('Text to image', function () { } }); if (!sharp.versions.pango) { - return this.skip(); + return t.skip(); } text.toFile(output, function (err, info) { if (err) throw err; @@ -63,7 +62,7 @@ describe('Text to image', function () { }); }); - it('text with dpi', function (done) { + it('text with dpi', function (t, done) { const output = fixtures.path('output.text-dpi.png'); const dpi = 300; const text = sharp({ @@ -73,7 +72,7 @@ describe('Text to image', function () { } }); if (!sharp.versions.pango) { - return this.skip(); + return t.skip(); } text.toFile(output, function (err, info) { if (err) throw err; @@ -86,7 +85,7 @@ describe('Text to image', function () { }); }); - it('text with color and pango markup', function (done) { + it('text with color and pango markup', function (t, done) { const output = fixtures.path('output.text-color-pango.png'); const dpi = 300; const text = sharp({ @@ -97,7 +96,7 @@ describe('Text to image', function () { } }); if (!sharp.versions.pango) { - return this.skip(); + return t.skip(); } text.toFile(output, function (err, info) { if (err) throw err; @@ -113,7 +112,7 @@ describe('Text to image', function () { }); }); - it('text with font', function (done) { + it('text with font', function (t, done) { const output = fixtures.path('output.text-with-font.png'); const text = sharp({ text: { @@ -122,7 +121,7 @@ describe('Text to image', function () { } }); if (!sharp.versions.pango) { - return this.skip(); + return t.skip(); } text.toFile(output, function (err, info) { if (err) throw err; @@ -134,7 +133,7 @@ describe('Text to image', function () { }); }); - it('text with justify and composite', function (done) { + it('text with justify and composite', function (t, done) { const output = fixtures.path('output.text-composite.png'); const width = 500; const dpi = 300; @@ -166,7 +165,7 @@ describe('Text to image', function () { top: 250 }]); if (!sharp.versions.pango) { - return this.skip(); + return t.skip(); } text.toFile(output, function (err, info) { if (err) throw err; diff --git a/test/unit/threshold.js b/test/unit/threshold.js index acd8add2..350bf0b4 100644 --- a/test/unit/threshold.js +++ b/test/unit/threshold.js @@ -1,13 +1,14 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); describe('Threshold', function () { - it('threshold 1 jpeg', function (done) { + it('threshold 1 jpeg', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .threshold(1) @@ -20,7 +21,7 @@ describe('Threshold', function () { }); }); - it('threshold 40 jpeg', function (done) { + it('threshold 40 jpeg', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .threshold(40) @@ -33,7 +34,7 @@ describe('Threshold', function () { }); }); - it('threshold 128', function (done) { + it('threshold 128', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .threshold(128) @@ -46,7 +47,7 @@ describe('Threshold', function () { }); }); - it('threshold true (=128)', function (done) { + it('threshold true (=128)', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .threshold(true) @@ -59,7 +60,7 @@ describe('Threshold', function () { }); }); - it('threshold false (=0)', function (done) { + it('threshold false (=0)', function (_t, done) { sharp(fixtures.inputJpg) .threshold(false) .toBuffer(function (err, data) { @@ -68,7 +69,7 @@ describe('Threshold', function () { }); }); - it('threshold grayscale: true (=128)', function (done) { + it('threshold grayscale: true (=128)', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .threshold(128, { grayscale: true }) @@ -81,7 +82,7 @@ describe('Threshold', function () { }); }); - it('threshold default jpeg', function (done) { + it('threshold default jpeg', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .threshold() @@ -94,7 +95,7 @@ describe('Threshold', function () { }); }); - it('threshold default png transparency', function (done) { + it('threshold default png transparency', function (_t, done) { sharp(fixtures.inputPngWithTransparency) .resize(320, 240) .threshold() @@ -107,7 +108,7 @@ describe('Threshold', function () { }); }); - it('threshold default png alpha', function (done) { + it('threshold default png alpha', function (_t, done) { sharp(fixtures.inputPngWithGreyAlpha) .resize(320, 240) .threshold() @@ -120,7 +121,7 @@ describe('Threshold', function () { }); }); - it('threshold default webp transparency', function (done) { + it('threshold default webp transparency', function (_t, done) { sharp(fixtures.inputWebPWithTransparency) .threshold() .toBuffer(function (err, data, info) { @@ -130,7 +131,7 @@ describe('Threshold', function () { }); }); - it('color threshold', function (done) { + it('color threshold', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .threshold(128, { grayscale: false }) diff --git a/test/unit/tiff.js b/test/unit/tiff.js index d4243aa5..8113d5a1 100644 --- a/test/unit/tiff.js +++ b/test/unit/tiff.js @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 const fs = require('node:fs'); +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); @@ -10,7 +11,7 @@ const fixtures = require('../fixtures'); const outputTiff = fixtures.path('output.tiff'); describe('TIFF', function () { - it('Load TIFF from Buffer', function (done) { + it('Load TIFF from Buffer', function (_t, done) { const inputTiffBuffer = fs.readFileSync(fixtures.inputTiff); sharp(inputTiffBuffer) .resize(320, 240) @@ -26,7 +27,7 @@ describe('TIFF', function () { }); }); - it('Load multi-page TIFF from file', function (done) { + it('Load multi-page TIFF from file', function (_t, done) { sharp(fixtures.inputTiffMultipage) // defaults to page 0 .jpeg() .toBuffer(function (err, defaultData, defaultInfo) { @@ -49,7 +50,7 @@ describe('TIFF', function () { }); }); - it('Load multi-page TIFF from Buffer', function (done) { + it('Load multi-page TIFF from Buffer', function (_t, done) { const inputTiffBuffer = fs.readFileSync(fixtures.inputTiffMultipage); sharp(inputTiffBuffer) // defaults to page 0 .jpeg() @@ -73,7 +74,7 @@ describe('TIFF', function () { }); }); - it('Save TIFF to Buffer', function (done) { + it('Save TIFF to Buffer', function (_t, done) { sharp(fixtures.inputTiff) .resize(320, 240) .toBuffer(function (err, data, info) { @@ -114,7 +115,7 @@ describe('TIFF', function () { }); }); - it('Not squashing TIFF to a bit depth of 1 should not change the file size', function (done) { + it('Not squashing TIFF to a bit depth of 1 should not change the file size', function (_t, done) { const startSize = fs.statSync(fixtures.inputTiff8BitDepth).size; sharp(fixtures.inputTiff8BitDepth) .toColourspace('b-w') // can only squash 1 band uchar images @@ -131,7 +132,7 @@ describe('TIFF', function () { }); }); - it('Squashing TIFF to a bit depth of 1 should significantly reduce file size', function (done) { + it('Squashing TIFF to a bit depth of 1 should significantly reduce file size', function (_t, done) { const startSize = fs.statSync(fixtures.inputTiff8BitDepth).size; sharp(fixtures.inputTiff8BitDepth) .toColourspace('b-w') // can only squash 1 band uchar images @@ -219,7 +220,7 @@ describe('TIFF', function () { }); }); - it('TIFF lzw compression with horizontal predictor shrinks test file', function (done) { + it('TIFF lzw compression with horizontal predictor shrinks test file', function (_t, done) { const startSize = fs.statSync(fixtures.inputTiffUncompressed).size; sharp(fixtures.inputTiffUncompressed) .tiff({ @@ -271,7 +272,7 @@ describe('TIFF', function () { }) ); - it('TIFF ccittfax4 compression shrinks b-w test file', function (done) { + it('TIFF ccittfax4 compression shrinks b-w test file', function (_t, done) { const startSize = fs.statSync(fixtures.inputTiff).size; sharp(fixtures.inputTiff) .toColourspace('b-w') @@ -311,7 +312,7 @@ describe('TIFF', function () { assert.strictEqual(resolutionUnit, 'cm'); }); - it('TIFF deflate compression with horizontal predictor shrinks test file', function (done) { + it('TIFF deflate compression with horizontal predictor shrinks test file', function (_t, done) { const startSize = fs.statSync(fixtures.inputTiffUncompressed).size; sharp(fixtures.inputTiffUncompressed) .tiff({ @@ -326,7 +327,7 @@ describe('TIFF', function () { }); }); - it('TIFF deflate compression with float predictor shrinks test file', function (done) { + it('TIFF deflate compression with float predictor shrinks test file', function (_t, done) { const startSize = fs.statSync(fixtures.inputTiffUncompressed).size; sharp(fixtures.inputTiffUncompressed) .tiff({ @@ -341,7 +342,7 @@ describe('TIFF', function () { }); }); - it('TIFF deflate compression without predictor shrinks test file', function (done) { + it('TIFF deflate compression without predictor shrinks test file', function (_t, done) { const startSize = fs.statSync(fixtures.inputTiffUncompressed).size; sharp(fixtures.inputTiffUncompressed) .tiff({ @@ -356,7 +357,7 @@ describe('TIFF', function () { }); }); - it('TIFF jpeg compression shrinks test file', function (done) { + it('TIFF jpeg compression shrinks test file', function (_t, done) { const startSize = fs.statSync(fixtures.inputTiffUncompressed).size; sharp(fixtures.inputTiffUncompressed) .tiff({ @@ -430,7 +431,7 @@ describe('TIFF', function () { }); }); - it('TIFF tiled pyramid image without compression enlarges test file', function (done) { + it('TIFF tiled pyramid image without compression enlarges test file', function (_t, done) { const startSize = fs.statSync(fixtures.inputTiffUncompressed).size; sharp(fixtures.inputTiffUncompressed) .tiff({ @@ -520,7 +521,7 @@ describe('TIFF', function () { }); }); - it('TIFF file input with invalid page fails gracefully', function (done) { + it('TIFF file input with invalid page fails gracefully', function (_t, done) { sharp(fixtures.inputTiffMultipage, { page: 2 }) .toBuffer(function (err) { assert.strictEqual(true, !!err); @@ -528,7 +529,7 @@ describe('TIFF', function () { }); }); - it('TIFF buffer input with invalid page fails gracefully', function (done) { + it('TIFF buffer input with invalid page fails gracefully', function (_t, done) { sharp(fs.readFileSync(fixtures.inputTiffMultipage), { page: 2 }) .toBuffer(function (err) { assert.strictEqual(true, !!err); diff --git a/test/unit/tile.js b/test/unit/tile.js index 90381f66..e496dba7 100644 --- a/test/unit/tile.js +++ b/test/unit/tile.js @@ -3,6 +3,7 @@ const fs = require('node:fs'); const path = require('node:path'); +const { describe, it } = require('node:test'); const assert = require('node:assert'); const extractZip = require('extract-zip'); @@ -329,7 +330,7 @@ describe('Tile', function () { }); if (sharp.format.dz.output.file) { - it('Deep Zoom layout', function (done) { + it('Deep Zoom layout', function (_t, done) { const directory = fixtures.path('output.dzi_files'); fs.rm(directory, { recursive: true }, function () { sharp(fixtures.inputJpg) @@ -345,7 +346,7 @@ describe('Tile', function () { }); }); - it('Deep Zoom layout with custom size+overlap', function (done) { + it('Deep Zoom layout with custom size+overlap', function (_t, done) { const directory = fixtures.path('output.512.dzi_files'); fs.rm(directory, { recursive: true }, function () { sharp(fixtures.inputJpg) @@ -367,7 +368,7 @@ describe('Tile', function () { }); }); - it('Deep Zoom layout with custom size+angle', function (done) { + it('Deep Zoom layout with custom size+angle', function (_t, done) { const directory = fixtures.path('output.512_90.dzi_files'); fs.rm(directory, { recursive: true }, function () { sharp(fixtures.inputJpg) @@ -401,7 +402,7 @@ describe('Tile', function () { }); }); - it('Deep Zoom layout with depth of one', function (done) { + it('Deep Zoom layout with depth of one', function (_t, done) { const directory = fixtures.path('output.512_depth_one.dzi_files'); fs.rm(directory, { recursive: true }, function () { sharp(fixtures.inputJpg) @@ -417,7 +418,7 @@ describe('Tile', function () { }); }); - it('Deep Zoom layout with depth of onepixel', function (done) { + it('Deep Zoom layout with depth of onepixel', function (_t, done) { const directory = fixtures.path('output.512_depth_onepixel.dzi_files'); fs.rm(directory, { recursive: true }, function () { sharp(fixtures.inputJpg) @@ -433,7 +434,7 @@ describe('Tile', function () { }); }); - it('Deep Zoom layout with depth of onetile', function (done) { + it('Deep Zoom layout with depth of onetile', function (_t, done) { const directory = fixtures.path('output.256_depth_onetile.dzi_files'); fs.rm(directory, { recursive: true }, function () { sharp(fixtures.inputJpg) @@ -449,7 +450,7 @@ describe('Tile', function () { }); }); - it('Deep Zoom layout with skipBlanks', function (done) { + it('Deep Zoom layout with skipBlanks', function (_t, done) { const directory = fixtures.path('output.256_skip_blanks.dzi_files'); fs.rm(directory, { recursive: true }, function () { sharp(fixtures.inputJpgOverlayLayer2) @@ -468,7 +469,7 @@ describe('Tile', function () { }); }); - it('Zoomify layout', function (done) { + it('Zoomify layout', function (_t, done) { const directory = fixtures.path('output.zoomify.dzi'); fs.rm(directory, { recursive: true }, function () { sharp(fixtures.inputJpg) @@ -492,7 +493,7 @@ describe('Tile', function () { }); }); - it('Zoomify layout with depth one', function (done) { + it('Zoomify layout with depth one', function (_t, done) { const directory = fixtures.path('output.zoomify.depth_one.dzi'); fs.rm(directory, { recursive: true }, function () { sharp(fixtures.inputJpg) @@ -513,7 +514,7 @@ describe('Tile', function () { }); }); - it('Zoomify layout with depth onetile', function (done) { + it('Zoomify layout with depth onetile', function (_t, done) { const directory = fixtures.path('output.zoomify.depth_onetile.dzi'); fs.rm(directory, { recursive: true }, function () { sharp(fixtures.inputJpg) @@ -534,7 +535,7 @@ describe('Tile', function () { }); }); - it('Zoomify layout with depth onepixel', function (done) { + it('Zoomify layout with depth onepixel', function (_t, done) { const directory = fixtures.path('output.zoomify.depth_onepixel.dzi'); fs.rm(directory, { recursive: true }, function () { sharp(fixtures.inputJpg) @@ -555,7 +556,7 @@ describe('Tile', function () { }); }); - it('Zoomify layout with skip blanks', function (done) { + it('Zoomify layout with skip blanks', function (_t, done) { const directory = fixtures.path('output.zoomify.skipBlanks.dzi'); fs.rm(directory, { recursive: true }, function () { sharp(fixtures.inputJpgOverlayLayer2) @@ -579,7 +580,7 @@ describe('Tile', function () { }); }); - it('Google layout', function (done) { + it('Google layout', function (_t, done) { const directory = fixtures.path('output.google.dzi'); fs.rm(directory, { recursive: true }, function () { sharp(fixtures.inputJpg) @@ -603,7 +604,7 @@ describe('Tile', function () { }); }); - it('Google layout with jpeg format', function (done) { + it('Google layout with jpeg format', function (_t, done) { const directory = fixtures.path('output.jpg.google.dzi'); fs.rm(directory, { recursive: true }, function () { sharp(fixtures.inputJpg) @@ -640,7 +641,7 @@ describe('Tile', function () { }); }); - it('Google layout with png format', function (done) { + it('Google layout with png format', function (_t, done) { const directory = fixtures.path('output.png.google.dzi'); fs.rm(directory, { recursive: true }, function () { sharp(fixtures.inputJpg) @@ -677,7 +678,7 @@ describe('Tile', function () { }); }); - it('Google layout with webp format', function (done) { + it('Google layout with webp format', function (_t, done) { const directory = fixtures.path('output.webp.google.dzi'); fs.rm(directory, { recursive: true }, function () { sharp(fixtures.inputJpg) @@ -715,7 +716,7 @@ describe('Tile', function () { }); }); - it('Google layout with depth one', function (done) { + it('Google layout with depth one', function (_t, done) { const directory = fixtures.path('output.google_depth_one.dzi'); fs.rm(directory, { recursive: true }, function () { sharp(fixtures.inputJpg) @@ -736,7 +737,7 @@ describe('Tile', function () { }); }); - it('Google layout with depth onetile', function (done) { + it('Google layout with depth onetile', function (_t, done) { const directory = fixtures.path('output.google_depth_onetile.dzi'); fs.rm(directory, { recursive: true }, function () { sharp(fixtures.inputJpg) @@ -757,7 +758,7 @@ describe('Tile', function () { }); }); - it('Google layout with default skip Blanks', function (done) { + it('Google layout with default skip Blanks', function (_t, done) { const directory = fixtures.path('output.google_depth_skipBlanks.dzi'); fs.rm(directory, { recursive: true }, function () { sharp(fixtures.inputPng) @@ -781,7 +782,7 @@ describe('Tile', function () { }); }); - it('Google layout with center image in tile', function (done) { + it('Google layout with center image in tile', function (_t, done) { const directory = fixtures.path('output.google_center.dzi'); fs.rm(directory, { recursive: true }, function () { sharp(fixtures.inputJpg) @@ -801,7 +802,7 @@ describe('Tile', function () { }); }); - it('Google layout with center image in tile centre', function (done) { + it('Google layout with center image in tile centre', function (_t, done) { const directory = fixtures.path('output.google_center.dzi'); fs.rm(directory, { recursive: true }, function () { sharp(fixtures.inputJpg) @@ -821,7 +822,7 @@ describe('Tile', function () { }); }); - it('IIIFv2 layout', function (done) { + it('IIIFv2 layout', function (_t, done) { const name = 'output.iiif.info'; const directory = fixtures.path(name); fs.rm(directory, { recursive: true }, function () { @@ -851,7 +852,7 @@ describe('Tile', function () { }); }); - it('IIIFv3 layout', function (done) { + it('IIIFv3 layout', function (_t, done) { const name = 'output.iiif3.info'; const directory = fixtures.path(name); fs.rm(directory, { recursive: true }, function () { @@ -882,7 +883,7 @@ describe('Tile', function () { }); }); - it('Write to ZIP container using file extension', function (done) { + it('Write to ZIP container using file extension', function (_t, done) { const container = fixtures.path('output.dz.container.zip'); const extractTo = fixtures.path('output.dz.container'); const directory = path.join(extractTo, 'output.dz.container_files'); @@ -903,13 +904,13 @@ describe('Tile', function () { .then(() => { assertDeepZoomTiles(directory, 256, 13, done); }) - .catch(done); + .catch(_t, done); }); }); }); }); - it('Write to ZIP container using container tile option', function (done) { + it('Write to ZIP container using container tile option', function (_t, done) { const container = fixtures.path('output.dz.containeropt.zip'); const extractTo = fixtures.path('output.dz.containeropt'); const directory = path.join(extractTo, 'output.dz.containeropt_files'); @@ -934,13 +935,13 @@ describe('Tile', function () { .then(() => { assertDeepZoomTiles(directory, 256, 13, done); }) - .catch(done); + .catch(_t, done); }); }); }); }); - it('Write ZIP container to Buffer', function (done) { + it('Write ZIP container to Buffer', function (_t, done) { const container = fixtures.path('output.dz.tiles.zip'); const extractTo = fixtures.path('output.dz.tiles'); const directory = path.join(extractTo, 'output.dz.tiles_files'); @@ -963,7 +964,7 @@ describe('Tile', function () { .then(() => { assertDeepZoomTiles(directory, 256, 13, done); }) - .catch(done); + .catch(_t, done); }); }); }); diff --git a/test/unit/timeout.js b/test/unit/timeout.js index 21782917..ed2012ac 100644 --- a/test/unit/timeout.js +++ b/test/unit/timeout.js @@ -1,6 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); diff --git a/test/unit/tint.js b/test/unit/tint.js index 93cf1777..1e2ccf52 100644 --- a/test/unit/tint.js +++ b/test/unit/tint.js @@ -1,6 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); @@ -10,7 +11,7 @@ const fixtures = require('../fixtures'); const maxDistance = 6; describe('Tint', function () { - it('tints rgb image red', function (done) { + it('tints rgb image red', function (_t, done) { const output = fixtures.path('output.tint-red.jpg'); sharp(fixtures.inputJpg) .resize(320, 240) @@ -23,7 +24,7 @@ describe('Tint', function () { }); }); - it('tints rgb image green', function (done) { + it('tints rgb image green', function (_t, done) { const output = fixtures.path('output.tint-green.jpg'); sharp(fixtures.inputJpg) .resize(320, 240) @@ -36,7 +37,7 @@ describe('Tint', function () { }); }); - it('tints rgb image blue', function (done) { + it('tints rgb image blue', function (_t, done) { const output = fixtures.path('output.tint-blue.jpg'); sharp(fixtures.inputJpg) .resize(320, 240) @@ -49,7 +50,7 @@ describe('Tint', function () { }); }); - it('tints rgb image with sepia tone', function (done) { + it('tints rgb image with sepia tone', function (_t, done) { const output = fixtures.path('output.tint-sepia-hex.jpg'); sharp(fixtures.inputJpg) .resize(320, 240) @@ -63,7 +64,7 @@ describe('Tint', function () { }); }); - it('tints rgb image with sepia tone with rgb colour', function (done) { + it('tints rgb image with sepia tone with rgb colour', function (_t, done) { const output = fixtures.path('output.tint-sepia-rgb.jpg'); sharp(fixtures.inputJpg) .resize(320, 240) @@ -77,7 +78,7 @@ describe('Tint', function () { }); }); - it('tints rgb image with alpha channel', function (done) { + it('tints rgb image with alpha channel', function (_t, done) { const output = fixtures.path('output.tint-alpha.png'); sharp(fixtures.inputPngRGBWithAlpha) .resize(320, 240) @@ -91,7 +92,7 @@ describe('Tint', function () { }); }); - it('tints cmyk image red', function (done) { + it('tints cmyk image red', function (_t, done) { const output = fixtures.path('output.tint-cmyk.jpg'); sharp(fixtures.inputJpgWithCmykProfile) .resize(320, 240) diff --git a/test/unit/toBuffer.js b/test/unit/toBuffer.js index 163f284b..40b2b004 100644 --- a/test/unit/toBuffer.js +++ b/test/unit/toBuffer.js @@ -1,6 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); diff --git a/test/unit/toFormat.js b/test/unit/toFormat.js index 089a797e..1d28efea 100644 --- a/test/unit/toFormat.js +++ b/test/unit/toFormat.js @@ -1,6 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); diff --git a/test/unit/trim.js b/test/unit/trim.js index 6261a866..b6b95e85 100644 --- a/test/unit/trim.js +++ b/test/unit/trim.js @@ -1,6 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); @@ -8,7 +9,7 @@ const inRange = require('../../lib/is').inRange; const fixtures = require('../fixtures'); describe('Trim borders', function () { - it('Skip shrink-on-load', function (done) { + it('Skip shrink-on-load', function (_t, done) { const expected = fixtures.expected('alpha-layer-2-trim-resize.jpg'); sharp(fixtures.inputJpgOverlayLayer2) .trim() @@ -41,7 +42,7 @@ describe('Trim borders', function () { }) ); - it('16-bit PNG with alpha channel', function (done) { + it('16-bit PNG with alpha channel', function (_t, done) { sharp(fixtures.inputPngWithTransparency16bit) .resize(32, 32) .trim({ @@ -60,7 +61,7 @@ describe('Trim borders', function () { }); }); - it('Attempt to trim 2x2 pixel image fails', function (done) { + it('Attempt to trim 2x2 pixel image fails', function (_t, done) { sharp({ create: { width: 2, @@ -78,7 +79,7 @@ describe('Trim borders', function () { assert.strictEqual('Image to trim must be at least 3x3 pixels', err.message); done(); }) - .catch(done); + .catch(_t, done); }); it('Should rotate before trim', () => diff --git a/test/unit/unflatten.js b/test/unit/unflatten.js index b7941cf5..1759353a 100644 --- a/test/unit/unflatten.js +++ b/test/unit/unflatten.js @@ -1,25 +1,26 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const sharp = require('../../'); const fixtures = require('../fixtures'); describe('Unflatten', function () { - it('unflatten white background', function (done) { + it('unflatten white background', function (_t, done) { sharp(fixtures.inputPng).unflatten() .toBuffer(function (err, data) { if (err) throw err; fixtures.assertSimilar(fixtures.expected('unflatten-white-transparent.png'), data, { threshold: 0 }, done); }); }); - it('unflatten transparent image', function (done) { + it('unflatten transparent image', function (_t, done) { sharp(fixtures.inputPngTrimSpecificColourIncludeAlpha).unflatten() .toBuffer(function (err, data) { if (err) throw err; fixtures.assertSimilar(fixtures.expected('unflatten-flag-white-transparent.png'), data, { threshold: 0 }, done); }); }); - it('unflatten using threshold', function (done) { + it('unflatten using threshold', function (_t, done) { sharp(fixtures.inputPngPalette).unflatten().threshold(128, { grayscale: false }) .toBuffer(function (err, data) { if (err) throw err; diff --git a/test/unit/util.js b/test/unit/util.js index e29109ca..db74405c 100644 --- a/test/unit/util.js +++ b/test/unit/util.js @@ -1,13 +1,14 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 +const { describe, it } = require('node:test'); const assert = require('node:assert'); const semver = require('semver'); const sharp = require('../../'); describe('Utilities', function () { describe('Cache', function () { - it('Can be disabled', function (done) { + it('Can be disabled', function (_t, done) { const check = setInterval(() => { const cache = sharp.cache(false); const empty = @@ -75,7 +76,7 @@ describe('Utilities', function () { }); describe('Counters', function () { - it('Have zero value at rest', (done) => { + it('Have zero value at rest', (_t, done) => { queueMicrotask(() => { const counters = sharp.counters(); assert.strictEqual(0, counters.queue); diff --git a/test/unit/webp.js b/test/unit/webp.js index 32f45f4e..e3d51cca 100644 --- a/test/unit/webp.js +++ b/test/unit/webp.js @@ -2,13 +2,14 @@ // SPDX-License-Identifier: Apache-2.0 const fs = require('node:fs'); +const { describe, it } = require('node:test'); const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); describe('WebP', function () { - it('WebP output', function (done) { + it('WebP output', function (_t, done) { sharp(fixtures.inputJpg) .resize(320, 240) .toFormat(sharp.format.webp) @@ -34,7 +35,7 @@ describe('WebP', function () { }); }); - it('should work for webp alpha quality', function (done) { + it('should work for webp alpha quality', function (_t, done) { sharp(fixtures.inputPngAlphaPremultiplicationSmall) .webp({ alphaQuality: 80, effort: 0 }) .toBuffer(function (err, data, info) { @@ -45,7 +46,7 @@ describe('WebP', function () { }); }); - it('should work for webp lossless', function (done) { + it('should work for webp lossless', function (_t, done) { sharp(fixtures.inputPngAlphaPremultiplicationSmall) .webp({ lossless: true, effort: 0 }) .toBuffer(function (err, data, info) { @@ -56,7 +57,7 @@ describe('WebP', function () { }); }); - it('should work for webp near-lossless', function (done) { + it('should work for webp near-lossless', function (_t, done) { sharp(fixtures.inputPngAlphaPremultiplicationSmall) .webp({ nearLossless: true, quality: 50, effort: 0 }) .toBuffer(function (err50, data50, info50) { @@ -67,7 +68,7 @@ describe('WebP', function () { }); }); - it('should use near-lossless when both lossless and nearLossless are specified', function (done) { + it('should use near-lossless when both lossless and nearLossless are specified', function (_t, done) { sharp(fixtures.inputPngAlphaPremultiplicationSmall) .webp({ nearLossless: true, quality: 50, lossless: true, effort: 0 }) .toBuffer(function (err50, data50, info50) { @@ -269,7 +270,7 @@ describe('WebP', function () { assert.deepStrictEqual(updated.delay, [120, 120, 90, 120, 120, 90, 120, 90, 30]); }); - it('should work with streams when only animated is set', function (done) { + it('should work with streams when only animated is set', function (_t, done) { fs.createReadStream(fixtures.inputWebPAnimated) .pipe(sharp({ animated: true })) .webp({ lossless: true, effort: 0 }) @@ -281,7 +282,7 @@ describe('WebP', function () { }); }); - it('should work with streams when only pages is set', function (done) { + it('should work with streams when only pages is set', function (_t, done) { fs.createReadStream(fixtures.inputWebPAnimated) .pipe(sharp({ pages: -1 })) .webp({ lossless: true, effort: 0 })