我有摩卡,sinon和柴的测试服:
describe('general visor methods tests', () => {
let res, req, next, resSpy, resNext;
beforeEach(() => {
res = {};
next = () => {};
resSpy = res.json = sinon.spy();
resNext = next = sinon.spy();
});
afterEach(() => {
resSpy.restore();
resNext.reset();
});
describe('get basemap layers from owner model', () => {
it('should send the basemap provided by the owner model', () => {
owner.basemap = ['basemap1', 'basemap2'];
getBaseMapLayersFromConfig(req, res, next);
// console.log(resSpy.args[0][0].data);
expect(resSpy.calledOnce).to.eql(true);
expect(resSpy.args[0][0].message).to.eql('basemaps correctly found');
expect(resSpy.args[0][0].data).to.eql(['basemap1', 'basemap2']);
});
... …Run Code Online (Sandbox Code Playgroud) 我不知道如何访问参数x-error-detail-header.
我使用node-fetch npm包从请求中收到此响应头:
Headers {
[Symbol(map)]:
{ 'content-type': [ 'text/xml' ],
date: [ 'Fri, 27 Apr 2018 09:46:56 GMT' ],
'retry-after': [ '51184' ],
server: [ 'xxxxx' ],
'x-error-detail-header': [ 'Account Over Rate Limit' ],
'x-x-error-code': [ 'ERR_403_DEVELOPER_OVER_RATE' ],
'x-x-responder': [ 'xxxxxxx.com' ],
'x-plan-qps-allotted': [ '2' ],
'x-plan-qps-current': [ '1' ],
'x-plan-quota-allotted': [ '50' ],
'x-plan-quota-current': [ '51' ],
'x-plan-quota-reset': [ 'Saturday, April 28, 2018 12:00:00 AM GMT' ],
'content-length': [ '28' ],
connection: [ 'Close' ] } }
Run Code Online (Sandbox Code Playgroud)
我的问题是我不知道如何访问[Symbol(map)]对象内的参数.
javascript ×2
chai ×1
fetch ×1
json ×1
mocha.js ×1
node.js ×1
parsing ×1
sinon ×1
unit-testing ×1