a1a3bc73
Luigi Serra
graphs updates
|
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
|
<!doctype html>
<!--
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-toast-basic</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<link rel="import" href="../paper-toast.html">
</head>
<body>
<test-fixture id="basic">
<template>
<paper-toast></paper-toast>
</template>
</test-fixture>
<test-fixture id="show">
<template>
<paper-toast opened></paper-toast>
</template>
</test-fixture>
<script>
suite('basic', function() {
var toast;
test('is hidden', function() {
toast = fixture('basic');
assert.isFalse(toast.opened, '`opened` is false');
});
test('is visible', function() {
toast = fixture('show');
assert.isTrue(toast.opened, '`opened` is true');
});
test('show() will open toast', function() {
toast = fixture('basic');
toast.show();
assert.isTrue(toast.opened, '`opened` is true');
});
test('hide() will close toast', function() {
toast = fixture('show');
toast.hide();
assert.isFalse(toast.opened, '`opened` is false');
});
test('toast auto-close after 10ms', function(done) {
toast = fixture('basic');
toast.duration = 10;
toast.show();
setTimeout(function() {
assert.isFalse(toast.opened, '`opened` is false');
done();
}, 12);
});
suite('disable auto-close', function() {
var spy;
setup(function() {
toast = fixture('basic');
spy = sinon.spy(toast, 'async');
});
test('duration = Infinity', function() {
toast.duration = Infinity;
toast.show();
assert.isFalse(spy.calledWith(toast.close), '`async` was not called with `close()`');
assert.isFalse(spy.calledWith(toast.hide), '`async` was not called with `hide()`');
});
test('duration = 0', function() {
toast.duration = 0;
toast.show();
assert.isFalse(spy.calledWith(toast.close), '`async` was not called with `close()`');
assert.isFalse(spy.calledWith(toast.hide), '`async` was not called with `hide()`');
});
test('duration = -10', function() {
toast.duration = -10;
toast.show();
assert.isFalse(spy.calledWith(toast.close), '`async` was not called with `close()`');
assert.isFalse(spy.calledWith(toast.hide), '`async` was not called with `hide()`');
});
});
test('there is only 1 toast opened', function() {
var toast1 = fixture('basic');
var toast2 = fixture('show');
toast2.open();
toast1.open();
assert.isTrue(toast1.opened, 'toast1 is opened');
assert.isFalse(toast2.opened, 'toast2 is not opened');
toast2.open();
assert.isFalse(toast1.opened, 'toast1 is now not opened');
assert.isTrue(toast2.opened, 'toast2 is now opened');
});
test('auto-close is correctly reset', function(done) {
toast = fixture('basic');
toast.duration = 10;
toast.show();
// a bit later (before the auto-close), toast is reset
setTimeout(function() {
toast.hide();
// keep toast opened
toast.duration = 0;
toast.show();
setTimeout(function() {
assert.isTrue(toast.opened, 'toast is still open');
done();
}, 10);
}, 5);
});
suite('a11y', function() {
test('show() will announce text', function() {
toast = fixture('basic');
var spy = sinon.spy(toast, 'fire');
toast.text = 'announce!';
toast.show();
assert.isTrue(spy.calledWith('iron-announce', {
text: 'announce!'
}), 'text announced');
});
test('hide() will not announce text', function() {
toast = fixture('show');
var spy = sinon.spy(toast, 'fire');
toast.hide();
assert.isFalse(spy.calledWith('iron-announce'), 'text not announced');
});
});
});
</script>
</body>
</html>
|