|
|
|
describe("parsing response headers", function() { |
|
|
|
|
|
var lfcr = "\u000d\u000a"; |
|
|
|
it('can parse an empty string', function(){ |
|
|
|
var parsed = parseResponseHeaders(''); |
|
|
|
expect(parsed).toEqual({}) |
|
}) |
|
|
|
it('can parse a single header', function(){ |
|
|
|
var parsed = parseResponseHeaders('x-powered-by: Express'); |
|
|
|
expect(parsed).toEqual({'x-powered-by':'Express'}) |
|
}); |
|
|
|
it('can parse a value containing ": "', function(){ |
|
|
|
var parsed = parseResponseHeaders('x-title: Episode 2: Another episode'); |
|
|
|
expect(parsed).toEqual({'x-title':'Episode 2: Another episode'}) |
|
}); |
|
|
|
it('can parse several headers', function(){ |
|
|
|
var subject = "x-powered-by: Express" + lfcr + |
|
"Transfer-Encoding: Identity" + lfcr + |
|
"Connection: keep-alive"; |
|
|
|
var parsed = parseResponseHeaders(subject); |
|
|
|
expect(parsed).toEqual({ |
|
"x-powered-by": "Express" |
|
, "Transfer-Encoding": "Identity" |
|
, "Connection": "keep-alive" |
|
}) |
|
}) |
|
|
|
}); |