const Nightmare = require('nightmare');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const test_url = "file:///"+path.resolve(__dirname,"../examples/vanilla.html");
const hash_url = test_url + "#group=nogroup&photo=rhinoceros";

const nightmare = Nightmare({
    webPreferences  : {
    partition : 'nopersist',
    preload: path.resolve(__dirname,'./preload.js')
  },
  show: true
});

describe('test',() => {
  it('caption', (done) => {
    nightmare.goto(test_url)
      .click('[data-caption="lion"]')
      .wait(1000)
      .click('.smartphoto-arrow-right a')
      .wait(1000)
      .evaluate(() => {
        return document.querySelector('.smartphoto-caption').innerText;
      })
      .then((result) => {
        assert.equal(result,'camel');
        done();
      })
      .catch((error) => {
        done(error);
      });
  });

  it('hash', (done) => {
    nightmare.goto(hash_url)
      .wait(1000)
      .evaluate(() => {
          return document.querySelector('.smartphoto-caption').innerText;
      })
      .then(result => {
        assert.equal(result,'rhinoceros');
        done();
      })
      .catch(error => {
        done(error);
      });
  });
});
@@ -262,16 +262,11 @@
 hino
-ceros
 %22;%0A
+
 %0Acon
@@ -530,17 +530,17 @@
 aption=%22
-l
+L
 ion%22%5D')%0A
@@ -777,17 +777,17 @@
 result,'
-c
+C
 amel');%0A
@@ -1111,18 +1111,13 @@
 lt,'
-r
+R
 hino
-ceros
 ');%0A
@@ -1202,11 +1202,12 @@
 ;%0A  %7D);%0A
-
 %7D);
+%0A

Fix data-caption text