polymer-gold-rails 1.0.0.pre.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +36 -0
- data/Rakefile +1 -0
- data/app/assets/components/gold-cc-cvc-input/README.md +24 -0
- data/app/assets/components/gold-cc-cvc-input/bower.json +39 -0
- data/app/assets/components/gold-cc-cvc-input/cvc_hint.png +0 -0
- data/app/assets/components/gold-cc-cvc-input/cvc_hint_amex.png +0 -0
- data/app/assets/components/gold-cc-cvc-input/demo/index.html +54 -0
- data/app/assets/components/gold-cc-cvc-input/gold-cc-cvc-input.html +195 -0
- data/app/assets/components/gold-cc-cvc-input/hero.svg +36 -0
- data/app/assets/components/gold-cc-cvc-input/index.html +26 -0
- data/app/assets/components/gold-cc-cvc-input/test/basic.html +125 -0
- data/app/assets/components/gold-cc-cvc-input/test/index.html +25 -0
- data/app/assets/components/gold-cc-expiration-input/README.md +10 -0
- data/app/assets/components/gold-cc-expiration-input/bower.json +40 -0
- data/app/assets/components/gold-cc-expiration-input/date-input.html +157 -0
- data/app/assets/components/gold-cc-expiration-input/date-validator.html +38 -0
- data/app/assets/components/gold-cc-expiration-input/demo/index.html +53 -0
- data/app/assets/components/gold-cc-expiration-input/gold-cc-expiration-input.html +131 -0
- data/app/assets/components/gold-cc-expiration-input/hero.svg +58 -0
- data/app/assets/components/gold-cc-expiration-input/index.html +28 -0
- data/app/assets/components/gold-cc-expiration-input/test/basic.html +126 -0
- data/app/assets/components/gold-cc-expiration-input/test/index.html +25 -0
- data/app/assets/components/gold-cc-input/README.md +9 -0
- data/app/assets/components/gold-cc-input/bower.json +39 -0
- data/app/assets/components/gold-cc-input/cc-validator.js +192 -0
- data/app/assets/components/gold-cc-input/demo/index.html +48 -0
- data/app/assets/components/gold-cc-input/gold-cc-input.html +215 -0
- data/app/assets/components/gold-cc-input/hero.svg +52 -0
- data/app/assets/components/gold-cc-input/images/amex.png +0 -0
- data/app/assets/components/gold-cc-input/images/diners_club.png +0 -0
- data/app/assets/components/gold-cc-input/images/discover.png +0 -0
- data/app/assets/components/gold-cc-input/images/jcb.png +0 -0
- data/app/assets/components/gold-cc-input/images/mastercard.png +0 -0
- data/app/assets/components/gold-cc-input/images/visa.png +0 -0
- data/app/assets/components/gold-cc-input/index.html +28 -0
- data/app/assets/components/gold-cc-input/test/basic.html +136 -0
- data/app/assets/components/gold-cc-input/test/index.html +25 -0
- data/app/assets/components/gold-elements/README.md +12 -0
- data/app/assets/components/gold-elements/bower.json +42 -0
- data/app/assets/components/gold-elements/demo/complex-form.html +127 -0
- data/app/assets/components/gold-elements/demo/index.html +94 -0
- data/app/assets/components/gold-elements/demo/item-card.html +59 -0
- data/app/assets/components/gold-elements/demo/simple-form.css +55 -0
- data/app/assets/components/gold-elements/demo/simple-form.html +93 -0
- data/app/assets/components/gold-elements/screenshot.png +0 -0
- data/app/assets/components/gold-email-input/README.md +8 -0
- data/app/assets/components/gold-email-input/bower.json +40 -0
- data/app/assets/components/gold-email-input/demo/index.html +46 -0
- data/app/assets/components/gold-email-input/email-validator.html +31 -0
- data/app/assets/components/gold-email-input/gold-email-input.html +108 -0
- data/app/assets/components/gold-email-input/hero.svg +59 -0
- data/app/assets/components/gold-email-input/index.html +28 -0
- data/app/assets/components/gold-email-input/test/basic.html +97 -0
- data/app/assets/components/gold-email-input/test/index.html +25 -0
- data/app/assets/components/gold-phone-input/README.md +13 -0
- data/app/assets/components/gold-phone-input/bower.json +39 -0
- data/app/assets/components/gold-phone-input/demo/index.html +53 -0
- data/app/assets/components/gold-phone-input/gold-phone-input.html +197 -0
- data/app/assets/components/gold-phone-input/hero.svg +63 -0
- data/app/assets/components/gold-phone-input/index.html +28 -0
- data/app/assets/components/gold-phone-input/test/basic.html +117 -0
- data/app/assets/components/gold-phone-input/test/index.html +25 -0
- data/app/assets/components/gold-zip-input/README.md +8 -0
- data/app/assets/components/gold-zip-input/bower.json +40 -0
- data/app/assets/components/gold-zip-input/demo/index.html +54 -0
- data/app/assets/components/gold-zip-input/gold-zip-input.html +113 -0
- data/app/assets/components/gold-zip-input/hero.svg +43 -0
- data/app/assets/components/gold-zip-input/index.html +28 -0
- data/app/assets/components/gold-zip-input/test/basic.html +116 -0
- data/app/assets/components/gold-zip-input/test/index.html +25 -0
- data/app/assets/components/gold-zip-input/zip-validator.html +32 -0
- data/app/assets/components/iron-autogrow-textarea/README.md +24 -0
- data/app/assets/components/iron-autogrow-textarea/bower.json +37 -0
- data/app/assets/components/iron-autogrow-textarea/demo/index.html +81 -0
- data/app/assets/components/iron-autogrow-textarea/hero.svg +33 -0
- data/app/assets/components/iron-autogrow-textarea/index.html +30 -0
- data/app/assets/components/iron-autogrow-textarea/iron-autogrow-textarea.html +263 -0
- data/app/assets/components/iron-autogrow-textarea/test/basic.html +94 -0
- data/app/assets/components/iron-autogrow-textarea/test/index.html +25 -0
- data/app/assets/components/iron-flex-layout/README.md +4 -0
- data/app/assets/components/iron-flex-layout/bower.json +21 -0
- data/app/assets/components/iron-flex-layout/classes/iron-flex-layout.html +307 -0
- data/app/assets/components/iron-flex-layout/classes/iron-shadow-flex-layout.html +302 -0
- data/app/assets/components/iron-flex-layout/demo/index.html +40 -0
- data/app/assets/components/iron-flex-layout/demo/x-app.html +106 -0
- data/app/assets/components/iron-flex-layout/iron-flex-layout.html +313 -0
- data/app/assets/components/iron-form-element-behavior/README.md +2 -0
- data/app/assets/components/iron-form-element-behavior/bower.json +27 -0
- data/app/assets/components/iron-form-element-behavior/demo/index.html +53 -0
- data/app/assets/components/iron-form-element-behavior/demo/simple-element.html +27 -0
- data/app/assets/components/iron-form-element-behavior/demo/simple-form.html +42 -0
- data/app/assets/components/iron-form-element-behavior/index.html +30 -0
- data/app/assets/components/iron-form-element-behavior/iron-form-element-behavior.html +50 -0
- data/app/assets/components/iron-icon/README.md +56 -0
- data/app/assets/components/iron-icon/bower.json +29 -0
- data/app/assets/components/iron-icon/demo/index.html +28 -0
- data/app/assets/components/iron-icon/demo/location.png +0 -0
- data/app/assets/components/iron-icon/hero.svg +19 -0
- data/app/assets/components/iron-icon/index.html +26 -0
- data/app/assets/components/iron-icon/iron-icon.html +187 -0
- data/app/assets/components/iron-icon/test/index.html +31 -0
- data/app/assets/components/iron-icon/test/iron-icon.html +120 -0
- data/app/assets/components/iron-input/README.md +16 -0
- data/app/assets/components/iron-input/bower.json +36 -0
- data/app/assets/components/iron-input/demo/index.html +87 -0
- data/app/assets/components/iron-input/hero.svg +19 -0
- data/app/assets/components/iron-input/index.html +30 -0
- data/app/assets/components/iron-input/iron-input.html +235 -0
- data/app/assets/components/iron-input/test/index.html +24 -0
- data/app/assets/components/iron-input/test/iron-input.html +139 -0
- data/app/assets/components/iron-input/test/letters-only.html +30 -0
- data/app/assets/components/iron-meta/README.md +46 -0
- data/app/assets/components/iron-meta/bower.json +28 -0
- data/app/assets/components/iron-meta/demo/index.html +45 -0
- data/app/assets/components/iron-meta/hero.svg +33 -0
- data/app/assets/components/iron-meta/index.html +27 -0
- data/app/assets/components/iron-meta/iron-meta.html +352 -0
- data/app/assets/components/iron-meta/test/basic.html +48 -0
- data/app/assets/components/iron-meta/test/index.html +30 -0
- data/app/assets/components/iron-meta/test/iron-meta.html +186 -0
- data/app/assets/components/iron-validatable-behavior/README.md +3 -0
- data/app/assets/components/iron-validatable-behavior/bower.json +35 -0
- data/app/assets/components/iron-validatable-behavior/demo/cats-only.html +46 -0
- data/app/assets/components/iron-validatable-behavior/demo/index.html +71 -0
- data/app/assets/components/iron-validatable-behavior/demo/validatable-input.html +46 -0
- data/app/assets/components/iron-validatable-behavior/index.html +30 -0
- data/app/assets/components/iron-validatable-behavior/iron-validatable-behavior.html +101 -0
- data/app/assets/components/iron-validatable-behavior/test/index.html +35 -0
- data/app/assets/components/iron-validatable-behavior/test/iron-validatable-behavior.html +52 -0
- data/app/assets/components/iron-validatable-behavior/test/test-validatable.html +28 -0
- data/app/assets/components/iron-validator-behavior/README.md +4 -0
- data/app/assets/components/iron-validator-behavior/bower.json +34 -0
- data/app/assets/components/iron-validator-behavior/demo/cats-only.html +46 -0
- data/app/assets/components/iron-validator-behavior/demo/index.html +144 -0
- data/app/assets/components/iron-validator-behavior/index.html +30 -0
- data/app/assets/components/iron-validator-behavior/iron-validator-behavior.html +61 -0
- data/app/assets/components/iron-validator-behavior/test/index.html +34 -0
- data/app/assets/components/iron-validator-behavior/test/iron-validator-behavior.html +47 -0
- data/app/assets/components/iron-validator-behavior/test/simple-validator.html +26 -0
- data/app/assets/components/paper-input/README.md +5 -0
- data/app/assets/components/paper-input/all-imports.html +12 -0
- data/app/assets/components/paper-input/bower.json +44 -0
- data/app/assets/components/paper-input/demo/index.html +96 -0
- data/app/assets/components/paper-input/demo/ssn-input.html +94 -0
- data/app/assets/components/paper-input/demo/ssn-validator.html +31 -0
- data/app/assets/components/paper-input/hero.svg +19 -0
- data/app/assets/components/paper-input/index.html +28 -0
- data/app/assets/components/paper-input/paper-input-addon-behavior.html +47 -0
- data/app/assets/components/paper-input/paper-input-behavior.html +317 -0
- data/app/assets/components/paper-input/paper-input-char-counter.html +95 -0
- data/app/assets/components/paper-input/paper-input-container.html +495 -0
- data/app/assets/components/paper-input/paper-input-error.html +99 -0
- data/app/assets/components/paper-input/paper-input.html +126 -0
- data/app/assets/components/paper-input/paper-textarea.html +106 -0
- data/app/assets/components/paper-input/test/index.html +28 -0
- data/app/assets/components/paper-input/test/letters-only.html +30 -0
- data/app/assets/components/paper-input/test/paper-input-char-counter.html +112 -0
- data/app/assets/components/paper-input/test/paper-input-container.html +237 -0
- data/app/assets/components/paper-input/test/paper-input-error.html +60 -0
- data/app/assets/components/paper-input/test/paper-input.html +213 -0
- data/app/assets/components/paper-input/test/paper-textarea.html +169 -0
- data/app/assets/components/paper-styles/README.md +3 -0
- data/app/assets/components/paper-styles/bower.json +27 -0
- data/app/assets/components/paper-styles/classes/global.html +96 -0
- data/app/assets/components/paper-styles/classes/shadow-layout.html +302 -0
- data/app/assets/components/paper-styles/classes/shadow.html +39 -0
- data/app/assets/components/paper-styles/classes/typography.html +171 -0
- data/app/assets/components/paper-styles/color.html +333 -0
- data/app/assets/components/paper-styles/default-theme.html +39 -0
- data/app/assets/components/paper-styles/demo-pages.html +72 -0
- data/app/assets/components/paper-styles/demo.css +25 -0
- data/app/assets/components/paper-styles/paper-styles-classes.html +14 -0
- data/app/assets/components/paper-styles/paper-styles.html +17 -0
- data/app/assets/components/paper-styles/shadow.html +61 -0
- data/app/assets/components/paper-styles/typography.html +240 -0
- data/app/assets/components/polymer/LICENSE.txt +27 -0
- data/app/assets/components/polymer/bower.json +26 -0
- data/app/assets/components/polymer/build.log +27 -0
- data/app/assets/components/polymer/polymer-micro.html +523 -0
- data/app/assets/components/polymer/polymer-mini.html +1368 -0
- data/app/assets/components/polymer/polymer.html +3768 -0
- data/app/assets/components/webcomponentsjs/CustomElements.js +956 -0
- data/app/assets/components/webcomponentsjs/CustomElements.min.js +11 -0
- data/app/assets/components/webcomponentsjs/HTMLImports.js +1078 -0
- data/app/assets/components/webcomponentsjs/HTMLImports.min.js +11 -0
- data/app/assets/components/webcomponentsjs/MutationObserver.js +344 -0
- data/app/assets/components/webcomponentsjs/MutationObserver.min.js +11 -0
- data/app/assets/components/webcomponentsjs/README.md +125 -0
- data/app/assets/components/webcomponentsjs/ShadowDOM.js +4414 -0
- data/app/assets/components/webcomponentsjs/ShadowDOM.min.js +15 -0
- data/app/assets/components/webcomponentsjs/bower.json +14 -0
- data/app/assets/components/webcomponentsjs/build.log +33 -0
- data/app/assets/components/webcomponentsjs/package.json +31 -0
- data/app/assets/components/webcomponentsjs/webcomponents-lite.js +2300 -0
- data/app/assets/components/webcomponentsjs/webcomponents-lite.min.js +13 -0
- data/app/assets/components/webcomponentsjs/webcomponents.js +7112 -0
- data/app/assets/components/webcomponentsjs/webcomponents.min.js +15 -0
- data/lib/polymer-gold-rails.rb +2 -0
- data/lib/polymer-gold-rails/enigne.rb +4 -0
- data/lib/polymer-gold-rails/version.rb +3 -0
- metadata +312 -0
@@ -0,0 +1,237 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<!--
|
3
|
+
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
4
|
+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
5
|
+
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
6
|
+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
7
|
+
Code distributed by Google as part of the polymer project is also
|
8
|
+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
9
|
+
-->
|
10
|
+
<html>
|
11
|
+
<head>
|
12
|
+
|
13
|
+
<title>paper-input-container tests</title>
|
14
|
+
|
15
|
+
<meta charset="utf-8">
|
16
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
17
|
+
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
|
18
|
+
|
19
|
+
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
20
|
+
|
21
|
+
<script src="../../web-component-tester/browser.js"></script>
|
22
|
+
<script src="../../test-fixture/test-fixture-mocha.js"></script>
|
23
|
+
|
24
|
+
<link rel="import" href="../../test-fixture/test-fixture.html">
|
25
|
+
<link rel="import" href="../../iron-input/iron-input.html">
|
26
|
+
<link rel="import" href="../paper-input-container.html">
|
27
|
+
<link rel="import" href="letters-only.html">
|
28
|
+
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
|
32
|
+
<test-fixture id="basic">
|
33
|
+
<template>
|
34
|
+
<paper-input-container>
|
35
|
+
<label id="l">label</label>
|
36
|
+
<input id="i">
|
37
|
+
</paper-input-container>
|
38
|
+
</template>
|
39
|
+
</test-fixture>
|
40
|
+
|
41
|
+
<test-fixture id="has-value">
|
42
|
+
<template>
|
43
|
+
<paper-input-container>
|
44
|
+
<label id="l">label</label>
|
45
|
+
<input id="i" value="value">
|
46
|
+
</paper-input-container>
|
47
|
+
</template>
|
48
|
+
</test-fixture>
|
49
|
+
|
50
|
+
<test-fixture id="no-float-has-value">
|
51
|
+
<template>
|
52
|
+
<paper-input-container no-label-float>
|
53
|
+
<label id="l">label</label>
|
54
|
+
<input id="i" value="value">
|
55
|
+
</paper-input-container>
|
56
|
+
</template>
|
57
|
+
</test-fixture>
|
58
|
+
|
59
|
+
<test-fixture id="always-float">
|
60
|
+
<template>
|
61
|
+
<paper-input-container always-float-label>
|
62
|
+
<label id="l">label</label>
|
63
|
+
<input id="i" value="value">
|
64
|
+
</paper-input-container>
|
65
|
+
</template>
|
66
|
+
</test-fixture>
|
67
|
+
|
68
|
+
<test-fixture id="auto-validate-numbers">
|
69
|
+
<template>
|
70
|
+
<paper-input-container auto-validate>
|
71
|
+
<label id="l">label</label>
|
72
|
+
<input is="iron-input" id="i" pattern="[0-9]*">
|
73
|
+
</paper-input-container>
|
74
|
+
</template>
|
75
|
+
</test-fixture>
|
76
|
+
|
77
|
+
<test-fixture id="manual-validate-numbers">
|
78
|
+
<template>
|
79
|
+
<paper-input-container>
|
80
|
+
<label id="l">label</label>
|
81
|
+
<input is="iron-input" id="i" pattern="[0-9]*">
|
82
|
+
</paper-input-container>
|
83
|
+
</template>
|
84
|
+
</test-fixture>
|
85
|
+
|
86
|
+
<letters-only></letters-only>
|
87
|
+
|
88
|
+
<test-fixture id="auto-validate-validator">
|
89
|
+
<template>
|
90
|
+
<paper-input-container auto-validate>
|
91
|
+
<label id="l">label</label>
|
92
|
+
<input is="iron-input" id="i" pattern="[0-9]*" validator="letters-only">
|
93
|
+
</paper-input-container>
|
94
|
+
</template>
|
95
|
+
</test-fixture>
|
96
|
+
|
97
|
+
<test-fixture id="auto-validate-validator-has-invalid-value">
|
98
|
+
<template>
|
99
|
+
<paper-input-container auto-validate>
|
100
|
+
<label id="l">label</label>
|
101
|
+
<input is="iron-input" id="i" validator="letters-only" value="123123">
|
102
|
+
</paper-input-container>
|
103
|
+
</template>
|
104
|
+
</test-fixture>
|
105
|
+
|
106
|
+
<script>
|
107
|
+
|
108
|
+
function getTransform(node) {
|
109
|
+
var style = getComputedStyle(node);
|
110
|
+
return style.transform || style.webkitTransform;
|
111
|
+
}
|
112
|
+
|
113
|
+
suite('label position', function() {
|
114
|
+
|
115
|
+
test('label is visible by default', function() {
|
116
|
+
var container = fixture('basic');
|
117
|
+
assert.equal(getComputedStyle(container.querySelector('#l')).visibility, 'visible', 'label has visibility:visible');
|
118
|
+
});
|
119
|
+
|
120
|
+
test('label is floated if value is initialized to not null', function() {
|
121
|
+
var container = fixture('has-value');
|
122
|
+
assert.notEqual(getTransform(container.querySelector('#l')), 'none', 'label has transform');
|
123
|
+
});
|
124
|
+
|
125
|
+
test('label is invisible if no-label-float and value is initialized to not null', function() {
|
126
|
+
var container = fixture('no-float-has-value');
|
127
|
+
assert.equal(getComputedStyle(container.querySelector('#l')).visibility, 'hidden', 'label has visibility:hidden');
|
128
|
+
});
|
129
|
+
|
130
|
+
test('label is floated if always-float-label is true', function() {
|
131
|
+
var container = fixture('always-float');
|
132
|
+
assert.notEqual(getTransform(container.querySelector('#l')), 'none', 'label has transform');
|
133
|
+
})
|
134
|
+
|
135
|
+
});
|
136
|
+
|
137
|
+
suite('focused styling', function() {
|
138
|
+
|
139
|
+
test('label is colored when input is focused and has value', function(done) {
|
140
|
+
var container = fixture('has-value');
|
141
|
+
var label = Polymer.dom(container).querySelector('#l');
|
142
|
+
var input = Polymer.dom(container).querySelector('#i');
|
143
|
+
var inputContent = Polymer.dom(container.root).querySelector('.input-content');
|
144
|
+
input.focus();
|
145
|
+
// 'focus' event isn't firing on windows ff for some reason when you call focus()
|
146
|
+
container._onFocus();
|
147
|
+
requestAnimationFrame(function() {
|
148
|
+
assert.equal(document.activeElement, input, 'input is focused');
|
149
|
+
assert.isTrue(container.focused, 'focused is true');
|
150
|
+
assert.isTrue(inputContent.classList.contains('label-is-highlighted'), 'label is highlighted when input has focus');
|
151
|
+
done();
|
152
|
+
});
|
153
|
+
});
|
154
|
+
|
155
|
+
test('label is not colored when input is focused and has null value', function(done) {
|
156
|
+
var container = fixture('basic');
|
157
|
+
var label = Polymer.dom(container).querySelector('#l');
|
158
|
+
var input = Polymer.dom(container).querySelector('#i');
|
159
|
+
var inputContent = Polymer.dom(container.root).querySelector('.input-content');
|
160
|
+
input.focus();
|
161
|
+
container._onFocus();
|
162
|
+
requestAnimationFrame(function() {
|
163
|
+
assert.isFalse(inputContent.classList.contains('label-is-highlighted'), 'label is not highlighted when input has focus and has null value');
|
164
|
+
done();
|
165
|
+
});
|
166
|
+
});
|
167
|
+
|
168
|
+
test('underline is colored when input is focused', function(done) {
|
169
|
+
var container = fixture('basic');
|
170
|
+
var input = Polymer.dom(container).querySelector('#i');
|
171
|
+
var line = Polymer.dom(container.root).querySelector('.underline');
|
172
|
+
assert.isFalse(line.classList.contains('is-highlighted'), 'line is not highlighted when input is not focused');
|
173
|
+
input.focus();
|
174
|
+
container._onFocus();
|
175
|
+
requestAnimationFrame(function() {
|
176
|
+
assert.equal(document.activeElement, input, 'input is focused');
|
177
|
+
assert.isTrue(line.classList.contains('is-highlighted'), 'line is highlighted when input is focused');
|
178
|
+
done();
|
179
|
+
});
|
180
|
+
});
|
181
|
+
|
182
|
+
});
|
183
|
+
|
184
|
+
suite('validation', function() {
|
185
|
+
|
186
|
+
test('styled when the input is set to an invalid value with auto-validate', function() {
|
187
|
+
var container = fixture('auto-validate-numbers');
|
188
|
+
var input = Polymer.dom(container).querySelector('#i');
|
189
|
+
var inputContent = Polymer.dom(container.root).querySelector('.input-content');
|
190
|
+
var line = Polymer.dom(container.root).querySelector('.underline');
|
191
|
+
|
192
|
+
input.bindValue = 'foobar';
|
193
|
+
|
194
|
+
assert.isTrue(container.invalid, 'invalid is true');
|
195
|
+
assert.isTrue(inputContent.classList.contains('is-invalid'), 'label has invalid styling when input is invalid');
|
196
|
+
assert.isTrue(line.classList.contains('is-invalid'), 'underline has invalid styling when input is invalid');
|
197
|
+
});
|
198
|
+
|
199
|
+
test('styled when the input is set to an invalid value with auto-validate, with validator', function() {
|
200
|
+
var container = fixture('auto-validate-validator');
|
201
|
+
var input = Polymer.dom(container).querySelector('#i');
|
202
|
+
var inputContent = Polymer.dom(container.root).querySelector('.input-content');
|
203
|
+
var line = Polymer.dom(container.root).querySelector('.underline');
|
204
|
+
|
205
|
+
input.bindValue = '123123';
|
206
|
+
|
207
|
+
assert.isTrue(container.invalid, 'invalid is true');
|
208
|
+
assert.isTrue(inputContent.classList.contains('is-invalid'), 'label has invalid styling when input is invalid');
|
209
|
+
assert.isTrue(line.classList.contains('is-invalid'), 'underline has invalid styling when input is invalid');
|
210
|
+
});
|
211
|
+
|
212
|
+
test('styled when the input is set initially to an invalid value with auto-validate, with validator', function() {
|
213
|
+
var container = fixture('auto-validate-validator-has-invalid-value');
|
214
|
+
assert.isTrue(container.invalid, 'invalid is true');
|
215
|
+
assert.isTrue(Polymer.dom(container.root).querySelector('.underline').classList.contains('is-invalid'), 'underline has is-invalid class');
|
216
|
+
});
|
217
|
+
|
218
|
+
test('styled when the input is set to an invalid value with manual validation', function() {
|
219
|
+
var container = fixture('manual-validate-numbers');
|
220
|
+
var input = Polymer.dom(container).querySelector('#i');
|
221
|
+
var inputContent = Polymer.dom(container.root).querySelector('.input-content');
|
222
|
+
var line = Polymer.dom(container.root).querySelector('.underline');
|
223
|
+
|
224
|
+
input.bindValue = 'foobar';
|
225
|
+
input.validate();
|
226
|
+
|
227
|
+
assert.isTrue(container.invalid, 'invalid is true');
|
228
|
+
assert.isTrue(inputContent.classList.contains('is-invalid'), 'label has invalid styling when input is invalid');
|
229
|
+
assert.isTrue(line.classList.contains('is-invalid'), 'underline has invalid styling when input is invalid');
|
230
|
+
});
|
231
|
+
|
232
|
+
});
|
233
|
+
|
234
|
+
</script>
|
235
|
+
|
236
|
+
</body>
|
237
|
+
</html>
|
@@ -0,0 +1,60 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<!--
|
3
|
+
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
4
|
+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
5
|
+
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
6
|
+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
7
|
+
Code distributed by Google as part of the polymer project is also
|
8
|
+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
9
|
+
-->
|
10
|
+
<html>
|
11
|
+
<head>
|
12
|
+
|
13
|
+
<title>paper-input-error tests</title>
|
14
|
+
|
15
|
+
<meta charset="utf-8">
|
16
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
17
|
+
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
|
18
|
+
|
19
|
+
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
20
|
+
|
21
|
+
<script src="../../web-component-tester/browser.js"></script>
|
22
|
+
<script src="../../test-fixture/test-fixture-mocha.js"></script>
|
23
|
+
|
24
|
+
<link rel="import" href="../../test-fixture/test-fixture.html">
|
25
|
+
<link rel="import" href="../../iron-input/iron-input.html">
|
26
|
+
<link rel="import" href="../paper-input-container.html">
|
27
|
+
<link rel="import" href="../paper-input-error.html">
|
28
|
+
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
|
32
|
+
<test-fixture id="auto-validate-numbers">
|
33
|
+
<template>
|
34
|
+
<paper-input-container auto-validate attr-for-value="bind-value">
|
35
|
+
<label id="l">label</label>
|
36
|
+
<input is="iron-input" id="i" pattern="[0-9]*">
|
37
|
+
<paper-input-error id="e">error</paper-input-error>
|
38
|
+
</paper-input-container>
|
39
|
+
</template>
|
40
|
+
</test-fixture>
|
41
|
+
|
42
|
+
<script>
|
43
|
+
|
44
|
+
suite('basic', function() {
|
45
|
+
|
46
|
+
test('error message only appears when input is invalid', function() {
|
47
|
+
var container = fixture('auto-validate-numbers');
|
48
|
+
var input = Polymer.dom(container).querySelector('#i');
|
49
|
+
var error = Polymer.dom(container).querySelector('#e');
|
50
|
+
assert.equal(getComputedStyle(error).display, 'none', 'error is display:none');
|
51
|
+
input.bindValue = 'foobar';
|
52
|
+
assert.notEqual(getComputedStyle(error).display, 'none', 'error is not display:none');
|
53
|
+
});
|
54
|
+
|
55
|
+
});
|
56
|
+
|
57
|
+
</script>
|
58
|
+
|
59
|
+
</body>
|
60
|
+
</html>
|
@@ -0,0 +1,213 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<!--
|
3
|
+
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
4
|
+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
5
|
+
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
6
|
+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
7
|
+
Code distributed by Google as part of the polymer project is also
|
8
|
+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
9
|
+
-->
|
10
|
+
<html>
|
11
|
+
<head>
|
12
|
+
|
13
|
+
<title>paper-input tests</title>
|
14
|
+
|
15
|
+
<meta charset="utf-8">
|
16
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
17
|
+
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
|
18
|
+
|
19
|
+
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
20
|
+
|
21
|
+
<script src="../../web-component-tester/browser.js"></script>
|
22
|
+
<script src="../../test-fixture/test-fixture-mocha.js"></script>
|
23
|
+
|
24
|
+
<script src="../../iron-test-helpers/test-helpers.js"></script>
|
25
|
+
|
26
|
+
<link rel="import" href="../../test-fixture/test-fixture.html">
|
27
|
+
<link rel="import" href="../paper-input.html">
|
28
|
+
<link rel="import" href="letters-only.html">
|
29
|
+
|
30
|
+
</head>
|
31
|
+
<body>
|
32
|
+
|
33
|
+
<test-fixture id="basic">
|
34
|
+
<template>
|
35
|
+
<paper-input></paper-input>
|
36
|
+
</template>
|
37
|
+
</test-fixture>
|
38
|
+
|
39
|
+
<test-fixture id="label">
|
40
|
+
<template>
|
41
|
+
<paper-input label="foo"></paper-input>
|
42
|
+
</template>
|
43
|
+
</test-fixture>
|
44
|
+
|
45
|
+
<test-fixture id="error">
|
46
|
+
<template>
|
47
|
+
<paper-input auto-validate pattern="[0-9]*" value="foobar" error-message="error"></paper-input>
|
48
|
+
</template>
|
49
|
+
</test-fixture>
|
50
|
+
|
51
|
+
<test-fixture id="required">
|
52
|
+
<template>
|
53
|
+
<paper-input auto-validate required error-message="error"></paper-input>
|
54
|
+
</template>
|
55
|
+
</test-fixture>
|
56
|
+
|
57
|
+
<test-fixture id="required-no-auto-validate">
|
58
|
+
<template>
|
59
|
+
<paper-input required error-message="error"></paper-input>
|
60
|
+
</template>
|
61
|
+
</test-fixture>
|
62
|
+
|
63
|
+
|
64
|
+
<test-fixture id="required-char-counter">
|
65
|
+
<template>
|
66
|
+
<paper-input auto-validate char-counter required error-message="error"></paper-input>
|
67
|
+
</template>
|
68
|
+
</test-fixture>
|
69
|
+
|
70
|
+
<test-fixture id="char-counter">
|
71
|
+
<template>
|
72
|
+
<paper-input char-counter value="foobar"></paper-input>
|
73
|
+
</template>
|
74
|
+
</test-fixture>
|
75
|
+
|
76
|
+
<test-fixture id="always-float-label">
|
77
|
+
<template>
|
78
|
+
<paper-input always-float-label label="foo"></paper-input>
|
79
|
+
</template>
|
80
|
+
</test-fixture>
|
81
|
+
|
82
|
+
<test-fixture id="placeholder">
|
83
|
+
<template>
|
84
|
+
<paper-input label="foo" placeholder="bar"></paper-input>
|
85
|
+
</template>
|
86
|
+
</test-fixture>
|
87
|
+
|
88
|
+
<letters-only></letters-only>
|
89
|
+
|
90
|
+
<test-fixture id="validator">
|
91
|
+
<template>
|
92
|
+
<paper-input value="123123" validator="letters-only" auto-validate></paper-input>
|
93
|
+
</template>
|
94
|
+
</test-fixture>
|
95
|
+
|
96
|
+
<script>
|
97
|
+
|
98
|
+
suite('basic', function() {
|
99
|
+
|
100
|
+
test('setting value sets the input value', function() {
|
101
|
+
var input = fixture('basic');
|
102
|
+
input.value = 'foobar';
|
103
|
+
assert.equal(input.inputElement.value, input.value, 'inputElement.value equals input.value');
|
104
|
+
});
|
105
|
+
|
106
|
+
test('placeholder does not overlap label', function() {
|
107
|
+
var input = fixture('placeholder');
|
108
|
+
assert.equal(input.inputElement.placeholder, input.placeholder, 'inputElement.placeholder equals input.placeholder');
|
109
|
+
assert.equal(input.noLabelFloat, false);
|
110
|
+
var floatingLabel = Polymer.dom(Polymer.dom(input.root).querySelector('paper-input-container').root).querySelector('.label-is-floating');
|
111
|
+
assert.ok(floatingLabel);
|
112
|
+
});
|
113
|
+
|
114
|
+
test('always-float-label attribute works without placeholder', function() {
|
115
|
+
var input = fixture('always-float-label');
|
116
|
+
var container = Polymer.dom(input.root).querySelector('paper-input-container');
|
117
|
+
var inputContent = Polymer.dom(container.root).querySelector('.input-content');
|
118
|
+
assert.isTrue(inputContent.classList.contains('label-is-floating'), 'label is floating');
|
119
|
+
});
|
120
|
+
|
121
|
+
test('error message is displayed', function() {
|
122
|
+
var input = fixture('error');
|
123
|
+
forceXIfStamp(input);
|
124
|
+
var error = Polymer.dom(input.root).querySelector('paper-input-error');
|
125
|
+
assert.ok(error, 'paper-input-error exists');
|
126
|
+
assert.notEqual(getComputedStyle(error).display, 'none', 'error is not display:none');
|
127
|
+
});
|
128
|
+
|
129
|
+
test('empty required input shows error', function() {
|
130
|
+
var input = fixture('required');
|
131
|
+
forceXIfStamp(input);
|
132
|
+
var error = Polymer.dom(input.root).querySelector('paper-input-error');
|
133
|
+
assert.ok(error, 'paper-input-error exists');
|
134
|
+
assert.notEqual(getComputedStyle(error).display, 'none', 'error is not display:none');
|
135
|
+
});
|
136
|
+
|
137
|
+
test('character counter is displayed', function() {
|
138
|
+
var input = fixture('char-counter');
|
139
|
+
forceXIfStamp(input);
|
140
|
+
var counter = Polymer.dom(input.root).querySelector('paper-input-char-counter')
|
141
|
+
assert.ok(counter, 'paper-input-char-counter exists');
|
142
|
+
assert.equal(counter._charCounterStr, input.value.length, 'character counter shows the value length');
|
143
|
+
});
|
144
|
+
|
145
|
+
test('validator is used', function() {
|
146
|
+
var input = fixture('validator');
|
147
|
+
assert.ok(input.inputElement.invalid, 'input is invalid');
|
148
|
+
});
|
149
|
+
|
150
|
+
test('caret position is preserved', function() {
|
151
|
+
var input = fixture('basic');
|
152
|
+
var ironInput = Polymer.dom(input.root).querySelector('input[is="iron-input"]');
|
153
|
+
input.value = 'nananana';
|
154
|
+
ironInput.selectionStart = 2;
|
155
|
+
ironInput.selectionEnd = 2;
|
156
|
+
|
157
|
+
input.updateValueAndPreserveCaret('nanananabatman');
|
158
|
+
|
159
|
+
assert.equal(ironInput.selectionStart, 2, 'selectionStart is preserved');
|
160
|
+
assert.equal(ironInput.selectionEnd, 2, 'selectionEnd is preserved');
|
161
|
+
});
|
162
|
+
|
163
|
+
});
|
164
|
+
|
165
|
+
suite('validation', function() {
|
166
|
+
|
167
|
+
test('invalid attribute updated after calling validate()', function() {
|
168
|
+
var input = fixture('required-no-auto-validate');
|
169
|
+
forceXIfStamp(input);
|
170
|
+
input.validate();
|
171
|
+
var error = Polymer.dom(input.root).querySelector('paper-input-error');
|
172
|
+
assert.ok(error, 'paper-input-error exists');
|
173
|
+
assert.notEqual(getComputedStyle(error).display, 'none', 'error is not display:none');
|
174
|
+
assert.isTrue(input.invalid, 'invalid is true');
|
175
|
+
});
|
176
|
+
|
177
|
+
});
|
178
|
+
|
179
|
+
suite('a11y', function() {
|
180
|
+
|
181
|
+
test('has aria-labelledby', function() {
|
182
|
+
var input = fixture('label');
|
183
|
+
assert.isTrue(input.inputElement.hasAttribute('aria-labelledby'))
|
184
|
+
assert.equal(input.inputElement.getAttribute('aria-labelledby'), Polymer.dom(input.root).querySelector('label').id, 'aria-labelledby points to the label');
|
185
|
+
});
|
186
|
+
|
187
|
+
test('has aria-describedby for error message', function() {
|
188
|
+
var input = fixture('required');
|
189
|
+
forceXIfStamp(input);
|
190
|
+
assert.isTrue(input.inputElement.hasAttribute('aria-describedby'));
|
191
|
+
assert.equal(input.inputElement.getAttribute('aria-describedby'), Polymer.dom(input.root).querySelector('paper-input-error').id, 'aria-describedby points to the error message');
|
192
|
+
});
|
193
|
+
|
194
|
+
test('has aria-describedby for character counter', function() {
|
195
|
+
var input = fixture('char-counter');
|
196
|
+
forceXIfStamp(input);
|
197
|
+
assert.isTrue(input.inputElement.hasAttribute('aria-describedby'));
|
198
|
+
assert.equal(input.inputElement.getAttribute('aria-describedby'), Polymer.dom(input.root).querySelector('paper-input-char-counter').id, 'aria-describedby points to the character counter');
|
199
|
+
});
|
200
|
+
|
201
|
+
test('has aria-describedby for character counter and error', function() {
|
202
|
+
var input = fixture('required-char-counter');
|
203
|
+
forceXIfStamp(input);
|
204
|
+
assert.isTrue(input.inputElement.hasAttribute('aria-describedby'));
|
205
|
+
assert.equal(input.inputElement.getAttribute('aria-describedby'), Polymer.dom(input.root).querySelector('paper-input-error').id + ' ' + Polymer.dom(input.root).querySelector('paper-input-char-counter').id, 'aria-describedby points to the error message and character counter');
|
206
|
+
});
|
207
|
+
|
208
|
+
});
|
209
|
+
|
210
|
+
</script>
|
211
|
+
|
212
|
+
</body>
|
213
|
+
</html>
|