Commit 860b73c1 860b73c128f6c7348e3996d2a34f841496ef7bcd by oncletom Committed by Nicolas Perriault

Tests for the new API

1 parent a97c3562
casper.test.comment('Casper.getCurrentHeader()');
casper.test.comment('Casper.headers.get()');
var server = require('webserver').create();
var service = server.listen(8090, function (request, response) {
......@@ -15,21 +15,21 @@ var service = server.listen(8090, function (request, response) {
function dumpHeaders () {
casper.test.comment('Dumping current response headers');
casper.getCurrentHeaders().forEach(function (header) {
casper.currentResponse.headers.forEach(function (header) {
casper.test.comment('- ' + header.name + ': ' + header.value);
});
}
casper.start('tests/site/index.html', function thenLocalPage () {
this.test.assertEquals(casper.getCurrentHeader('Status'), null, 'No Status header on local page');
this.test.assertEquals(casper.getCurrentHeader('Content-Language'), null, 'No Content-Language on local page');
this.test.assert(casper.getCurrentHeaders().length === 0, 'No headers sent back');
this.test.assertEquals(casper.currentResponse, undefined, 'No response available on local page');
});
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');
var headers = casper.currentResponse.headers;
this.test.assertEquals(headers.get('Content-Language'), 'en', 'Checking existing header');
this.test.assertEquals(headers.get('content-language'), null, 'Checking header typecase');
this.test.assertEquals(headers.get('X-Is-Troll'), null, 'Checking unexisting header');
});
casper.run(function () {
......