import Nightmare from 'nightmare';
import test from 'tape';

let count = 0;

test('Google site', t => {
  let nightmare = Nightmare({
    show: false
  });

  Promise.resolve()
  .then(() => {
    return nightmare.goto('http://google.com').title();
  })
  .then(title => {
    t.equal(title, 'Google', 'Google page\'s title should be "Google"');
  })
  .then(() => {
    nightmare.end();
    t.end();
    count++;
  });
});

test('Google logo', t => {
  let nightmare = Nightmare({
    show: false
  });

  Promise.resolve()
  .then(() => {
    return nightmare
      .goto('http://google.com')
      .wait('#hplogo')
      .evaluate(() => {
        return document.getElementById('hplogo').height;
      });
  })
  .then(height => {
    t.equal(height, 92, 'Google logo height should be 92');
  })
  .then(() => {
    nightmare.end();
    t.end();
    count++;
  });
});

setInterval(() => {
  if (count === 2) {
    process.exit();
  }
}, 200);

@@ -866,16 +866,675 @@
 );%0A%7D);%0A%0A
+test('Google image comparison', t =%3E %7B%0A  let nightmare = Nightmare(%7B%0A    show: false%0A  %7D);%0A%0A  Promise.resolve()%0A  .then(() =%3E %7B%0A    return nightmare%0A      .goto('http://google.com')%0A      .wait('#hplogo')%0A      .evaluate(() =%3E %7B%0A        const x = document.getElementById('hplogo').getBoundingClientRect();%0A        return %7B%0A          y: x.top,%0A          x: x.left,%0A          width: x.width,%0A          height: x.height%0A        %7D;%0A      %7D);%0A  %7D)%0A  .then(rect =%3E %7B%0A    console.log(rect);%0A    return nightmare.screenshot(undefined, rect);%0A  %7D)%0A  .then((image) =%3E %7B%0A    console.log(image);%0A    t.ok(true);%0A%0A    nightmare.end();%0A    t.end();%0A    count++;%0A  %7D);%0A%7D);%0A%0A
 setInter
@@ -1561,17 +1561,17 @@
 unt === 
-2
+3
 ) %7B%0A    

Add basic example of image extraction