Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: polymer_1.0.4/bower_components/iron-autogrow-textarea/test/basic.html

Issue 1205703007: Add polymer 1.0 to npm_modules (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Renamed folder to 1.0.4 Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!doctype html>
2 <!--
3 @license
4 Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
5 This code may only be used under the BSD style license found at http://polymer.g ithub.io/LICENSE.txt
6 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
7 The complete set of contributors may be found at http://polymer.github.io/CONTRI BUTORS.txt
8 Code distributed by Google as part of the polymer project is also
9 subject to an additional IP rights grant found at http://polymer.github.io/PATEN TS.txt
10 -->
11 <html>
12 <head>
13
14 <title>iron-autogrow-textarea 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, init ial-scale=1, user-scalable=yes">
19
20 <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
21
22 <script src="../../web-component-tester/browser.js"></script>
23 <script src="../../test-fixture/test-fixture-mocha.js"></script>
24 <script src="../../iron-test-helpers/mock-interactions.js"></script>
25
26 <link rel="import" href="../../test-fixture/test-fixture.html">
27 <link rel="import" href="../iron-autogrow-textarea.html">
28
29 </head>
30 <body>
31
32 <test-fixture id="basic">
33 <template>
34 <iron-autogrow-textarea></iron-autogrow-textarea>
35 </template>
36 </test-fixture>
37
38 <test-fixture id="has-bindValue">
39 <template>
40 <iron-autogrow-textarea bind-value="foobar"></iron-autogrow-textarea>
41 </template>
42 </test-fixture>
43
44 <test-fixture id="rows">
45 <template>
46 <iron-autogrow-textarea rows="3"></iron-autogrow-textarea>
47 </template>
48 </test-fixture>
49
50 <script>
51
52 suite('basic', function() {
53
54 test('setting bindValue sets textarea value', function() {
55 var autogrow = fixture('basic');
56 var textarea = autogrow.textarea;
57
58 autogrow.bindValue = 'batman';
59 assert.equal(textarea.value, autogrow.bindValue, 'textarea value equal s to bindValue');
60 });
61
62 test('can set an initial bindValue', function() {
63 var autogrow = fixture('has-bindValue');
64 assert.equal(autogrow.textarea.value, 'foobar', 'textarea value equals to initial bindValue');
65 });
66
67 test('can set an initial number of rows', function() {
68 var autogrow = fixture("rows");
69 assert.equal(autogrow.textarea.rows, 3, 'textarea has rows=3');
70 });
71
72 test('adding rows grows the textarea', function() {
73 var autogrow = fixture('basic');
74 var initialHeight = autogrow.offsetHeight;
75
76 autogrow.bindValue = 'batman\nand\nrobin';
77 var finalHeight = autogrow.offsetHeight
78 assert.isTrue(finalHeight > initialHeight);
79 });
80
81 test('removing rows shrinks the textarea', function() {
82 var autogrow = fixture('basic');
83 autogrow.bindValue = 'batman\nand\nrobin';
84 var initialHeight = autogrow.offsetHeight;
85
86 autogrow.bindValue = 'batman';
87 var finalHeight = autogrow.offsetHeight
88 assert.isTrue(finalHeight < initialHeight);
89 });
90 });
91
92 suite('focus/blur events', function() {
93 var input;
94
95 setup(function() {
96 input = fixture('basic');
97 });
98
99 test('focus/blur events fired on host element', function(done) {
100 var nFocusEvents = 0;
101 var nBlurEvents = 0;
102 input.addEventListener('focus', function() {
103 nFocusEvents += 1;
104 // setTimeout to wait for potentially more, erroneous events
105 setTimeout(function() {
106 assert.equal(nFocusEvents, 1, 'one focus event fired');
107 MockInteractions.blur(input.textarea);
108 });
109 });
110 input.addEventListener('blur', function() {
111 nBlurEvents += 1;
112 // setTimeout to wait for potentially more, erroneous events
113 setTimeout(function() {
114 assert.equal(nBlurEvents, 1, 'one blur event fired');
115 done();
116 });
117 });
118 MockInteractions.focus(input.textarea);
119 });
120
121 });
122
123 </script>
124
125 </body>
126 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698