navigation.js
1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
var server = require('webserver').create();
var service = server.listen(8090, function(request, response) {
response.statusCode = 200;
response.setHeader('Content-type', 'text/html');
response.write('<a href="/link">a link</a>');
response.write('<form action="/form" method="POST"><input type="submit" /></form>');
response.close();
});
casper.test.begin('Link Navigation updates response', function(test) {
casper.start('http://localhost:8090', function(response) {
casper.click('a');
casper.then(function(response) {
test.assertUrlMatch(
/\/link$/,
'URL matches anchor href'
);
test.assertEquals(
response.url,
casper.page.url,
'response is consisitent with the internal page'
);
});
}).run(function() {
test.done();
});
});
casper.test.begin('Form Submittal updates the response', function(test) {
casper.start('http://localhost:8090', function(response) {
casper.fill('form', {}, true);
casper.then(function(response) {
test.assertUrlMatch(
/\/form$/,
'URL matches form action'
);
test.assertEquals(
response.url,
casper.page.url,
'response is consisitent with the internal page'
);
});
}).run(function() {
test.done();
server.close();
});
});