<!doctype html> <!– @license Copyright © 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at polymer.github.io/LICENSE The complete set of authors may be found at polymer.github.io/AUTHORS The complete set of contributors may be found at polymer.github.io/CONTRIBUTORS Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at polymer.github.io/PATENTS –> <html> <head>

<meta charset="UTF-8">
<title>test for app-scrollpos-control</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">

<script src="../../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../../web-component-tester/browser.js"></script>
<script src="../../../test-fixture/test-fixture-mocha.js"></script>
<link rel="import" href="../../../test-fixture/test-fixture.html">
<link rel="import" href="../app-scrollpos-control.html">

</head> <body>

<test-fixture id="basicScrollposControl">
  <template>
    <app-scrollpos-control></app-scrollpos-control>
    <div style="height: 10000px"></div>
  </template>
</test-fixture>

<script>

  suite('basic features', function() {
    var scrollposControl;

    setup(function() {
      scrollposControl = fixture('basicScrollposControl')[0];
    });

    test('default settings', function() {
      assert.isFalse(scrollposControl.reset);
    });

    test('store and retrieve', function(done) {
      // page0 selected
      scrollposControl.selected = 'page0';
      assert.equal(window.pageYOffset, 0);
      // scroll down to 200px on page0
      window.scrollTo(0, 200);
      // change to page1
      scrollposControl.selected = 'page1';
      setTimeout(function() {
        assert.equal(window.pageYOffset, 0, 'should be reset to 0');
        // change it back to page0
        scrollposControl.selected = 'page0';
        setTimeout(function() {
          assert.equal(window.pageYOffset, 200, 'should update to previous scrollpos on page0');
          done();
        }, 50);
      }, 10);
    });

  });

</script>

</body> </html>