Test custom inspect function for `Header` (#1017)

This commit is contained in:
Travis D. Warlick, Jr 2021-01-01 00:39:48 -05:00 committed by GitHub
parent cb032ea44f
commit 4abbfd231f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -1,3 +1,4 @@
import util from 'util';
import {Headers} from '../src/index.js';
import chai from 'chai';
import chaiIterator from 'chai-iterator';
@ -232,4 +233,17 @@ describe('Headers', () => {
expect(() => new Headers('b2')).to.throw(TypeError);
expect(() => new Headers({[Symbol.iterator]: 42})).to.throw(TypeError);
});
it('should use a custom inspect function', () => {
const headers = new Headers([
['Host', 'thehost'],
['Host', 'notthehost'],
['a', '1'],
['b', '2'],
['a', '3']
]);
// eslint-disable-next-line quotes
expect(util.format(headers)).to.equal("{ a: [ '1', '3' ], b: '2', host: 'thehost' }");
});
});