var test = require('tape');
var setLocationHash = require('./dist/set-location-hash.js');

var body = document.body;

body.style.height = '9999px';

// create 'div#some' element
var target = document.createElement('div');
target.id = 'some';
target.style.position = 'absolute';
target.style.top = '5000px';
body.appendChild(target);

window.scrollTo(0, 0);

test('if hash changed', function(t) {
  'use strict';

  setLocationHash('some');
  
  t.plan(1);
  t.equal(location.hash, '#some');
});

test('if scroll position unchanged', function(t) {
  'use strict';

  setLocationHash('some');

  t.plan(1);
  t.equal(
    body.scrollTop || document.documentElement.scrollTop,
    0
  );
});

test('if empty hash available', function(t) {
  'use strict';

  setLocationHash('');

  t.plan(2);
  t.equal(history.length, 3);
  t.equal(location.href.split('#')[1], '');
});

@@ -783,9 +783,9 @@
 lan(
-2
+1
 );%0A 
@@ -797,28 +797,314 @@
 ual(
-history.length, 3
+location.href.split('#')%5B1%5D, '');%0A%7D);%0A%0Aif (typeof history.pushState === 'function' &&%0A    typeof history.replaceState === 'function') %7B%0A%0A  test('replace option', function(t) %7B%0A    'use strict';%0A%0A    var currentHistoryLength = history.length;%0A%0A    setLocationHash('baz', %7Breplace: true%7D);%0A%0A    t.plan(1
 );%0A
+  
   t.
@@ -1113,42 +1113,332 @@
 ual(
-location.href.split('#')%5B1%5D, ''
+history.length, currentHistoryLength);%0A  %7D);%0A%0A  test('force option', function(t) %7B%0A    'use strict';%0A%0A    var currentHistoryLength = history.length;%0A    var currentFrag = location.hash.substring(1);%0A%0A    setLocationHash(currentFrag, %7Bforce: true%7D);%0A%0A    t.plan(1);%0A    t.equal(history.length, currentHistoryLength + 1
 );%0A
+  
 %7D);%0A
+%7D%0A

add test for options