Commit 0644fff6 0644fff699eb04c1784c909857ef8ffa2ce2a5cc by oncletom Committed by Nicolas Perriault

Expected headers on server request

1 parent 4949dad8
casper.test.comment('Casper.getCurrentHeader()');
function dumpHeaders() {
var server = require('webserver').create();
var service = server.listen(8090, function (request, response) {
response.statusCode = 200;
response.headers = {
'Content-Language': 'en',
'Content-Type': 'text/html',
'Date': new Date().toUTCString()
};
response.write("\o/");
response.close();
});
function dumpHeaders () {
casper.test.comment('Dumping current response headers');
casper.getCurrentHeaders().forEach(function(header){
casper.test.comment('- '+ header.name + ': '+ header.value);
casper.getCurrentHeaders().forEach(function (header) {
casper.test.comment('- ' + header.name + ': ' + header.value);
});
}
casper.start('tests/site/index.html', function then(){
this.test.assertEquals(casper.getCurrentHeader('Status'), null, 'No Status header on local page');
this.test.assert(casper.getCurrentHeaders().length === 0, 'No headers sent back');
casper.start('tests/site/index.html', function thenLocalPage () {
this.test.assertEquals(casper.getCurrentHeader('Status'), null, 'No Status header on local page');
this.test.assert(casper.getCurrentHeaders().length === 0, 'No headers sent back');
});
casper.thenOpen('http://localhost:8090/', function thenLocalhost () {
this.test.assertEquals(casper.getCurrentHeader('Content-Language'), 'en', 'Checking existing header');
this.test.assertEquals(casper.getCurrentHeader('content-language'), null, 'Checking header typecase');
this.test.assertEquals(casper.getCurrentHeader('X-Is-Troll'), null, 'Checking unexisting header');
});
casper.run(function(){
this.test.done();
casper.run(function () {
server.close();
this.test.done();
});
......