var WebKit = require('../');
var expect = require('expect.js');
var fs = require('fs');

describe("unload method", function suite() {
	this.timeout(10000);
	it("should be set immediately to an empty document with an empty url", function(done) {
		var view = new WebKit();
		var uri = 'http://localhost';
		view.load(uri).once('load', function() {
			view.unload(function(err) {
				expect(view.uri).to.be("");
				expect(view.looping).to.be(0);
				view.run("document.documentElement.outerHTML;", function(err, html) {
					expect(err).to.not.be.ok();
					expect(html).to.be('<html><head></head><body></body></html>');
					done();
				});
			});
		});
	});
	it("should allow to load another uri just after", function(done) {
		var view = new WebKit();
		var uri = 'http://google.com';
		view.load(uri).once('load', function() {
			console.log("first load");
			view.unload(function(err) {
				view.load('http://google.com', function(err) {
					expect(err).to.not.be.ok();
					console.log("second load cb");
				}).on('ready', function() {
					console.log("second ready event");
				})
				.on('load', function() {

					this.html(function(err, html) {
						console.log(html.length);
						done();
					});
				});
			});
		});
	});
});

@@ -827,38 +827,8 @@
 ) %7B%0A
-%09%09%09console.log(%22first load%22);%0A
 %09%09%09v
@@ -850,24 +850,24 @@
 tion(err) %7B%0A
+
 %09%09%09%09view.loa
@@ -946,219 +946,120 @@
 %09%09%09%09
-%09console.log(%22second load cb%22);%0A%09%09%09%09%7D).on('ready', function() %7B%0A%09%09%09%09%09console.log(%22second ready event%22);%0A%09%09%09%09%7D)%0A%09%09%09%09.on('load', function() %7B%0A%0A%09%09%09%09%09this.html(function(err, html) %7B%0A%09%09%09%09%09%09console.log(html.length
+%7D).html(function(err, html) %7B%0A%09%09%09%09%09expect(err).to.not.be.ok();%0A%09%09%09%09%09expect(html.length).to.be.greaterThan(200
 );%0A
-%09
 %09%09%09%09
@@ -1071,17 +1071,8 @@
 ();%0A
-%09%09%09%09%09%7D);%0A
 %09%09%09%09

Clean unload test