|
109 | 109 | }); |
110 | 110 | }); |
111 | 111 |
|
112 | | - it('should fire pfe-search-event after click on search icon', (done) => { |
| 112 | + it('should fire pfe-autocomplete:search-event after click on search icon', (done) => { |
113 | 113 | flush(() => { |
114 | 114 | const input = autocompleteElem._input; |
115 | 115 | input.value = "test"; |
116 | 116 |
|
117 | | - autocompleteElem.addEventListener("pfe-search-event", function(event) { |
| 117 | + autocompleteElem.addEventListener("pfe-autocomplete:search-event", function(event) { |
118 | 118 | assert.equal(event.detail.searchValue, "test"); |
119 | 119 | done(); |
120 | 120 | }); |
|
133 | 133 | }); |
134 | 134 | }); |
135 | 135 |
|
136 | | - it('should fire pfe-search-event after user click on an option', done => { |
| 136 | + it('should fire pfe-autocomplete:search-event after user click on an option', done => { |
137 | 137 | flush(() => { |
138 | 138 | droplistElem.data = ['option 1', 'option 2']; |
139 | 139 | droplistElem.reflow = true; |
140 | 140 | droplistElem.open = true; |
141 | 141 | let option = droplistElem.shadowRoot.querySelector('li:nth-child(2)'); |
142 | 142 |
|
143 | | - autocompleteElem.addEventListener("pfe-search-event", function(event) { |
| 143 | + autocompleteElem.addEventListener("pfe-autocomplete:search-event", function(event) { |
144 | 144 | assert.equal(event.detail.searchValue, "option 2"); |
145 | 145 | done(); |
146 | 146 | }); |
|
149 | 149 | }); |
150 | 150 | }); |
151 | 151 |
|
| 152 | + it('should fire a pfe-autocomplete:option-selected event when a user selects an option in the droplist with the enter key', done => { |
| 153 | + flush(() => { |
| 154 | + const input = autocompleteElem._input; |
| 155 | + droplistElem.data = ['option 1', 'option 2']; |
| 156 | + droplistElem.reflow = true; |
| 157 | + droplistElem.open = true; |
| 158 | + input.focus(); |
| 159 | + |
| 160 | + autocompleteElem.addEventListener("pfe-autocomplete:option-selected", function(event) { |
| 161 | + assert.equal(event.detail.optionValue, "option 1"); |
| 162 | + done(); |
| 163 | + }); |
| 164 | + |
| 165 | + MockInteractions.keyUpOn(input, 40); |
| 166 | + MockInteractions.keyUpOn(input, 13); |
| 167 | + }); |
| 168 | + }); |
| 169 | + |
| 170 | + it('should fire a pfe-autocomplete:option-selected event when a user selects an option in the droplist with the mouse', done => { |
| 171 | + flush(() => { |
| 172 | + droplistElem.data = ['option 1', 'option 2']; |
| 173 | + droplistElem.reflow = true; |
| 174 | + droplistElem.open = true; |
| 175 | + let option = droplistElem.shadowRoot.querySelector('li:nth-child(2)'); |
| 176 | + |
| 177 | + autocompleteElem.addEventListener("pfe-autocomplete:option-selected", function(event) { |
| 178 | + assert.equal(event.detail.optionValue, "option 2"); |
| 179 | + done(); |
| 180 | + }); |
| 181 | + |
| 182 | + MockInteractions.tap(option); |
| 183 | + }); |
| 184 | + }); |
| 185 | + |
152 | 186 | it('should set selected-value attribute after user click on an option', done => { |
153 | 187 | flush(() => { |
154 | 188 | droplistElem.data = ['option 1', 'option 2']; |
|
0 commit comments