esi
esi copied to clipboard
Testing if a HTTP_COOKIE exists always returns true
This repo doesn't seem to be able to check for cookies.
Example:
I added this little simple test-case that checks if there's a cookie with the name "blargh"
it("should be able to check for a non-existant cookie", function(done){
var str = `<esi:choose><esi:when test="$exists($(HTTP_COOKIE{'blargh'}))">blargh cookie exists</esi:when><esi:otherwise>blargh cookie doesn't exist</esi:otherwise></esi:choose>`;
var output = ESI( str, null, {
HTTP_HOST : 'localhost'
});
expect(output).to.eventually.be.eql( "blargh cookie doesn't exist" ).and.notify(done);
});
Running the test with mocha gives me the output
AssertionError: expected 'blargh cookie exists' to deeply equal 'blargh cookie doesn\'t exist'
So I suspect that this esi-parser incorrectly returns true for all kinds of checks using exists and HTTP_COOKIE