Skip to content

Commit 4abbfd2

Browse files
authored
Test custom inspect function for Header (node-fetch#1017)
1 parent cb032ea commit 4abbfd2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/headers.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import util from 'util';
12
import {Headers} from '../src/index.js';
23
import chai from 'chai';
34
import chaiIterator from 'chai-iterator';
@@ -232,4 +233,17 @@ describe('Headers', () => {
232233
expect(() => new Headers('b2')).to.throw(TypeError);
233234
expect(() => new Headers({[Symbol.iterator]: 42})).to.throw(TypeError);
234235
});
236+
237+
it('should use a custom inspect function', () => {
238+
const headers = new Headers([
239+
['Host', 'thehost'],
240+
['Host', 'notthehost'],
241+
['a', '1'],
242+
['b', '2'],
243+
['a', '3']
244+
]);
245+
246+
// eslint-disable-next-line quotes
247+
expect(util.format(headers)).to.equal("{ a: [ '1', '3' ], b: '2', host: 'thehost' }");
248+
});
235249
});

0 commit comments

Comments
 (0)