Blame view

bower_components/paper-dialog-scrollable/test/paper-dialog-scrollable.html 13.1 KB
c5169e0e   Renato De Donato   a new hope
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
  <!doctype html>

  <!--

  @license

  Copyright (c) 2015 The Polymer Project Authors. All rights reserved.

  This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt

  The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt

  The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt

  Code distributed by Google as part of the polymer project is also

  subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt

  -->

  <html>

    <head>

  

      <title>paper-dialog-scrollable tests</title>

  

      <meta charset="utf-8">

      <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

      <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">

  

      <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="../paper-dialog-scrollable.html">

  

      <link rel="import" href="../../iron-flex-layout/classes/iron-flex-layout.html">

  

      <style>

        .fixed-height {

          height: 400px;

        }

      </style>

  

    </head>

    <body>

  

      <test-fixture id="basic">

        <template>

          <section class="fixed-height layout vertical">

            <div class="header">Header</div>

            <paper-dialog-scrollable class="flex">

              <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

              <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

              <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

              <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

              <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

              <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

              <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

              <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

            </paper-dialog-scrollable>

            <div class="footer">Footer</div>

          </section>

        </template>

      </test-fixture>

  

      <test-fixture id="only-child">

        <template>

          <section class="fixed-height layout vertical">

            <paper-dialog-scrollable class="flex">

              <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

              <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

              <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

              <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

              <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

              <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

              <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

              <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

            </paper-dialog-scrollable>

          </section>

        </template>

      </test-fixture>

  

      <test-fixture id="short">

        <template>

          <section class="fixed-height layout vertical">

            <div class="header">Header</div>

            <paper-dialog-scrollable class="flex">

              <p>Hello world!</p>

            </paper-dialog-scrollable>

            <div class="footer">Footer</div>

          </section>

        </template>

      </test-fixture>

  

      <script>

  

        function runAfterScroll(node, scrollTop, callback) {

          var timeout = function() {

            node.scrollTop = scrollTop;

            if (node.scrollTop === scrollTop) {

              // there seems to be no good way to wait for pseudoelement styling to apply and

              // chrome takes a while before getComputedStyle returns the correct values

              setTimeout(function() {

                callback();

              }, 250);

            } else {

              setTimeout(timeout, 10);

            }

          };

          node.scrollTop = scrollTop;

          setTimeout(timeout);

        }

  

        suite('basic', function() {

  

          test('shows top divider if scrolled', function(done) {

            var container = fixture('basic');

            var scrollable = Polymer.dom(container).querySelector('paper-dialog-scrollable');

            setTimeout(function() {

              runAfterScroll(scrollable.scrollTarget, 10, function() {

                assert.ok(getComputedStyle(scrollable, '::before').content, '::before has content');

                done();

              });

            }, 10);

          });

  

          test('shows bottom divider if scrollable', function(done) {

            var container = fixture('basic');

            setTimeout(function() {

              var scrollable = Polymer.dom(container).querySelector('paper-dialog-scrollable');

              requestAnimationFrame(function() {

                assert.ok(getComputedStyle(scrollable, '::after').content, '::after has content');

                done();

              });

            }, 10);

          });

  

          test('hides bottom divider if scrolled to bottom', function(done) {

            var container = fixture('basic');

            var scrollable = Polymer.dom(container).querySelector('paper-dialog-scrollable');

            setTimeout(function() {

              runAfterScroll(scrollable.scrollTarget, scrollable.scrollTarget.scrollHeight - scrollable.scrollTarget.offsetHeight, function() {

                var content = getComputedStyle(scrollable, '::after').content;

                assert.ok(!content || content === 'none', '::after does not have content');

                done();

              });

            }, 10);

          });

  

          test('does not show dividers if scrolled and only child', function(done) {

            var container = fixture('only-child');

            var scrollable = Polymer.dom(container).querySelector('paper-dialog-scrollable');

            setTimeout(function() {

              runAfterScroll(scrollable.scrollTarget, 10, function() {

                var contentBefore = getComputedStyle(scrollable, '::before').content;

                assert.ok(!contentBefore || contentBefore === 'none', '::before does not have content');

                var contentAfter = getComputedStyle(scrollable, '::after').content;

                assert.ok(!contentAfter || contentAfter === 'none', '::after does not have content');

                done();

              });

            }, 10);

          });

  

          test('does not show bottom divider if not scrollable', function(done) {

            var container = fixture('short');

            setTimeout(function() {

              var scrollable = Polymer.dom(container).querySelector('paper-dialog-scrollable');

              var contentAfter = getComputedStyle(scrollable, '::after').content;

              assert.ok(!contentAfter || contentAfter === 'none', '::after does not have content');

              done();

            }, 10);

          });

  

        });

  

      </script>

  

    </body>

  </html>