Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
94e51f43
...
94e51f4359c28ce258058e5219822e1180bc10c0
authored
2012-12-28 12:36:04 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
migrated http_status tests to new testing format
1 parent
53863ca3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
13 deletions
tests/suites/http_status.js
tests/suites/http_status.js
View file @
94e51f4
...
...
@@ -4,6 +4,8 @@
* Special test server to test for HTTP status codes
*
*/
var
fs
=
require
(
'fs'
);
var
utils
=
require
(
'utils'
);
var
server
=
require
(
'webserver'
).
create
();
var
service
=
server
.
listen
(
8090
,
function
(
request
,
response
)
{
var
code
=
parseInt
(
/^
\/(\d
+
)
$/
.
exec
(
request
.
url
)[
1
],
10
);
...
...
@@ -11,34 +13,36 @@ var service = server.listen(8090, function (request, response) {
response
.
write
(
""
);
response
.
close
();
});
var
fs
=
require
(
"fs"
);
casper
.
start
();
casper
.
test
.
begin
(
"HTTP status code handling"
,
109
,
function
(
test
)
{
casper
.
start
();
// file protocol
casper
.
thenOpen
(
'file://'
+
phantom
.
casperPath
+
'/tests/site/index.html'
,
function
()
{
// file protocol
casper
.
thenOpen
(
'file://'
+
phantom
.
casperPath
+
'/tests/site/index.html'
,
function
()
{
this
.
test
.
assertHttpStatus
(
null
,
'file:// protocol does not set a HTTP status'
);
});
});
// http protocol
var
codes
=
[
100
,
101
,
102
,
118
,
200
,
201
,
202
,
203
,
204
,
205
,
206
,
207
,
210
,
// http protocol
var
codes
=
[
100
,
101
,
102
,
118
,
200
,
201
,
202
,
203
,
204
,
205
,
206
,
207
,
210
,
300
,
301
,
302
,
303
,
304
,
305
,
307
,
310
,
400
,
401
,
402
,
403
,
404
,
405
,
406
,
407
,
408
,
409
,
410
,
411
,
412
,
413
,
414
,
415
,
416
,
417
,
418
,
422
,
423
,
424
,
425
,
426
,
449
,
450
,
500
,
501
,
502
,
503
,
504
,
505
,
507
,
509
];
casper
.
each
(
codes
,
function
(
self
,
code
)
{
casper
.
each
(
codes
,
function
(
self
,
code
)
{
if
(
code
===
100
)
{
// HTTP 100 is CONTINUE, so don't expect a terminated response
return
;
}
this
.
thenOpen
(
'http://localhost:8090/'
+
code
,
function
()
{
this
.
test
.
assertEquals
(
this
.
currentHTTPStatus
,
code
);
this
.
test
.
assertHttpStatus
(
code
);
this
.
test
.
assertEquals
(
this
.
currentHTTPStatus
,
code
,
utils
.
format
(
'Status is stored in casper.currentHTTPStatus'
,
code
));
this
.
test
.
assertHttpStatus
(
code
,
utils
.
format
(
'HTTP %d handled'
,
code
));
});
});
});
casper
.
run
(
function
()
{
casper
.
run
(
function
()
{
server
.
close
();
this
.
test
.
done
(
109
);
this
.
test
.
done
();
});
});
...
...
Please
register
or
sign in
to post a comment