diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d4aaef5..8b10eda6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,6 @@ jobs: CI: permissions: contents: write # for npx prebuild to make release - checks: write # to create new checks (coverallsapp/github-action) name: ${{ matrix.container || matrix.os }} - Node.js ${{ matrix.nodejs_version }} ${{ matrix.nodejs_arch }} ${{ matrix.prebuild && '- prebuild' }} runs-on: ${{ matrix.os }} container: ${{ matrix.container }} @@ -18,7 +17,6 @@ jobs: - os: ubuntu-22.04 container: centos:7 nodejs_version: 14 - coverage: true prebuild: true - os: ubuntu-22.04 container: centos:7 @@ -95,11 +93,6 @@ jobs: run: npm install --build-from-source --unsafe-perm - name: Test run: npm test - - name: Coverage - if: matrix.coverage - uses: coverallsapp/github-action@1.1.3 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - name: Prebuild if: matrix.prebuild && startsWith(github.ref, 'refs/tags/') env: diff --git a/README.md b/README.md index ed167593..47b1b8ec 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,6 @@ readableStream A [guide for contributors](https://github.com/lovell/sharp/blob/main/.github/CONTRIBUTING.md) covers reporting bugs, requesting features and submitting code changes. -[![Test Coverage](https://coveralls.io/repos/lovell/sharp/badge.svg?branch=main)](https://coveralls.io/r/lovell/sharp?branch=main) [![Node-API v5](https://img.shields.io/badge/Node--API-v5-green.svg)](https://nodejs.org/dist/latest/docs/api/n-api.html#n_api_n_api_version_matrix) ## Licensing diff --git a/lib/resize.js b/lib/resize.js index e5bc4596..adc3324d 100644 --- a/lib/resize.js +++ b/lib/resize.js @@ -511,15 +511,12 @@ function trim (trim) { } } else if (is.object(trim)) { this._setBackgroundColourOption('trimBackground', trim.background); - if (!is.defined(trim.threshold)) { this.options.trimThreshold = 10; - } else if (is.number(trim.threshold)) { - if (trim.threshold >= 0) { - this.options.trimThreshold = trim.threshold; - } else { - throw is.invalidParameterError('threshold', 'positive number', trim); - } + } else if (is.number(trim.threshold) && trim.threshold >= 0) { + this.options.trimThreshold = trim.threshold; + } else { + throw is.invalidParameterError('threshold', 'positive number', trim); } } else { throw is.invalidParameterError('trim', 'string, number or object', trim); diff --git a/package.json b/package.json index dd1f6dcc..b81349c0 100644 --- a/package.json +++ b/package.json @@ -92,9 +92,8 @@ "clean": "rm -rf node_modules/ build/ vendor/ .nyc_output/ coverage/ test/fixtures/output.*", "test": "npm run test-lint && npm run test-unit && npm run test-licensing", "test-lint": "semistandard && cpplint", - "test-unit": "nyc --reporter=lcov --branches=99 mocha --slow=1000 --timeout=60000 ./test/unit/*.js", + "test-unit": "nyc --reporter=lcov --reporter=text --check-coverage --branches=100 mocha --slow=1000 --timeout=10000 ./test/unit/*.js", "test-licensing": "license-checker --production --summary --onlyAllow=\"Apache-2.0;BSD;ISC;MIT\"", - "test-coverage": "./test/coverage/report.sh", "test-leak": "./test/leak/leak.sh", "docs-build": "documentation lint lib && node docs/build && node docs/search-index/build", "docs-serve": "cd docs && npx serve", diff --git a/test/coverage/report.sh b/test/coverage/report.sh deleted file mode 100755 index 1c0b5459..00000000 --- a/test/coverage/report.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -CPPFLAGS="--coverage" LDFLAGS="--coverage" npm rebuild -npm test -geninfo --no-external --base-directory src --output-file coverage/sharp.info build/Release/obj.target/sharp/src -genhtml --title sharp --demangle-cpp --output-directory coverage/sharp coverage/*.info diff --git a/test/unit/text.js b/test/unit/text.js index d3803605..b8c80af9 100644 --- a/test/unit/text.js +++ b/test/unit/text.js @@ -175,12 +175,13 @@ describe('Text to image', () => { }); it('fontfile input', function () { - // Added for code coverage - sharp({ - text: { - text: 'text', - fontfile: 'UnknownFont.ttf' - } + assert.doesNotThrow(function () { + sharp({ + text: { + text: 'text', + fontfile: 'UnknownFont.ttf' + } + }); }); });