UNPKG

faux-jax-tulios

Version:

Fork using latest mitm for node 10 - Intercept and respond to requests in the browser (XMLHttpRequest, XDomainRequest) and Node.js (http(s) module)

28 lines (23 loc) 712 B
var test = require('tape'); var XMLHttpRequest = require('../../../lib/XMLHttpRequest/'); test('xhr.getAllResponseHeaders() sends empty string when no headers', function(t) { var xhr = new XMLHttpRequest(); t.equal('', xhr.getAllResponseHeaders(), 'we get an empty string'); t.end(); }); test('xhr.getAllResponseHeaders() sends all response headers when present', function(t) { var headers = { 'how': 'dy', 'hai': 'oh' }; var xhr = new XMLHttpRequest(); xhr.open('GET', '/'); xhr.send(); xhr.respond(200, headers); t.equal( xhr.getAllResponseHeaders(), 'how: dy\r\nhai: oh\r\n', 'We get all the response headers in a string, formatted accordingly' ); t.end(); });