From 48f2450020418ea529f8d1686d3e51aaeca00817 Mon Sep 17 00:00:00 2001 From: Stefan Guggisberg Date: Tue, 2 Jan 2024 15:39:10 +0100 Subject: [PATCH] fix: remove conflicting chai dependencies --- package-lock.json | 116 +++---------------------------------- package.json | 1 - test/fetch/headers.test.js | 47 ++++++++++----- 3 files changed, 39 insertions(+), 125 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4f839f6..ea8d0b3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,16 +11,13 @@ "dependencies": { "debug": "4.3.4", "http-cache-semantics": "4.1.1", - "lru-cache": "7.18.3" + "lru-cache": "10.1.0" }, "devDependencies": { "@semantic-release/changelog": "6.0.3", "@semantic-release/git": "10.0.1", "c8": "8.0.1", "chai": "5.0.0", - "chai-as-promised": "7.1.1", - "chai-bytes": "0.1.2", - "chai-iterator": "3.0.2", "eslint": "8.56.0", "eslint-config-airbnb-base": "15.0.0", "eslint-plugin-header": "3.1.1", @@ -1677,42 +1674,6 @@ "node": ">=12" } }, - "node_modules/chai-as-promised": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/chai-as-promised/-/chai-as-promised-7.1.1.tgz", - "integrity": "sha512-azL6xMoi+uxu6z4rhWQ1jbdUhOMhis2PvscD/xjLqNMkv3BPPp2JyyuTHOrf9BOosGpNQ11v6BKv/g57RXbiaA==", - "dev": true, - "dependencies": { - "check-error": "^1.0.2" - }, - "peerDependencies": { - "chai": ">= 2.1.2 < 5" - } - }, - "node_modules/chai-bytes": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/chai-bytes/-/chai-bytes-0.1.2.tgz", - "integrity": "sha512-0ol6oJS0y1ozj6AZK8n1pyv1/G+l44nqUJygAkK1UrYl+IOGie5vcrEdrAlwmLYGIA9NVvtHWosPYwWWIXf/XA==", - "dev": true, - "engines": { - "node": ">=4" - }, - "peerDependencies": { - "chai": ">=2 <5" - } - }, - "node_modules/chai-iterator": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/chai-iterator/-/chai-iterator-3.0.2.tgz", - "integrity": "sha512-7ZKEmBJRNSYUBMK0QC1sTzyhHHS67d1R3W3uu9MdehvPPzOEOrtmI6lmTO3CxiuMbeEEDozF1pnlEMraxKXLcg==", - "dev": true, - "engines": { - "node": ">=6.0" - }, - "peerDependencies": { - "chai": "4.x" - } - }, "node_modules/chai/node_modules/check-error": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.0.0.tgz", @@ -1747,18 +1708,6 @@ "node": ">=10" } }, - "node_modules/check-error": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.3.tgz", - "integrity": "sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==", - "dev": true, - "dependencies": { - "get-func-name": "^2.0.2" - }, - "engines": { - "node": "*" - } - }, "node_modules/chokidar": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", @@ -3564,15 +3513,6 @@ "node": "^16.14.0 || >=18.0.0" } }, - "node_modules/hosted-git-info/node_modules/lru-cache": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.0.1.tgz", - "integrity": "sha512-IJ4uwUTi2qCccrioU6g9g/5rvvVl13bsdczUUcqbciD9iLr095yj8DQKdObriEvuNSx325N1rV1O0sJFszx75g==", - "dev": true, - "engines": { - "node": "14 || >=16.14" - } - }, "node_modules/html-escaper": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", @@ -4770,11 +4710,11 @@ } }, "node_modules/lru-cache": { - "version": "7.18.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz", - "integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==", + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.1.0.tgz", + "integrity": "sha512-/1clY/ui8CzjKFyjdvwPWJUYKiFVXG2I2cY0ssG7h4+hwk+XOIX7ZSG9Q7TW8TW3Kp3BUSqgFWBLgL4PJ+Blag==", "engines": { - "node": ">=12" + "node": "14 || >=16.14" } }, "node_modules/make-dir": { @@ -12379,29 +12319,6 @@ } } }, - "chai-as-promised": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/chai-as-promised/-/chai-as-promised-7.1.1.tgz", - "integrity": "sha512-azL6xMoi+uxu6z4rhWQ1jbdUhOMhis2PvscD/xjLqNMkv3BPPp2JyyuTHOrf9BOosGpNQ11v6BKv/g57RXbiaA==", - "dev": true, - "requires": { - "check-error": "^1.0.2" - } - }, - "chai-bytes": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/chai-bytes/-/chai-bytes-0.1.2.tgz", - "integrity": "sha512-0ol6oJS0y1ozj6AZK8n1pyv1/G+l44nqUJygAkK1UrYl+IOGie5vcrEdrAlwmLYGIA9NVvtHWosPYwWWIXf/XA==", - "dev": true, - "requires": {} - }, - "chai-iterator": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/chai-iterator/-/chai-iterator-3.0.2.tgz", - "integrity": "sha512-7ZKEmBJRNSYUBMK0QC1sTzyhHHS67d1R3W3uu9MdehvPPzOEOrtmI6lmTO3CxiuMbeEEDozF1pnlEMraxKXLcg==", - "dev": true, - "requires": {} - }, "chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -12418,15 +12335,6 @@ "integrity": "sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==", "dev": true }, - "check-error": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.3.tgz", - "integrity": "sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==", - "dev": true, - "requires": { - "get-func-name": "^2.0.2" - } - }, "chokidar": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", @@ -13755,14 +13663,6 @@ "dev": true, "requires": { "lru-cache": "^10.0.1" - }, - "dependencies": { - "lru-cache": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.0.1.tgz", - "integrity": "sha512-IJ4uwUTi2qCccrioU6g9g/5rvvVl13bsdczUUcqbciD9iLr095yj8DQKdObriEvuNSx325N1rV1O0sJFszx75g==", - "dev": true - } } }, "html-escaper": { @@ -14604,9 +14504,9 @@ } }, "lru-cache": { - "version": "7.18.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz", - "integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==" + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.1.0.tgz", + "integrity": "sha512-/1clY/ui8CzjKFyjdvwPWJUYKiFVXG2I2cY0ssG7h4+hwk+XOIX7ZSG9Q7TW8TW3Kp3BUSqgFWBLgL4PJ+Blag==" }, "make-dir": { "version": "4.0.0", diff --git a/package.json b/package.json index 9be2213..c2c6d05 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,6 @@ "@semantic-release/git": "10.0.1", "c8": "8.0.1", "chai": "5.0.0", - "chai-iterator": "3.0.2", "eslint": "8.56.0", "eslint-config-airbnb-base": "15.0.0", "eslint-plugin-header": "3.1.1", diff --git a/test/fetch/headers.test.js b/test/fetch/headers.test.js index 011e7de..620a761 100644 --- a/test/fetch/headers.test.js +++ b/test/fetch/headers.test.js @@ -14,13 +14,10 @@ /* eslint-disable no-unused-expressions */ /* eslint-disable guard-for-in */ -import { expect, use } from 'chai'; -import chaiIterator from 'chai-iterator'; - +import { expect, assert } from 'chai'; import { Headers } from '../../src/index.js'; -use(chaiIterator); -// const { expect } = chai; +const isIterable = (obj) => obj != null && typeof obj[Symbol.iterator] === 'function'; describe('Headers Tests', () => { it('overrides toStringTag', () => { @@ -83,7 +80,7 @@ describe('Headers Tests', () => { ['a', '1'], ]); headers.append('b', '3'); - expect(headers).to.be.iterable; + assert(isIterable(headers)); const result = []; for (const pair of headers) { @@ -105,12 +102,18 @@ describe('Headers Tests', () => { ]); headers.append('b', '3'); - expect(headers.entries()).to.be.iterable - .and.to.deep.iterate.over([ - ['a', '1'], - ['b', '2, 3'], - ['c', '4'], - ]); + assert(isIterable(headers.entries())); + + const result = []; + for (const entry of headers.entries()) { + result.push(entry); + } + + expect(result).to.deep.equal([ + ['a', '1'], + ['b', '2, 3'], + ['c', '4'], + ]); }); it('should allow iterating through all headers with keys()', () => { @@ -121,8 +124,14 @@ describe('Headers Tests', () => { ]); headers.append('b', '3'); - expect(headers.keys()).to.be.iterable - .and.to.iterate.over(['a', 'b', 'c']); + assert(isIterable(headers.keys())); + + const result = []; + for (const key of headers.keys()) { + result.push(key); + } + + expect(result).to.deep.equal(['a', 'b', 'c']); }); it('should allow iterating through all headers with values()', () => { @@ -133,8 +142,14 @@ describe('Headers Tests', () => { ]); headers.append('b', '3'); - expect(headers.values()).to.be.iterable - .and.to.iterate.over(['1', '2, 3', '4']); + assert(isIterable(headers.values())); + + const result = []; + for (const val of headers.values()) { + result.push(val); + } + + expect(result).to.deep.equal(['1', '2, 3', '4']); }); it('should reject illegal header', () => {