• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!doctype html>
2<!--
3@license
4Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
5This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
6The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
7The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
8Code distributed by Google as part of the polymer project is also
9subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
10-->
11<html>
12<head>
13
14  <title>neon-animated-pages tests</title>
15
16  <meta charset="utf-8">
17  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
18    <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
19
20  <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
21
22  <script>Polymer = {lazyRegister: true}</script>
23
24  <script src="../../web-component-tester/browser.js"></script>
25  <script src="../../test-fixture/test-fixture-mocha.js"></script>
26
27  <link rel="import" href="../../test-fixture/test-fixture.html">
28  <link rel="import" href="../neon-animated-pages.html">
29  <link rel="import" href="../neon-animatable.html">
30  <link rel="import" href="../animations/slide-from-left-animation.html">
31  <link rel="import" href="../animations/slide-right-animation.html">
32  <link rel="import" href="test-resizable-pages.html">
33
34</head>
35<body>
36
37  <test-fixture id="animate-initial-selection">
38    <template>
39      <neon-animated-pages entry-animation="slide-from-left-animation" exit-animation="slide-right-animation" animate-initial-selection>
40        <neon-animatable></neon-animatable>
41        <neon-animatable></neon-animatable>
42      </neon-animated-pages>
43    </template>
44  </test-fixture>
45
46  <script>
47    suite('animations found when `lazRegister` setting is true', function() {
48      test('animations are registered', function(done) {
49        var animatedPages = fixture('animate-initial-selection');
50        animatedPages._complete = sinon.spy(animatedPages._complete);
51        assert.isUndefined(animatedPages.selected);
52        var pages = Polymer.dom(animatedPages).children;
53        animatedPages.addEventListener('neon-animation-finish', function(event) {
54          if (animatedPages.selected === 0) {
55            animatedPages.selected = 1;
56            return;
57          }
58          assert.strictEqual(animatedPages.selected, 1);
59          assert.equal(event.detail.fromPage, pages[0]);
60          assert.equal(event.detail.toPage, pages[1]);
61          assert.isTrue(animatedPages._complete.calledTwice);
62          var a$ = animatedPages._complete.getCall(1).args[0];
63          assert.isTrue(a$[0].neonAnimation.isNeonAnimation, 'entry animation is not a registered animation');
64          assert.isTrue(a$[1].neonAnimation.isNeonAnimation, 'exit animation is not a registered animation');
65          done();
66        });
67        animatedPages.selected = 0;
68      });
69    });
70  </script>
71
72</body>
73</html>
74