Commit dec4d533 dec4d533529512ab408347bd5e4631a6d8996314 by Nicolas Perriault

added tests for Casper.getGlobal()

1 parent 6ce99dd1
......@@ -4,6 +4,11 @@
<script type="text/javascript">
var myGlobal = 'awesome string';
var myUnencodableGlobal = document;
var myObject = {
foo: {
bar: 'baz'
}
};
</script>
</body>
</html>
\ No newline at end of file
</html>
......
......@@ -2,10 +2,14 @@
/*jshint strict:false*/
casper.start('tests/site/global.html', function() {
this.test.comment('Casper.getGlobal()');
this.test.assertEquals(this.getGlobal('myGlobal'), 'awesome string', 'Casper.getGlobal() can retrieve a remote global variable');
this.test.assertRaises(this.getGlobal, ['myUnencodableGlobal'], 'Casper.getGlobal() does not fail trying to encode an unencodable global');
this.test.assertEquals(this.getGlobal('myGlobal'), 'awesome string',
'Casper.getGlobal() can retrieve a remote global variable');
this.test.assertEquals(this.getGlobal('myObject').foo.bar, 'baz',
'Casper.getGlobal() can retrieves a serializable object');
this.test.assertRaises(this.getGlobal, ['myUnencodableGlobal'],
'Casper.getGlobal() does not fail trying to encode an unserializable global');
});
casper.run(function() {
this.test.done(2);
this.test.done(3);
});
......