| | 154 | }}, |
|---|
| | 155 | |
|---|
| | 156 | // Same integration test, results has no linebreaks |
|---|
| | 157 | testAjaxAutocompleterNoLinebreaksInResult: function() { with(this) { |
|---|
| | 158 | var ac = new Ajax.Autocompleter('ac_input_br','ac_update_br','_autocomplete_result_nobr.html', |
|---|
| | 159 | { method: 'get' }); //override so we can use a static for the result |
|---|
| | 160 | assertInstanceOf(Ajax.Autocompleter, ac); |
|---|
| | 161 | |
|---|
| | 162 | // box not visible |
|---|
| | 163 | assertNotVisible('ac_update_br'); |
|---|
| | 164 | |
|---|
| | 165 | // focus, but box not visible |
|---|
| | 166 | Event.simulateMouse('ac_input_br', 'click'); |
|---|
| | 167 | assertNotVisible('ac_update_br'); |
|---|
| | 168 | |
|---|
| | 169 | Event.simulateKeys('ac_input_br','abcdefg'); |
|---|
| | 170 | assertEqual('abcdefg', $('ac_input_br').value); |
|---|
| | 171 | |
|---|
| | 172 | // check box popping up on input |
|---|
| | 173 | wait(1000, function() { with(this) { |
|---|
| | 174 | assertVisible('ac_update_br'); |
|---|
| | 175 | assertEqual('test1', $('ac_update_br').firstChild.firstChild.innerHTML); |
|---|
| | 176 | assertEqual('test2', $('ac_update_br').firstChild.firstChild.nextSibling.innerHTML); |
|---|
| | 177 | |
|---|
| | 178 | // intl. characters return (UTF-8) |
|---|
| | 179 | assertEqual('Here we have some international ©âîÃçâ ârÃ', $('ac_update_br').firstChild.lastChild.innerHTML); |
|---|
| | 180 | |
|---|
| | 181 | // first entry should be selected |
|---|
| | 182 | assert(Element.hasClassName($('ac_update_br').firstChild.firstChild, 'selected'),'Selected item should have a className of: selected'); |
|---|
| | 183 | |
|---|
| | 184 | Event.simulateKey('ac_input_br','keypress',{keyCode:Event.KEY_DOWN}); |
|---|
| | 185 | |
|---|
| | 186 | // second entry should be selected |
|---|
| | 187 | assert(!Element.hasClassName($('ac_update_br').firstChild.firstChild),'Item shouldn\'t have a className of: selected'); |
|---|
| | 188 | assert(Element.hasClassName($('ac_update_br').firstChild.firstChild.nextSibling, 'selected'),'Second entry should have a className of: selected'); |
|---|
| | 189 | |
|---|
| | 190 | // check selecting with <TAB> |
|---|
| | 191 | Event.simulateKey('ac_input_br','keypress',{keyCode:Event.KEY_TAB}); |
|---|
| | 192 | assertEqual('test2',$('ac_input_br').value); |
|---|
| | 193 | |
|---|
| | 194 | // check box going away |
|---|
| | 195 | wait(500, function() { with(this) { |
|---|
| | 196 | assertNotVisible('ac_update_br'); |
|---|
| | 197 | |
|---|
| | 198 | // check selecting with mouse click |
|---|
| | 199 | Event.simulateKeys('ac_input_br','3'); |
|---|
| | 200 | assertEqual('test23', $('ac_input_br').value); |
|---|
| | 201 | wait(1000, function() { with(this) { |
|---|
| | 202 | assertVisible('ac_update_br'); |
|---|
| | 203 | Event.simulateMouse($('ac_update_br').firstChild.childNodes[4],'click'); |
|---|
| | 204 | |
|---|
| | 205 | wait(1000, function() { with(this) { |
|---|
| | 206 | // tests if removal of 'informal' nodes and HTML escaping works |
|---|
| | 207 | assertEqual('(GET <ME> INSTEAD)',$('ac_input_br').value); |
|---|
| | 208 | assertNotVisible('ac_update_br'); |
|---|
| | 209 | |
|---|
| | 210 | // check cancelling with <ESC> |
|---|
| | 211 | Event.simulateKeys('ac_input_br','abcdefg'); |
|---|
| | 212 | |
|---|
| | 213 | wait(1000, function() { with(this) { |
|---|
| | 214 | assertVisible('ac_update_br'); |
|---|
| | 215 | assertEqual('(GET <ME> INSTEAD)abcdefg', $('ac_input_br').value); |
|---|
| | 216 | |
|---|
| | 217 | Event.simulateKey('ac_input_br','keypress',{keyCode:Event.KEY_DOWN}); |
|---|
| | 218 | Event.simulateKey('ac_input_br','keypress',{keyCode:Event.KEY_ESC}); |
|---|
| | 219 | |
|---|
| | 220 | assertEqual('(GET <ME> INSTEAD)abcdefg', $('ac_input_br').value); |
|---|
| | 221 | }}); |
|---|
| | 222 | }}); |
|---|
| | 223 | }}); |
|---|
| | 224 | }}); |
|---|
| | 225 | }}); |
|---|