From bdf0cb2cab57fda05dea1fc975250c02e0f877a7 Mon Sep 17 00:00:00 2001 From: Jesse Wright <63333554+jeswr@users.noreply.github.com> Date: Sun, 22 Sep 2024 01:24:37 +0200 Subject: [PATCH] chore: lint jest functionality (#452) * chore: lint jest functionality * chore: fix test * chore: only lint on node 22 --- .eslintrc | 11 ++ .github/workflows/ci.yml | 20 ++- package-lock.json | 347 ++++++++++++++++++++++++++++++++++++++- package.json | 1 + test/N3Parser-test.js | 4 +- test/N3Store-test.js | 46 +++--- 6 files changed, 400 insertions(+), 29 deletions(-) diff --git a/.eslintrc b/.eslintrc index fab11b3d..fa1df297 100644 --- a/.eslintrc +++ b/.eslintrc @@ -8,11 +8,22 @@ sourceType: "module", }, + plugins: [ + 'jest', + ], + extends: [ 'plugin:import/recommended', + 'plugin:jest/recommended' ], rules: { + "jest/no-standalone-expect": 0, + "jest/expect-expect": 0, + "jest/no-done-callback": 0, + "jest/no-identical-title": 0, + "jest/no-conditional-expect": 0, + // Possible Errors comma-dangle: [2, "always-multiline"], no-cond-assign: 0, diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7a6a212d..406508d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,9 +17,24 @@ jobs: - uses: actions/checkout@v4 - run: npm ci --ignore-scripts - run: npm run build - - run: npm run lint - run: npm run test - + + lint: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + node-version: [22.x] + steps: + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + - uses: actions/checkout@v4 + - run: npm ci --ignore-scripts + - run: npm run build + - run: npm run lint + spec: runs-on: ubuntu-latest strategy: @@ -60,6 +75,7 @@ jobs: - test - spec - docs + - lint runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/v') steps: diff --git a/package-lock.json b/package-lock.json index 53f7941f..803ddf2e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,6 +25,7 @@ "docco": "^0.9.1", "eslint": "^8.57.0", "eslint-plugin-import": "^2.29.1", + "eslint-plugin-jest": "^28.8.3", "jest": "^29.7.0", "pre-commit": "^1.2.2", "rdf-isomorphic": "^1.3.1", @@ -3005,6 +3006,147 @@ "integrity": "sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==", "dev": true }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "8.6.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.6.0.tgz", + "integrity": "sha512-ZuoutoS5y9UOxKvpc/GkvF4cuEmpokda4wRg64JEia27wX+PysIE9q+lzDtlHHgblwUWwo5/Qn+/WyTUvDwBHw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.6.0", + "@typescript-eslint/visitor-keys": "8.6.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/types": { + "version": "8.6.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.6.0.tgz", + "integrity": "sha512-rojqFZGd4MQxw33SrOy09qIDS8WEldM8JWtKQLAjf/X5mGSeEFh5ixQlxssMNyPslVIk9yzWqXCsV2eFhYrYUw==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "8.6.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.6.0.tgz", + "integrity": "sha512-MOVAzsKJIPIlLK239l5s06YXjNqpKTVhBVDnqUumQJja5+Y94V3+4VUFRA0G60y2jNnTVwRCkhyGQpavfsbq/g==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "@typescript-eslint/types": "8.6.0", + "@typescript-eslint/visitor-keys": "8.6.0", + "debug": "^4.3.4", + "fast-glob": "^3.3.2", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^1.3.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "8.6.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.6.0.tgz", + "integrity": "sha512-eNp9cWnYf36NaOVjkEUznf6fEgVy1TWpE0o52e4wtojjBx7D1UV2WAWGzR+8Y5lVFtpMLPwNbC67T83DWSph4A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@typescript-eslint/scope-manager": "8.6.0", + "@typescript-eslint/types": "8.6.0", + "@typescript-eslint/typescript-estree": "8.6.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "8.6.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.6.0.tgz", + "integrity": "sha512-wapVFfZg9H0qOYh4grNVQiMklJGluQrOUiOhYRrQWhx7BY/+I1IYb8BczWNbbUpO+pqy0rDciv3lQH5E1bCLrg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.6.0", + "eslint-visitor-keys": "^3.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, "node_modules/@ungap/structured-clone": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", @@ -5197,6 +5339,32 @@ "node": ">=0.10.0" } }, + "node_modules/eslint-plugin-jest": { + "version": "28.8.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-28.8.3.tgz", + "integrity": "sha512-HIQ3t9hASLKm2IhIOqnu+ifw7uLZkIlR7RYNv7fMcEi/p0CIiJmfriStQS2LDkgtY4nyLbIZAD+JL347Yc2ETQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/utils": "^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "engines": { + "node": "^16.10.0 || ^18.12.0 || >=20.0.0" + }, + "peerDependencies": { + "@typescript-eslint/eslint-plugin": "^6.0.0 || ^7.0.0 || ^8.0.0", + "eslint": "^7.0.0 || ^8.0.0 || ^9.0.0", + "jest": "*" + }, + "peerDependenciesMeta": { + "@typescript-eslint/eslint-plugin": { + "optional": true + }, + "jest": { + "optional": true + } + } + }, "node_modules/eslint-scope": { "version": "7.2.2", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", @@ -5582,6 +5750,23 @@ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "dev": true }, + "node_modules/fast-glob": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", + "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.4" + }, + "engines": { + "node": ">=8.6.0" + } + }, "node_modules/fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", @@ -5886,7 +6071,6 @@ "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", "dev": true, - "optional": true, "dependencies": { "is-glob": "^4.0.1" }, @@ -8840,6 +9024,16 @@ "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", "dev": true }, + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, "node_modules/micromatch": { "version": "4.0.7", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.7.tgz", @@ -10950,6 +11144,19 @@ "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", "dev": true }, + "node_modules/ts-api-utils": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz", + "integrity": "sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "typescript": ">=4.2.0" + } + }, "node_modules/tsconfig-paths": { "version": "3.15.0", "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz", @@ -11102,6 +11309,21 @@ "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==", "dev": true }, + "node_modules/typescript": { + "version": "5.6.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz", + "integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==", + "dev": true, + "license": "Apache-2.0", + "peer": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "node_modules/uglify-js": { "version": "3.19.3", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.3.tgz", @@ -13742,6 +13964,86 @@ "integrity": "sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==", "dev": true }, + "@typescript-eslint/scope-manager": { + "version": "8.6.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.6.0.tgz", + "integrity": "sha512-ZuoutoS5y9UOxKvpc/GkvF4cuEmpokda4wRg64JEia27wX+PysIE9q+lzDtlHHgblwUWwo5/Qn+/WyTUvDwBHw==", + "dev": true, + "requires": { + "@typescript-eslint/types": "8.6.0", + "@typescript-eslint/visitor-keys": "8.6.0" + } + }, + "@typescript-eslint/types": { + "version": "8.6.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.6.0.tgz", + "integrity": "sha512-rojqFZGd4MQxw33SrOy09qIDS8WEldM8JWtKQLAjf/X5mGSeEFh5ixQlxssMNyPslVIk9yzWqXCsV2eFhYrYUw==", + "dev": true + }, + "@typescript-eslint/typescript-estree": { + "version": "8.6.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.6.0.tgz", + "integrity": "sha512-MOVAzsKJIPIlLK239l5s06YXjNqpKTVhBVDnqUumQJja5+Y94V3+4VUFRA0G60y2jNnTVwRCkhyGQpavfsbq/g==", + "dev": true, + "requires": { + "@typescript-eslint/types": "8.6.0", + "@typescript-eslint/visitor-keys": "8.6.0", + "debug": "^4.3.4", + "fast-glob": "^3.3.2", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^1.3.0" + }, + "dependencies": { + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0" + } + }, + "minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + } + }, + "semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true + } + } + }, + "@typescript-eslint/utils": { + "version": "8.6.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.6.0.tgz", + "integrity": "sha512-eNp9cWnYf36NaOVjkEUznf6fEgVy1TWpE0o52e4wtojjBx7D1UV2WAWGzR+8Y5lVFtpMLPwNbC67T83DWSph4A==", + "dev": true, + "requires": { + "@eslint-community/eslint-utils": "^4.4.0", + "@typescript-eslint/scope-manager": "8.6.0", + "@typescript-eslint/types": "8.6.0", + "@typescript-eslint/typescript-estree": "8.6.0" + } + }, + "@typescript-eslint/visitor-keys": { + "version": "8.6.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.6.0.tgz", + "integrity": "sha512-wapVFfZg9H0qOYh4grNVQiMklJGluQrOUiOhYRrQWhx7BY/+I1IYb8BczWNbbUpO+pqy0rDciv3lQH5E1bCLrg==", + "dev": true, + "requires": { + "@typescript-eslint/types": "8.6.0", + "eslint-visitor-keys": "^3.4.3" + } + }, "@ungap/structured-clone": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", @@ -15632,6 +15934,15 @@ } } }, + "eslint-plugin-jest": { + "version": "28.8.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-28.8.3.tgz", + "integrity": "sha512-HIQ3t9hASLKm2IhIOqnu+ifw7uLZkIlR7RYNv7fMcEi/p0CIiJmfriStQS2LDkgtY4nyLbIZAD+JL347Yc2ETQ==", + "dev": true, + "requires": { + "@typescript-eslint/utils": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, "eslint-scope": { "version": "7.2.2", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", @@ -15757,6 +16068,19 @@ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "dev": true }, + "fast-glob": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", + "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", + "dev": true, + "requires": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.4" + } + }, "fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", @@ -15985,7 +16309,6 @@ "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", "dev": true, - "optional": true, "requires": { "is-glob": "^4.0.1" } @@ -18140,6 +18463,12 @@ "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", "dev": true }, + "merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true + }, "micromatch": { "version": "4.0.7", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.7.tgz", @@ -19830,6 +20159,13 @@ "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", "dev": true }, + "ts-api-utils": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz", + "integrity": "sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==", + "dev": true, + "requires": {} + }, "tsconfig-paths": { "version": "3.15.0", "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz", @@ -19944,6 +20280,13 @@ "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==", "dev": true }, + "typescript": { + "version": "5.6.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz", + "integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==", + "dev": true, + "peer": true + }, "uglify-js": { "version": "3.19.3", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.3.tgz", diff --git a/package.json b/package.json index 12192493..45e5d377 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "docco": "^0.9.1", "eslint": "^8.57.0", "eslint-plugin-import": "^2.29.1", + "eslint-plugin-jest": "^28.8.3", "jest": "^29.7.0", "pre-commit": "^1.2.2", "rdf-isomorphic": "^1.3.1", diff --git a/test/N3Parser-test.js b/test/N3Parser-test.js index 97b7ec62..0415bc9f 100644 --- a/test/N3Parser-test.js +++ b/test/N3Parser-test.js @@ -983,7 +983,7 @@ describe('Parser', () => { it('should not parse a single opening brace', shouldNotParse('{', 'Unexpected "{" on line 1.')); - it('should not parse a superfluous closing brace ', shouldNotParse('{}}', + it('should not parse a superfluous closing brace', shouldNotParse('{}}', 'Unexpected graph closing on line 1.')); it('should not parse a graph with only a dot', shouldNotParse('{.}', @@ -1188,7 +1188,7 @@ describe('Parser', () => { }); it('should throw on syntax errors if no callback is given', () => { - expect((() => { new Parser().parse(' bar '); })).toThrowError('Unexpected "bar" on line 1.'); + expect((() => { new Parser().parse(' bar '); })).toThrow('Unexpected "bar" on line 1.'); }); it('should throw on grammar errors if no callback is given', () => { diff --git a/test/N3Store-test.js b/test/N3Store-test.js index 210c2ee7..2d85b059 100644 --- a/test/N3Store-test.js +++ b/test/N3Store-test.js @@ -1831,7 +1831,7 @@ describe('Store', () => { ).toBe(true); it('extractLists throws an error', () => { - expect(() => store.extractLists()).toThrowError('b0 has no list head'); + expect(() => store.extractLists()).toThrow('b0 has no list head'); }); }); @@ -1843,7 +1843,7 @@ describe('Store', () => { ).toBe(true); it('extractLists throws an error', () => { - expect(() => store.extractLists()).toThrowError('b2 has multiple rdf:first arcs'); + expect(() => store.extractLists()).toThrow('b2 has multiple rdf:first arcs'); }); }); @@ -1855,7 +1855,7 @@ describe('Store', () => { ).toBe(true); it('extractLists throws an error', () => { - expect(() => store.extractLists()).toThrowError('b3 has multiple rdf:first arcs'); + expect(() => store.extractLists()).toThrow('b3 has multiple rdf:first arcs'); }); }); @@ -1867,7 +1867,7 @@ describe('Store', () => { ).toBe(true); it('extractLists throws an error', () => { - expect(() => store.extractLists()).toThrowError('b2 has multiple rdf:rest arcs'); + expect(() => store.extractLists()).toThrow('b2 has multiple rdf:rest arcs'); }); }); @@ -1879,7 +1879,7 @@ describe('Store', () => { ).toBe(true); it('extractLists throws an error', () => { - expect(() => store.extractLists()).toThrowError('b3 has multiple rdf:rest arcs'); + expect(() => store.extractLists()).toThrow('b3 has multiple rdf:rest arcs'); }); }); @@ -1891,7 +1891,7 @@ describe('Store', () => { ).toBe(true); it('extractLists throws an error', () => { - expect(() => store.extractLists()).toThrowError('b4 can\'t be subject and object'); + expect(() => store.extractLists()).toThrow('b4 can\'t be subject and object'); }); }); @@ -1903,7 +1903,7 @@ describe('Store', () => { ).toBe(true); it('extractLists throws an error', () => { - expect(() => store.extractLists()).toThrowError('b4 has incoming rdf:rest arcs'); + expect(() => store.extractLists()).toThrow('b4 has incoming rdf:rest arcs'); }); }); @@ -1914,7 +1914,7 @@ describe('Store', () => { expect(store.addQuad(listElements[0], new NamedNode('p1'), new NamedNode('o2'))).toBe(true); it('extractLists throws an error', () => { - expect(() => store.extractLists()).toThrowError('b3 has non-list arcs out'); + expect(() => store.extractLists()).toThrow('b3 has non-list arcs out'); }); }); @@ -1928,7 +1928,7 @@ describe('Store', () => { expect(store.addQuad(new NamedNode('s2'), new NamedNode('p1'), listElements[0])).toBe(true); it('extractLists throws an error', () => { - expect(() => store.extractLists()).toThrowError('b3 can\'t have coreferences'); + expect(() => store.extractLists()).toThrow('b3 can\'t have coreferences'); }); }); @@ -1956,7 +1956,7 @@ describe('Store', () => { describe('extractLists without ignoreErrors', () => { it('extractLists throws an error', () => { - expect(() => store.extractLists()).toThrowError('b0 not confined to single graph'); + expect(() => store.extractLists()).toThrow('b0 not confined to single graph'); }); }); @@ -2174,11 +2174,11 @@ describe('Store', () => { expect(s1.intersection(s2).size).toBeLessThanOrEqual(s1.size); expect(s1.intersection(s2).size).toBeLessThanOrEqual(s2.size); expect(s1.intersection(s2)._graphs).toBeTruthy(); - expect(s1.intersection(s2).equals(s2.intersection(s1))); - expect(s1.union(s2).intersection(s1).equals(s1)); - expect(s1.intersection(s2).union(s1).equals(s1)); - expect(new Store([...s1.union(s2).intersection(s1)]).equals(new Store([...s1]))); - expect(new Store([...s1.intersection(s2).union(s1)]).equals(new Store([...s2]))); + expect(s1.intersection(s2).equals(s2.intersection(s1))).toBe(true); + expect(s1.union(s2).intersection(s1).equals(s1)).toBe(true); + expect(s1.intersection(s2).union(s1).equals(s1)).toBe(true); + expect(new Store([...s1.union(s2).intersection(s1)]).equals(new Store([...s1]))).toBe(true); + expect(new Store([...s1.intersection(s2).union(s1)]).equals(new Store([...s1]))).toBe(true); const newStore = s1.intersection(s2); const size = newStore.size; @@ -2237,8 +2237,8 @@ describe('Store', () => { it('should map over quads', () => { const quads = store1.map(quad => quad); expect(quads.size).toEqual(2); - expect(quads.contains(store1)); - expect(store1.contains(quads)); + expect(quads.contains(store1)).toBe(true); + expect(store1.contains(quads)).toBe(true); }); }); @@ -2261,11 +2261,11 @@ describe('Store', () => { }); describe('#toStream', () => { - it('should convert to a stream', () => { - expect(arrayifyStream(store2.toStream())).resolves.toEqual([q[0], q[2]]); - expect(arrayifyStream(store1.toStream())).resolves.toEqual([q[0], q[1]]); - expect(arrayifyStream(store.toStream())).resolves.toEqual([q[0]]); - expect(arrayifyStream(empty.toStream())).resolves.toEqual([]); + it('should convert to a stream', async () => { + await expect(arrayifyStream(store2.toStream())).resolves.toEqual([q[0], q[2]]); + await expect(arrayifyStream(store1.toStream())).resolves.toEqual([q[0], q[1]]); + await expect(arrayifyStream(store.toStream())).resolves.toEqual([q[0]]); + await expect(arrayifyStream(empty.toStream())).resolves.toEqual([]); }); }); @@ -2277,7 +2277,7 @@ describe('Store', () => { describe('#toCanonical', () => { it('should convert to a canonical string', () => { - expect(() => store1.toCanonical()).toThrowError('not implemented'); + expect(() => store1.toCanonical()).toThrow('not implemented'); }); });