Skip to content

Commit

Permalink
fix: remove conflicting chai dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-guggisberg committed Jan 2, 2024
1 parent ee155fa commit 48f2450
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 125 deletions.
116 changes: 8 additions & 108 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
47 changes: 31 additions & 16 deletions test/fetch/headers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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) {
Expand All @@ -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()', () => {
Expand All @@ -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()', () => {
Expand All @@ -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', () => {
Expand Down

0 comments on commit 48f2450

Please sign in to comment.