Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1 | define( |
| 2 | ['alwaysmenu', 'menu/item', 'menu/prefix', 'menu/lengthField', 'alwaysentry'], |
| 3 | function (alwaysMenuClass, menuItemClass, prefixClass, lengthFieldClass, alwaysEntryClass) { |
| 4 | |
| 5 | //These class definitions were taken from menuSpec for a guideline on how to procede |
| 6 | |
| 7 | // The OwnAlwaysMenu item |
| 8 | const OwnAlwaysMenuItem = { |
| 9 | create : function (params) { |
| 10 | return Object.create(menuItemClass).upgradeTo(OwnAlwaysMenuItem)._init(params); |
| 11 | }, |
| 12 | content : function (content) { |
| 13 | if (arguments.length === 1) { |
| 14 | this._content = content; |
| 15 | }; |
| 16 | return this._content; |
| 17 | }, |
| 18 | _init : function (params) { |
| 19 | if (params[0] === undefined) |
| 20 | throw new Error("Missing parameters"); |
| 21 | |
| 22 | this._content = document.createTextNode(params[0]); |
| 23 | this._lcField = ' ' + this.content().textContent.toLowerCase(); |
| 24 | |
| 25 | return this; |
| 26 | } |
| 27 | }; |
| 28 | |
| 29 | // The OwnAlwaysMenu |
| 30 | let OwnAlwaysMenu = { |
| 31 | create : function (list) { |
| 32 | return alwaysMenuClass.create(list, { itemClass : OwnAlwaysMenuItem } ) |
| 33 | .upgradeTo(OwnAlwaysMenu); |
| 34 | } |
| 35 | }; |
| 36 | |
| 37 | |
| 38 | |
| 39 | // HintMenuItem |
| 40 | const HintMenuItem = { |
| 41 | create : function (params) { |
| 42 | return Object.create(menuItemClass) |
| 43 | .upgradeTo(HintMenuItem) |
| 44 | ._init(params); |
| 45 | }, |
| 46 | content : function (content) { |
| 47 | if (arguments.length === 1) { |
| 48 | this._content = content; |
| 49 | }; |
| 50 | return this._content; |
| 51 | }, |
| 52 | _init : function (params) { |
| 53 | if (params[0] === undefined || params[1] === undefined) |
| 54 | throw new Error("Missing parameters"); |
| 55 | |
| 56 | this._name = params[0]; |
| 57 | this._action = params[1]; |
| 58 | this._lcField = ' ' + this._name.toLowerCase(); |
| 59 | |
| 60 | if (params.length > 2) { |
| 61 | this._desc = params[2]; |
| 62 | this._lcField += " " + this._desc.toLowerCase(); |
| 63 | }; |
| 64 | |
| 65 | return this; |
| 66 | }, |
| 67 | |
| 68 | name : function () { |
| 69 | return this._name; |
| 70 | }, |
| 71 | action : function () { |
| 72 | return this._action; |
| 73 | }, |
| 74 | desc : function () { |
| 75 | return this._desc; |
| 76 | }, |
| 77 | element : function () { |
| 78 | // already defined |
| 79 | if (this._el !== undefined) |
| 80 | return this._el; |
| 81 | |
| 82 | // Create list item |
| 83 | var li = document.createElement("li"); |
| 84 | li.setAttribute("data-action", this._action); |
| 85 | |
| 86 | // Create title |
| 87 | var name = document.createElement("strong"); |
| 88 | name.appendChild(document.createTextNode(this._name)); |
| 89 | |
| 90 | li.appendChild(name); |
| 91 | |
| 92 | // Create description |
| 93 | if (this._desc !== undefined) { |
| 94 | var desc = document.createElement("span"); |
| 95 | desc.appendChild(document.createTextNode(this._desc)); |
| 96 | li.appendChild(desc); |
| 97 | }; |
| 98 | return this._el = li; |
| 99 | } |
| 100 | }; |
| 101 | |
| 102 | |
| 103 | // HintMenu |
| 104 | const HintMenu = { |
| 105 | create : function (context, list) { |
| 106 | var obj = alwaysMenuClass.create(list, {itemClass : HintMenuItem} ) |
| 107 | .upgradeTo(HintMenu); |
| 108 | obj._context = context; |
| 109 | return obj; |
| 110 | } |
| 111 | }; |
| 112 | |
| 113 | |
| 114 | // The ComplexMenuItem |
| 115 | const ComplexMenuItem = { |
| 116 | create : function (params) { |
| 117 | return Object.create(menuItemClass) |
| 118 | .upgradeTo(ComplexMenuItem) |
| 119 | ._init(params); |
| 120 | }, |
| 121 | content : function (content) { |
| 122 | if (arguments.length === 1) { |
| 123 | this._content = content; |
| 124 | }; |
| 125 | return this._content; |
| 126 | }, |
| 127 | _init : function (params) { |
| 128 | if (params[0] === undefined) |
| 129 | throw new Error("Missing parameters"); |
| 130 | |
| 131 | var r = document.createElement('div'); |
| 132 | for (var i = 1; i <= params.length; i++) { |
| 133 | var h = document.createElement('h' + i); |
| 134 | h.appendChild(document.createTextNode(params[i-1])); |
| 135 | r.appendChild(h); |
| 136 | }; |
| 137 | |
| 138 | this._content = r; |
| 139 | this._lcField = ' ' + this.content().textContent.toLowerCase(); |
| 140 | |
| 141 | return this; |
| 142 | } |
| 143 | }; |
| 144 | |
| 145 | |
| 146 | describe('KorAP.AlwaysMenu', function () { |
| 147 | var list = [ |
| 148 | ["Constituency", "c=", "Example 1"], |
| 149 | ["Lemma", "l="], |
| 150 | ["Morphology", "m=", "Example 2"], |
| 151 | ["Part-of-Speech", "p="], |
| 152 | ["Syntax", "syn="] |
| 153 | ]; |
| 154 | |
| 155 | var listMultiPrefix = [ |
| 156 | ["PP","PP ","Personal Pronoun"], |
| 157 | ["PPP","PPP ","Personal Pronoun, Plural"], |
| 158 | ["PPPA","PPPA ","Personal Pronoun, Plural, Acc."], |
| 159 | ["PPPD","PPPD ","Personal Pronoun, Plural, Dative"], |
| 160 | ["PPPR","PPPR ","Personal Pronoun, Plural, Direct"], |
| 161 | ["PPPO","PPPO ","Personal Pronoun, Plural, Oblique"], |
| 162 | ["PPS","PPS ","Personal Pronoun, Singular"], |
| 163 | ["PPSA","PPSA ","Personal Pronoun, Singular, Accusative"], |
| 164 | ["PPSD","PPSD ","Personal Pronoun, Singular, Dative"], |
| 165 | ["PPSR","PPSR ","Personal Pronoun, Singular, Direct"], |
| 166 | ["PPSN","PPSN ","Personal Pronoun, Singular, Nominative"], |
| 167 | ["PPSO","PPSO ","Personal Pronoun, Singular, Oblique"] |
| 168 | ]; |
| 169 | |
| 170 | var demolist = [ |
| 171 | ['Titel', 'title'], |
| 172 | ['Untertitel', 'subTitle'], |
| 173 | ['Veröffentlichungsdatum', 'pubDate'], |
| 174 | ['Länge', 'length'], |
| 175 | ['Autor', 'author'] |
| 176 | ]; |
| 177 | |
| 178 | var demolonglist = [ |
| 179 | ['Titel', 'title'], |
| 180 | ['Untertitel', 'subTitle'], |
| 181 | ['Veröffentlichungsdatum', 'pubDate'], |
| 182 | ['Länge', 'length'], |
| 183 | ['Autor', 'author'], |
| 184 | ['Genre', 'genre'], |
| 185 | ['corpusID', 'corpusID'], |
| 186 | ['docID', 'docID'], |
| 187 | ['textID', 'textID'], |
| 188 | ]; |
| 189 | |
| 190 | it('should be initializable', function () { |
| 191 | var list = [ |
| 192 | ["Constituency"], |
| 193 | ["Lemma"], |
| 194 | ["Morphology"], |
| 195 | ["Part-of-Speech"], |
| 196 | ["Syntax"] |
| 197 | ]; |
| 198 | |
| 199 | var menu = OwnAlwaysMenu.create(list); |
| 200 | menu._firstActive = true; |
| 201 | expect(menu.itemClass()).toEqual(OwnAlwaysMenuItem); |
| 202 | expect(menu._notItemElements).toEqual(4); |
| 203 | expect(menu.element().getElementsByClassName("pref").length).toEqual(2); //TODO: new scss = new class |
| 204 | expect(menu.element().getElementsByClassName("pref")[1].innerHTML).toEqual("Speichern"); |
| 205 | expect(menu.alwaysEntry().element().innerHTML).toEqual("Speichern"); |
| 206 | //expect(menu.element().childNodes[3].innerHTML).toEqual("Speichern"); //? |
| 207 | // getElementsByClassName funktioniert bei allen Kindern. |
| 208 | |
| 209 | |
| 210 | // view |
| 211 | menu.show(); |
| 212 | |
| 213 | expect(menu.alwaysEntry().active()).toBe(false); |
| 214 | }); |
| 215 | |
| 216 | it('should be visible', function () { |
| 217 | var menu = HintMenu.create("cnx/", list); |
| 218 | expect(menu.removeItems()).toBe(undefined); |
| 219 | menu.limit(3); |
| 220 | |
| 221 | expect(menu.show()).toBe(true); |
| 222 | |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 223 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>"); |
| 224 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Lemma</strong>"); |
| 225 | expect(menu.directElementChildrenByTagName("li")[1].getAttribute("data-action")).toEqual("l="); |
| 226 | expect(menu.directElementChildrenByTagName("li")[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>"); |
| 227 | expect(menu.directElementChildrenByTagName("li")[3]).toBe(undefined); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 228 | |
| 229 | // Check boundaries |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 230 | expect(menu.directElementChildrenByTagName("li")[0].classList.contains("no-more")).toBe(true); |
| 231 | expect(menu.directElementChildrenByTagName("li")[1].classList.contains("no-more")).toBe(false); |
| 232 | expect(menu.directElementChildrenByTagName("li")[2].classList.contains("no-more")).toBe(false); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 233 | }); |
| 234 | |
| 235 | it('should be filterable', function () { |
| 236 | var menu = HintMenu.create("cnx/", list); |
| 237 | menu.limit(3); |
| 238 | expect(menu.prefix("o").show()).toBe(true); |
| 239 | expect(menu.alwaysEntryValue("o").alwaysEntryValue()).toEqual("o"); |
| 240 | expect(menu.element().getElementsByClassName("pref")[0].innerHTML).toEqual("o"); |
| 241 | expect(menu.alwaysEntry().element().innerHTML).toEqual("Speichern"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 242 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>"); |
| 243 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>"); |
| 244 | expect(menu.directElementChildrenByTagName("li")[2].innerHTML).toEqual("<strong>Part-<mark>o</mark>f-Speech</strong>"); |
| 245 | expect(menu.directElementChildrenByTagName("li")[3]).toBe(undefined); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 246 | |
| 247 | // Check boundaries |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 248 | expect(menu.directElementChildrenByTagName("li")[0].classList.contains("no-more")).toBe(true); |
| 249 | expect(menu.directElementChildrenByTagName("li")[1].classList.contains("no-more")).toBe(false); |
| 250 | expect(menu.directElementChildrenByTagName("li")[2].classList.contains("no-more")).toBe(true); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 251 | |
| 252 | menu.limit(2); |
| 253 | |
| 254 | expect(menu.prefix("o").show()).toBe(true); |
| 255 | expect(menu.alwaysEntryValue("o").alwaysEntryValue()).toEqual("o"); |
| 256 | expect(menu.element().getElementsByClassName("pref")[0].innerHTML).toEqual("o"); |
| 257 | expect(menu.alwaysEntry().element().innerHTML).toEqual("Speichern"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 258 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>"); |
| 259 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>"); |
| 260 | expect(menu.directElementChildrenByTagName("li")[2]).toBe(undefined); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 261 | |
| 262 | // Check boundaries |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 263 | expect(menu.directElementChildrenByTagName("li")[0].classList.contains("no-more")).toBe(true); |
| 264 | expect(menu.directElementChildrenByTagName("li")[1].classList.contains("no-more")).toBe(false); |
| 265 | expect(menu.directElementChildrenByTagName("li")[2]).toBe(undefined); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 266 | |
| 267 | expect(menu.prefix("e").show()).toBe(true); |
| 268 | expect(menu.alwaysEntryValue("e").alwaysEntryValue()).toEqual("e"); |
| 269 | expect(menu.element().getElementsByClassName("pref")[0].innerHTML).toEqual("e"); |
| 270 | expect(menu.alwaysEntry().element().innerHTML).toEqual("Speichern"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 271 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>"); |
| 272 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>"); |
| 273 | expect(menu.directElementChildrenByTagName("li")[2]).toBe(undefined); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 274 | |
| 275 | menu.limit(5); |
| 276 | expect(menu.prefix("a").show()).toBe(true); |
| 277 | expect(menu.alwaysEntryValue("a").alwaysEntryValue()).toEqual("a"); |
| 278 | expect(menu.element().getElementsByClassName("pref")[0].innerHTML).toEqual("a"); |
| 279 | expect(menu.alwaysEntry().element().innerHTML).toEqual("Speichern"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 280 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Constituency</strong><span>Ex<mark>a</mark>mple 1</span>"); |
| 281 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Lemm<mark>a</mark></strong>"); |
| 282 | expect(menu.directElementChildrenByTagName("li")[2].innerHTML).toEqual("<strong>Morphology</strong><span>Ex<mark>a</mark>mple 2</span>"); |
| 283 | expect(menu.directElementChildrenByTagName("li")[3].innerHTML).toEqual("<strong>P<mark>a</mark>rt-of-Speech</strong>"); |
| 284 | expect(menu.directElementChildrenByTagName("li")[4].innerHTML).toEqual("<strong>Synt<mark>a</mark>x</strong>"); |
| 285 | expect(menu.directElementChildrenByTagName("li")[5]).toBe(undefined); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 286 | }); |
| 287 | |
| 288 | |
| 289 | it('should be nextable', function () { |
| 290 | var menu = HintMenu.create("cnx/", list); |
| 291 | menu._firstActive = true; |
| 292 | |
| 293 | expect(menu._prefix.active()).toBe(false); |
| 294 | |
| 295 | // Show only 3 items |
| 296 | menu.limit(3); |
| 297 | expect(menu.show()).toBe(true); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 298 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 299 | expect(menu.shownItem(0).active()).toBe(true); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 300 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Lemma</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 301 | expect(menu.shownItem(1).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 302 | expect(menu.directElementChildrenByTagName("li")[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 303 | expect(menu.shownItem(2).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 304 | expect(menu.directElementChildrenByTagName("li")[3]).toBe(undefined); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 305 | expect(menu.alwaysEntry().active()).toBe(false); |
| 306 | |
| 307 | // Activate next (1) |
| 308 | menu.next(); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 309 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 310 | expect(menu.shownItem(0).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 311 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Lemma</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 312 | expect(menu.shownItem(1).active()).toBe(true); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 313 | expect(menu.directElementChildrenByTagName("li")[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 314 | expect(menu.shownItem(2).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 315 | expect(menu.directElementChildrenByTagName("li")[3]).toBe(undefined); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 316 | expect(menu.alwaysEntry().active()).toBe(false); |
| 317 | |
| 318 | // Activate next (2) |
| 319 | menu.next(); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 320 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 321 | expect(menu.shownItem(0).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 322 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Lemma</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 323 | expect(menu.shownItem(1).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 324 | expect(menu.directElementChildrenByTagName("li")[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 325 | expect(menu.shownItem(2).active()).toBe(true); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 326 | expect(menu.directElementChildrenByTagName("li")[3]).toBe(undefined); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 327 | expect(menu.alwaysEntry().active()).toBe(false); |
| 328 | |
| 329 | // Activate next (3) |
| 330 | // scroll! |
| 331 | menu.next(); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 332 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Lemma</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 333 | expect(menu.shownItem(0).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 334 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 335 | expect(menu.shownItem(1).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 336 | expect(menu.directElementChildrenByTagName("li")[2].innerHTML).toEqual("<strong>Part-of-Speech</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 337 | expect(menu.shownItem(2).active()).toBe(true); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 338 | expect(menu.directElementChildrenByTagName("li")[3]).toBe(undefined); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 339 | expect(menu.alwaysEntry().active()).toBe(false); |
| 340 | |
| 341 | // Activate next (4) |
| 342 | menu.next(); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 343 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 344 | expect(menu.shownItem(0).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 345 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Part-of-Speech</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 346 | expect(menu.shownItem(1).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 347 | expect(menu.directElementChildrenByTagName("li")[2].innerHTML).toEqual("<strong>Syntax</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 348 | expect(menu.shownItem(2).active()).toBe(true); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 349 | expect(menu.directElementChildrenByTagName("li")[3]).toBe(undefined); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 350 | expect(menu.alwaysEntry().active()).toBe(false); |
| 351 | |
| 352 | // Activate next (5) - Entry / Speichern |
| 353 | menu.next(); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 354 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 355 | expect(menu.shownItem(0).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 356 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Part-of-Speech</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 357 | expect(menu.shownItem(1).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 358 | expect(menu.directElementChildrenByTagName("li")[2].innerHTML).toEqual("<strong>Syntax</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 359 | expect(menu.shownItem(2).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 360 | expect(menu.directElementChildrenByTagName("li")[3]).toBe(undefined); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 361 | expect(menu.alwaysEntry().active()).toBe(true); |
| 362 | |
| 363 | // Activate next (6) - ROLL |
| 364 | menu.next(); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 365 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 366 | expect(menu.shownItem(0).active()).toBe(true); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 367 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Lemma</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 368 | expect(menu.shownItem(1).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 369 | expect(menu.directElementChildrenByTagName("li")[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 370 | expect(menu.shownItem(2).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 371 | expect(menu.directElementChildrenByTagName("li")[3]).toBe(undefined); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 372 | expect(menu.alwaysEntry().active()).toBe(false); |
| 373 | |
| 374 | // Active next (7) |
| 375 | menu.next(); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 376 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 377 | expect(menu.shownItem(0).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 378 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Lemma</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 379 | expect(menu.shownItem(1).active()).toBe(true); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 380 | expect(menu.directElementChildrenByTagName("li")[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 381 | expect(menu.shownItem(2).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 382 | expect(menu.directElementChildrenByTagName("li")[3]).toBe(undefined); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 383 | expect(menu.alwaysEntry().active()).toBe(false); |
| 384 | |
| 385 | expect(menu._prefix.active()).toBe(false); |
| 386 | }); |
| 387 | |
| 388 | it('should be nextable without active field', function () { |
| 389 | var menu = HintMenu.create("cnx/", list); |
| 390 | menu.limit(3); |
| 391 | expect(menu.show()).toBe(true); |
| 392 | menu.next(); |
| 393 | expect(menu.shownItem(0).active()).toEqual(true); |
| 394 | }); |
| 395 | |
| 396 | |
| 397 | it('should be prevable', function () { |
| 398 | var menu = HintMenu.create("cnx/", list); |
| 399 | menu._firstActive = true; |
| 400 | menu.limit(3); |
| 401 | expect(menu.show()).toBe(true); |
| 402 | expect(menu._prefix.active()).toBe(false); |
| 403 | expect(menu.alwaysEntryValue()).toBe(""); |
| 404 | |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 405 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 406 | expect(menu.shownItem(0).active()).toBe(true); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 407 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Lemma</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 408 | expect(menu.shownItem(1).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 409 | expect(menu.directElementChildrenByTagName("li")[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 410 | expect(menu.shownItem(2).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 411 | expect(menu.directElementChildrenByTagName("li")[3]).toBe(undefined); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 412 | expect(menu.alwaysEntry().active()).toBe(false); |
| 413 | |
| 414 | |
| 415 | // Activate prev (1) - roll to bottom |
| 416 | menu.prev(); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 417 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 418 | expect(menu.shownItem(0).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 419 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Lemma</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 420 | expect(menu.shownItem(1).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 421 | expect(menu.directElementChildrenByTagName("li")[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 422 | expect(menu.shownItem(2).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 423 | expect(menu.directElementChildrenByTagName("li")[3]).toBe(undefined); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 424 | expect(menu.alwaysEntry().active()).toBe(true); |
| 425 | |
| 426 | // Activate prev (2) |
| 427 | menu.prev(); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 428 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 429 | expect(menu.shownItem(0).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 430 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Part-of-Speech</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 431 | expect(menu.shownItem(1).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 432 | expect(menu.directElementChildrenByTagName("li")[2].innerHTML).toEqual("<strong>Syntax</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 433 | expect(menu.shownItem(2).active()).toBe(true); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 434 | expect(menu.directElementChildrenByTagName("li")[3]).toBe(undefined); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 435 | expect(menu.alwaysEntry().active()).toBe(false); |
| 436 | |
| 437 | // Activate prev (3) |
| 438 | menu.prev(); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 439 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 440 | expect(menu.shownItem(0).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 441 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Part-of-Speech</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 442 | expect(menu.shownItem(1).active()).toBe(true); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 443 | expect(menu.directElementChildrenByTagName("li")[2].innerHTML).toEqual("<strong>Syntax</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 444 | expect(menu.shownItem(2).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 445 | expect(menu.directElementChildrenByTagName("li")[3]).toBe(undefined); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 446 | expect(menu.alwaysEntry().active()).toBe(false); |
| 447 | |
| 448 | // Activate prev (4) |
| 449 | menu.prev(); |
| 450 | expect(menu.shownItem(0).name()).toEqual("Morphology"); |
| 451 | expect(menu.shownItem(0).active()).toBe(true); |
| 452 | expect(menu.shownItem(1).name()).toEqual("Part-of-Speech"); |
| 453 | expect(menu.shownItem(1).active()).toBe(false); |
| 454 | expect(menu.shownItem(2).name()).toEqual("Syntax"); |
| 455 | expect(menu.shownItem(2).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 456 | expect(menu.directElementChildrenByTagName("li")[3]).toBe(undefined); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 457 | expect(menu.alwaysEntry().active()).toBe(false); |
| 458 | |
| 459 | // Activate prev (5) |
| 460 | menu.prev(); |
| 461 | expect(menu.shownItem(0).name()).toEqual("Lemma"); |
| 462 | expect(menu.shownItem(0).active()).toBe(true); |
| 463 | expect(menu.shownItem(1).name()).toEqual("Morphology"); |
| 464 | expect(menu.shownItem(1).active()).toBe(false); |
| 465 | expect(menu.shownItem(2).name()).toEqual("Part-of-Speech"); |
| 466 | expect(menu.shownItem(2).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 467 | expect(menu.directElementChildrenByTagName("li")[3]).toBe(undefined); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 468 | expect(menu.alwaysEntry().active()).toBe(false); |
| 469 | |
| 470 | // Activate prev (6) |
| 471 | menu.prev(); |
| 472 | expect(menu.shownItem(0).name()).toEqual("Constituency"); |
| 473 | expect(menu.shownItem(0).active()).toBe(true); |
| 474 | expect(menu.shownItem(1).name()).toEqual("Lemma"); |
| 475 | expect(menu.shownItem(1).active()).toBe(false); |
| 476 | expect(menu.shownItem(2).name()).toEqual("Morphology"); |
| 477 | expect(menu.shownItem(2).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 478 | expect(menu.directElementChildrenByTagName("li")[3]).toBe(undefined); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 479 | expect(menu.alwaysEntry().active()).toBe(false); |
| 480 | |
| 481 | // Activate next (7) |
| 482 | menu.next(); |
| 483 | expect(menu.shownItem(0).name()).toEqual("Constituency"); |
| 484 | expect(menu.shownItem(0).active()).toBe(false); |
| 485 | expect(menu.shownItem(1).name()).toEqual("Lemma"); |
| 486 | expect(menu.shownItem(1).active()).toBe(true); |
| 487 | expect(menu.shownItem(2).name()).toEqual("Morphology"); |
| 488 | expect(menu.shownItem(2).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 489 | expect(menu.directElementChildrenByTagName("li")[3]).toBe(undefined); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 490 | expect(menu.alwaysEntry().active()).toBe(false); |
| 491 | |
| 492 | // Activate prev (8) |
| 493 | menu.prev(); |
| 494 | |
| 495 | // Activate prev (9) - Roll again |
| 496 | menu.prev(); |
| 497 | expect(menu.shownItem(0).name()).toEqual("Constituency"); |
| 498 | expect(menu.shownItem(0).active()).toBe(false); |
| 499 | expect(menu.shownItem(1).name()).toEqual("Lemma"); |
| 500 | expect(menu.shownItem(1).active()).toBe(false); |
| 501 | expect(menu.shownItem(2).name()).toEqual("Morphology"); |
| 502 | expect(menu.shownItem(2).active()).toBe(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 503 | expect(menu.directElementChildrenByTagName("li")[3]).toBe(undefined); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 504 | expect(menu.alwaysEntry().active()).toBe(true); |
| 505 | |
| 506 | // Activate prev (10) |
| 507 | menu.prev() |
| 508 | expect(menu.shownItem(0).name()).toEqual("Morphology"); |
| 509 | expect(menu.shownItem(0).active()).toBe(false); |
| 510 | expect(menu.shownItem(1).name()).toEqual("Part-of-Speech"); |
| 511 | expect(menu.shownItem(1).active()).toBe(false); |
| 512 | expect(menu.shownItem(2).name()).toEqual("Syntax"); |
| 513 | expect(menu.shownItem(2).active()).toBe(true); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 514 | expect(menu.directElementChildrenByTagName("li")[3]).toBe(undefined); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 515 | expect(menu.alwaysEntry().active()).toBe(false); |
| 516 | expect(menu._prefix.active()).toBe(false); |
| 517 | expect(menu.alwaysEntryValue()).toBe(""); |
| 518 | expect(menu.alwaysEntry().element().innerHTML).toBe("Speichern"); |
| 519 | |
| 520 | }); |
| 521 | |
| 522 | it('should be prevable without active field', function () { |
| 523 | var menu = HintMenu.create("cnx/", list); |
| 524 | menu.limit(3); |
| 525 | expect(menu.show()).toBe(true); |
| 526 | menu.prev(); |
| 527 | expect(menu.alwaysEntry().active()).toBe(true); |
| 528 | expect(menu.shownItem(2).active()).toEqual(false); |
| 529 | expect(menu.shownItem(2).lcField()).toEqual(' morphology example 2'); |
| 530 | menu.prev() |
| 531 | expect(menu.shownItem(2).active()).toEqual(true); |
| 532 | expect(menu.shownItem(2).lcField()).toEqual(' syntax'); |
| 533 | }); |
| 534 | |
| 535 | it('should be navigatable and filterable (prefix = "o")', function () { |
| 536 | var menu = HintMenu.create("cnx/", list); |
| 537 | menu._firstActive = true; |
| 538 | menu.limit(2); |
| 539 | |
| 540 | expect(menu.prefix("o").show()).toBe(true); |
| 541 | expect(menu.alwaysEntryValue("o").alwaysEntryValue()).toBe("o"); |
| 542 | expect(menu._prefix.active()).toBe(false); |
| 543 | expect(menu.alwaysEntry().active()).toBe(false); |
| 544 | |
| 545 | expect(menu.shownItem(0).name()).toEqual("Constituency"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 546 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 547 | expect(menu.shownItem(0).active()).toBe(true); |
| 548 | expect(menu.shownItem(1).name()).toEqual("Morphology"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 549 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 550 | expect(menu.shownItem(1).active()).toBe(false); |
| 551 | expect(menu.shownItem(2)).toBe(undefined); |
| 552 | |
| 553 | // Next (1) |
| 554 | menu.next(); |
| 555 | expect(menu.shownItem(0).name()).toEqual("Constituency"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 556 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 557 | expect(menu.shownItem(0).active()).toBe(false); |
| 558 | expect(menu.shownItem(1).name()).toEqual("Morphology"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 559 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 560 | expect(menu.shownItem(1).active()).toBe(true); |
| 561 | expect(menu.shownItem(2)).toBe(undefined); |
| 562 | |
| 563 | // Next (2) |
| 564 | menu.next(); |
| 565 | expect(menu.shownItem(0).name()).toEqual("Morphology"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 566 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 567 | expect(menu.shownItem(0).active()).toBe(false); |
| 568 | expect(menu.shownItem(1).name()).toEqual("Part-of-Speech"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 569 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Part-<mark>o</mark>f-Speech</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 570 | expect(menu.shownItem(1).active()).toBe(true); |
| 571 | expect(menu.shownItem(2)).toBe(undefined); |
| 572 | |
| 573 | // Next (3) - to prefix |
| 574 | menu.next(); |
| 575 | expect(menu.shownItem(0).name()).toEqual("Morphology"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 576 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 577 | expect(menu.shownItem(0).active()).toBe(false); |
| 578 | expect(menu.shownItem(1).name()).toEqual("Part-of-Speech"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 579 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Part-<mark>o</mark>f-Speech</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 580 | expect(menu.shownItem(1).active()).toBe(false); |
| 581 | expect(menu.shownItem(2)).toBe(undefined); |
| 582 | expect(menu._prefix.active()).toBe(true); |
| 583 | expect(menu.alwaysEntry().active()).toBe(false); |
| 584 | |
| 585 | // Next (4) - to entry |
| 586 | menu.next(); |
| 587 | expect(menu.shownItem(0).name()).toEqual("Morphology"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 588 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 589 | expect(menu.shownItem(0).active()).toBe(false); |
| 590 | expect(menu.shownItem(1).name()).toEqual("Part-of-Speech"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 591 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Part-<mark>o</mark>f-Speech</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 592 | expect(menu.shownItem(1).active()).toBe(false); |
| 593 | expect(menu.shownItem(2)).toBe(undefined); |
| 594 | expect(menu._prefix.active()).toBe(false); |
| 595 | expect(menu.alwaysEntry().active()).toBe(true); |
| 596 | |
| 597 | menu.next(); |
| 598 | expect(menu.shownItem(0).name()).toEqual("Constituency"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 599 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 600 | expect(menu.shownItem(0).active()).toBe(true); |
| 601 | expect(menu.shownItem(1).name()).toEqual("Morphology"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 602 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 603 | expect(menu.shownItem(1).active()).toBe(false); |
| 604 | expect(menu.shownItem(2)).toBe(undefined); |
| 605 | |
| 606 | expect(menu.prefix("o").show()).toBe(true); |
| 607 | expect(menu.alwaysEntryValue("o").alwaysEntryValue()).toBe("o"); |
| 608 | expect(menu._prefix.active()).toBe(false); |
| 609 | expect(menu.alwaysEntry().active()).toBe(false); |
| 610 | }); |
| 611 | |
| 612 | |
| 613 | it('should be navigatable and filterable (prefix = "ex", "e")', function () { |
| 614 | var menu = HintMenu.create("cnx/", list); |
| 615 | menu._firstActive = true; |
| 616 | |
| 617 | menu.limit(2); |
| 618 | expect(menu.prefix("ex").show()).toBe(true); |
| 619 | expect(menu.alwaysEntryValue("ex").alwaysEntryValue()).toBe("ex"); |
| 620 | expect(menu._prefix.active()).toBe(false); |
| 621 | expect(menu.alwaysEntry().active()).toBe(false); |
| 622 | |
| 623 | expect(menu.shownItem(0).name()).toEqual("Constituency"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 624 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Constituency</strong><span><mark>Ex</mark>ample 1</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 625 | expect(menu.shownItem(0).active()).toBe(true); |
| 626 | expect(menu.shownItem(1).name()).toEqual("Morphology"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 627 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>Ex</mark>ample 2</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 628 | expect(menu.shownItem(1).active()).toBe(false); |
| 629 | expect(menu.shownItem(2)).toBe(undefined); |
| 630 | |
| 631 | // Next (1) |
| 632 | menu.next(); |
| 633 | expect(menu.shownItem(0).name()).toEqual("Constituency"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 634 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Constituency</strong><span><mark>Ex</mark>ample 1</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 635 | expect(menu.shownItem(0).active()).toBe(false); |
| 636 | expect(menu.shownItem(1).name()).toEqual("Morphology"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 637 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>Ex</mark>ample 2</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 638 | expect(menu.shownItem(1).active()).toBe(true); |
| 639 | expect(menu.shownItem(2)).toBe(undefined); |
| 640 | expect(menu.alwaysEntryValue()).toBe("ex"); |
| 641 | expect(menu._prefix.active()).toBe(false); |
| 642 | expect(menu.alwaysEntry().active()).toBe(false); |
| 643 | |
| 644 | // Next (2) |
| 645 | menu.next(); |
| 646 | |
| 647 | expect(menu.prefix()).toEqual('ex'); |
| 648 | expect(menu.shownItem(0).name()).toEqual("Constituency"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 649 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Constituency</strong><span><mark>Ex</mark>ample 1</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 650 | expect(menu.shownItem(0).active()).toBe(false); |
| 651 | |
| 652 | expect(menu.shownItem(1).name()).toEqual("Morphology"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 653 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>Ex</mark>ample 2</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 654 | expect(menu.shownItem(1).active()).toBe(false); |
| 655 | expect(menu.shownItem(2)).toBe(undefined); |
| 656 | expect(menu.alwaysEntryValue()).toBe("ex"); |
| 657 | expect(menu._prefix.active()).toBe(true); |
| 658 | expect(menu.alwaysEntry().active()).toBe(false); |
| 659 | |
| 660 | // Reset limit |
| 661 | menu.limit(5); |
| 662 | |
| 663 | // Change show |
| 664 | expect(menu.prefix("e").show()).toBe(true); |
| 665 | expect(menu.alwaysEntryValue("e").alwaysEntryValue()).toBe("e"); |
| 666 | expect(menu._prefix.active()).toBe(false); |
| 667 | expect(menu.alwaysEntry().active()).toBe(false); |
| 668 | expect(menu.shownItem(0).name()).toEqual("Constituency"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 669 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 670 | expect(menu.shownItem(0).active()).toBe(true); |
| 671 | expect(menu.shownItem(1).name()).toEqual("Morphology"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 672 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 673 | expect(menu.shownItem(1).active()).toBe(false); |
| 674 | expect(menu.shownItem(2)).toBe(undefined); |
| 675 | |
| 676 | // Next (1) |
| 677 | menu.next(); |
| 678 | expect(menu._prefix.active()).toBe(false); |
| 679 | expect(menu.prefix()).toEqual('e'); |
| 680 | expect(menu.shownItem(0).name()).toEqual("Constituency"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 681 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 682 | expect(menu.shownItem(0).active()).toBe(false); |
| 683 | expect(menu.shownItem(1).name()).toEqual("Morphology"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 684 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 685 | expect(menu.shownItem(1).active()).toBe(true); |
| 686 | expect(menu.shownItem(2)).toBe(undefined); |
| 687 | expect(menu._prefix.active()).toBe(false); |
| 688 | expect(menu.alwaysEntry().active()).toBe(false); |
| 689 | |
| 690 | // Next (2) |
| 691 | menu.next(); |
| 692 | expect(menu._prefix.active()).toBe(true); |
| 693 | expect(menu.shownItem(0).name()).toEqual("Constituency"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 694 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 695 | expect(menu.shownItem(0).active()).toBe(false); |
| 696 | expect(menu.shownItem(1).name()).toEqual("Morphology"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 697 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 698 | expect(menu.shownItem(1).active()).toBe(false); |
| 699 | expect(menu.shownItem(2)).toBe(undefined); |
| 700 | expect(menu._prefix.active()).toBe(true); |
| 701 | expect(menu.alwaysEntry().active()).toBe(false); |
| 702 | |
| 703 | // Next (2.5) |
| 704 | menu.next(); |
| 705 | expect(menu._prefix.active()).toBe(false); |
| 706 | expect(menu.shownItem(0).name()).toEqual("Constituency"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 707 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 708 | expect(menu.shownItem(0).active()).toBe(false); |
| 709 | expect(menu.shownItem(1).name()).toEqual("Morphology"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 710 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 711 | expect(menu.shownItem(1).active()).toBe(false); |
| 712 | expect(menu.shownItem(2)).toBe(undefined); |
| 713 | expect(menu._prefix.active()).toBe(false); |
| 714 | expect(menu.alwaysEntry().active()).toBe(true); |
| 715 | |
| 716 | // Next (3) |
| 717 | menu.next(); |
| 718 | expect(menu._prefix.active()).toBe(false); |
| 719 | expect(menu.shownItem(0).name()).toEqual("Constituency"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 720 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 721 | expect(menu.shownItem(0).active()).toBe(true); |
| 722 | expect(menu.shownItem(1).name()).toEqual("Morphology"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 723 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 724 | expect(menu.shownItem(1).active()).toBe(false); |
| 725 | expect(menu.shownItem(2)).toBe(undefined); |
| 726 | |
| 727 | expect(menu.alwaysEntryValue()).toBe("e"); |
| 728 | expect(menu._prefix.active()).toBe(false); |
| 729 | expect(menu.alwaysEntry().active()).toBe(false); |
| 730 | }); |
| 731 | |
| 732 | it('should be filterable (multiple prefix = "pro sin")', function () { |
| 733 | var menu = HintMenu.create("drukola/p=", listMultiPrefix); |
| 734 | menu._firstActive = true; |
| 735 | |
| 736 | menu.limit(2); |
| 737 | expect(menu.prefix("pro sin").show()).toBe(true); |
| 738 | expect(menu.alwaysEntryValue("pro sin").alwaysEntryValue()).toBe("pro sin"); |
| 739 | expect(menu._prefix.active()).toBe(false); |
| 740 | expect(menu.alwaysEntry().active()).toBe(false); |
| 741 | expect(menu.shownItem(0).name()).toEqual("PPS"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 742 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual( |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 743 | "<strong>PPS</strong><span>Personal <mark>Pro</mark>noun, <mark>Sin</mark>gular</span>" |
| 744 | ); |
| 745 | |
| 746 | expect(menu.shownItem(0).active()).toBe(true); |
| 747 | expect(menu.shownItem(1).name()).toEqual("PPSA"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 748 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>PPSA</strong><span>Personal <mark>Pro</mark>noun, <mark>Sin</mark>gular, Accusative</span>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 749 | expect(menu.shownItem(1).active()).toBe(false); |
| 750 | |
| 751 | expect(menu.shownItem(2)).toBe(undefined); |
| 752 | }); |
| 753 | |
| 754 | it('should be filterable (trimming = " p")', function () { |
| 755 | var menu = HintMenu.create("/p=", listMultiPrefix); |
| 756 | // menu._firstActive = true; |
| 757 | |
| 758 | menu.limit(2); |
| 759 | expect(menu.show()).toBe(true); |
| 760 | menu._prefix.add(" "); |
| 761 | menu._entry.add(" ") |
| 762 | expect(menu.show()).toBe(true); |
| 763 | menu._prefix.add("p") |
| 764 | menu._entry.add("p") |
| 765 | expect(menu.alwaysEntryValue()).toBe(" p"); |
| 766 | expect(menu.show()).toBe(true); |
| 767 | expect(menu.shownItem(0).name()).toEqual("PP"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 768 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual( |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 769 | "<strong><mark>P</mark><mark>P</mark></strong>"+ |
| 770 | "<span><mark>P</mark>ersonal <mark>P</mark>ronoun</span>" |
| 771 | ); |
| 772 | }); |
| 773 | |
| 774 | |
| 775 | |
| 776 | it('should ignore navigation with failing prefix', function () { |
| 777 | var menu = HintMenu.create("cnx/", list); |
| 778 | menu.limit(2); |
| 779 | expect(menu.show()).toBe(true); |
| 780 | |
| 781 | menu.next(); |
| 782 | |
| 783 | expect(menu.prefix("exit").show()).toBe(true); |
| 784 | expect(menu.element().querySelector('li')).toBe(null); |
| 785 | expect(menu.shownItem(0)).toBeUndefined(); |
| 786 | expect(menu._prefix.active()).toBe(true); |
| 787 | |
| 788 | menu.next(); |
| 789 | expect(menu._prefix.active()).toBe(false); |
| 790 | expect(menu._entry.active()).toBe(true); |
| 791 | |
| 792 | menu.next(); |
| 793 | expect(menu._prefix.active()).toBe(true); |
| 794 | expect(menu._entry.active()).toBe(false); |
| 795 | |
| 796 | menu.prev(); |
| 797 | expect(menu._prefix.active()).toBe(false); |
| 798 | expect(menu._entry.active()).toBe(true); |
| 799 | |
| 800 | menu.prev(); |
| 801 | expect(menu._prefix.active()).toBe(true); |
| 802 | expect(menu._entry.active()).toBe(false); |
| 803 | |
| 804 | }); |
| 805 | |
| 806 | it('should be navigatable with prefix', function () { |
| 807 | var menu = HintMenu.create("cnx/", demolist); |
| 808 | menu._firstActive = true; |
| 809 | |
| 810 | menu.limit(3); |
| 811 | |
| 812 | expect(menu.show()).toBe(true); |
| 813 | expect(menu.prefix()).toEqual(""); |
| 814 | expect(menu.alwaysEntryValue()).toEqual(""); |
| 815 | expect(menu._prefix.active()).toEqual(false); |
| 816 | expect(menu._entry.active()).toEqual(false); |
| 817 | |
| 818 | expect(menu.shownItem(0).name()).toEqual("Titel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 819 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Titel</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 820 | expect(menu.shownItem(0).active()).toBe(true); |
| 821 | expect(menu.shownItem(1).name()).toEqual("Untertitel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 822 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Untertitel</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 823 | expect(menu.shownItem(1).active()).toBe(false); |
| 824 | expect(menu.shownItem(2).name()).toEqual("Veröffentlichungsdatum"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 825 | expect(menu.directElementChildrenByTagName("li")[2].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 826 | expect(menu.shownItem(2).active()).toBe(false); |
| 827 | expect(menu.shownItem(3)).toBe(undefined); |
| 828 | expect(menu._prefix.active()).toEqual(false); |
| 829 | expect(menu._entry.active()).toEqual(false); |
| 830 | |
| 831 | menu._prefix.add('a'); |
| 832 | menu._entry.add('a'); |
| 833 | expect(menu._prefix.active()).toEqual(false); |
| 834 | expect(menu._entry.active()).toEqual(false); |
| 835 | expect(menu.show()).toBe(true); |
| 836 | expect(menu.prefix()).toEqual("a"); |
| 837 | expect(menu.alwaysEntryValue()).toEqual("a"); |
| 838 | expect(menu.shownItem(0).name()).toEqual("Autor"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 839 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong><mark>A</mark>utor</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 840 | |
| 841 | menu._prefix.add('u'); |
| 842 | menu._entry.add('u'); |
| 843 | expect(menu.show()).toBe(true); |
| 844 | expect(menu.prefix()).toEqual("au"); |
| 845 | expect(menu.alwaysEntryValue()).toEqual("au"); |
| 846 | expect(menu.shownItem(0).name()).toEqual("Autor"); |
| 847 | expect(menu._prefix.active()).toEqual(false); |
| 848 | expect(menu._entry.active()).toEqual(false); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 849 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong><mark>Au</mark>tor</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 850 | |
| 851 | menu._prefix.chop(); |
| 852 | menu._entry.chop(); |
| 853 | expect(menu.show()).toBe(true); |
| 854 | expect(menu.prefix()).toEqual("a"); |
| 855 | expect(menu.alwaysEntryValue()).toEqual("a"); |
| 856 | expect(menu.shownItem(0).name()).toEqual("Autor"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 857 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong><mark>A</mark>utor</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 858 | |
| 859 | menu._prefix.chop(); |
| 860 | menu._entry.chop(); |
| 861 | expect(menu.show()).toBe(true); |
| 862 | expect(menu.prefix()).toEqual(""); |
| 863 | expect(menu.alwaysEntryValue()).toEqual(""); |
| 864 | expect(menu._prefix.active()).toEqual(false); |
| 865 | expect(menu._entry.active()).toEqual(false); |
| 866 | expect(menu.shownItem(0).name()).toEqual("Titel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 867 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Titel</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 868 | expect(menu.shownItem(0).active()).toBe(true); |
| 869 | expect(menu.shownItem(1).name()).toEqual("Untertitel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 870 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Untertitel</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 871 | expect(menu.shownItem(1).active()).toBe(false); |
| 872 | expect(menu.shownItem(2).name()).toEqual("Veröffentlichungsdatum"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 873 | expect(menu.directElementChildrenByTagName("li")[2].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 874 | expect(menu.shownItem(2).active()).toBe(false); |
| 875 | expect(menu.shownItem(3)).toBe(undefined); |
| 876 | |
| 877 | // Forward |
| 878 | menu._prefix.chop(); |
| 879 | menu._entry.chop(); |
| 880 | expect(menu.show()).toBe(true); |
| 881 | expect(menu.prefix()).toEqual(""); |
| 882 | expect(menu._prefix.active()).toEqual(false); |
| 883 | expect(menu._entry.active()).toEqual(false); |
| 884 | expect(menu.alwaysEntryValue()).toEqual(""); |
| 885 | expect(menu.shownItem(0).name()).toEqual("Titel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 886 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Titel</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 887 | expect(menu.shownItem(0).active()).toBe(true); |
| 888 | expect(menu.shownItem(1).name()).toEqual("Untertitel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 889 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Untertitel</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 890 | expect(menu.shownItem(1).active()).toBe(false); |
| 891 | expect(menu.shownItem(2).name()).toEqual("Veröffentlichungsdatum"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 892 | expect(menu.directElementChildrenByTagName("li")[2].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 893 | expect(menu.shownItem(2).active()).toBe(false); |
| 894 | |
| 895 | // Forward |
| 896 | menu.next(); |
| 897 | expect(menu.prefix()).toEqual(""); |
| 898 | expect(menu.alwaysEntryValue()).toEqual(""); |
| 899 | expect(menu._prefix.active()).toEqual(false); |
| 900 | expect(menu._entry.active()).toEqual(false); |
| 901 | expect(menu.shownItem(0).name()).toEqual("Titel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 902 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Titel</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 903 | expect(menu.shownItem(0).active()).toBe(false); |
| 904 | expect(menu.shownItem(1).name()).toEqual("Untertitel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 905 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Untertitel</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 906 | expect(menu.shownItem(1).active()).toBe(true); |
| 907 | expect(menu.shownItem(2).name()).toEqual("Veröffentlichungsdatum"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 908 | expect(menu.directElementChildrenByTagName("li")[2].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 909 | expect(menu.shownItem(2).active()).toBe(false); |
| 910 | expect(menu.shownItem(3)).toBe(undefined); |
| 911 | |
| 912 | // Forward |
| 913 | menu.next(); |
| 914 | expect(menu.prefix()).toEqual(""); |
| 915 | expect(menu.alwaysEntryValue()).toEqual(""); |
| 916 | expect(menu._prefix.active()).toEqual(false); |
| 917 | expect(menu._entry.active()).toEqual(false); |
| 918 | expect(menu.shownItem(0).name()).toEqual("Titel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 919 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Titel</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 920 | expect(menu.shownItem(0).active()).toBe(false); |
| 921 | expect(menu.shownItem(1).name()).toEqual("Untertitel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 922 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Untertitel</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 923 | expect(menu.shownItem(1).active()).toBe(false); |
| 924 | expect(menu.shownItem(2).name()).toEqual("Veröffentlichungsdatum"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 925 | expect(menu.directElementChildrenByTagName("li")[2].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 926 | expect(menu.shownItem(2).active()).toBe(true); |
| 927 | expect(menu.shownItem(3)).toBe(undefined); |
| 928 | |
| 929 | // Forward |
| 930 | menu.next(); |
| 931 | expect(menu.prefix()).toEqual(""); |
| 932 | expect(menu.alwaysEntryValue()).toEqual(""); |
| 933 | expect(menu.shownItem(0).name()).toEqual("Untertitel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 934 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Untertitel</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 935 | expect(menu.shownItem(0).active()).toBe(false); |
| 936 | expect(menu.shownItem(1).name()).toEqual("Veröffentlichungsdatum"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 937 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 938 | expect(menu.shownItem(1).active()).toBe(false); |
| 939 | expect(menu.shownItem(2).name()).toEqual("Länge"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 940 | expect(menu.directElementChildrenByTagName("li")[2].innerHTML).toEqual("<strong>Länge</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 941 | expect(menu.shownItem(2).active()).toBe(true); |
| 942 | expect(menu.shownItem(3)).toBe(undefined); |
| 943 | expect(menu._prefix.active()).toEqual(false); |
| 944 | expect(menu._entry.active()).toEqual(false); |
| 945 | |
| 946 | // Forward |
| 947 | menu.next(); |
| 948 | expect(menu.prefix()).toEqual(""); |
| 949 | expect(menu.alwaysEntryValue()).toEqual(""); |
| 950 | expect(menu.shownItem(0).name()).toEqual("Veröffentlichungsdatum"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 951 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 952 | expect(menu.shownItem(0).active()).toBe(false); |
| 953 | expect(menu.shownItem(1).name()).toEqual("Länge"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 954 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Länge</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 955 | expect(menu.shownItem(1).active()).toBe(false); |
| 956 | expect(menu.shownItem(2).name()).toEqual("Autor"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 957 | expect(menu.directElementChildrenByTagName("li")[2].innerHTML).toEqual("<strong>Autor</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 958 | expect(menu.shownItem(2).active()).toBe(true); |
| 959 | expect(menu.shownItem(3)).toBe(undefined); |
| 960 | expect(menu._prefix.active()).toEqual(false); |
| 961 | expect(menu._entry.active()).toEqual(false); |
| 962 | |
| 963 | // Forward |
| 964 | menu.next(); |
| 965 | expect(menu.prefix()).toEqual(""); |
| 966 | expect(menu.alwaysEntryValue()).toEqual(""); |
| 967 | expect(menu.shownItem(0).name()).toEqual("Veröffentlichungsdatum"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 968 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 969 | expect(menu.shownItem(0).active()).toBe(false); |
| 970 | expect(menu.shownItem(1).name()).toEqual("Länge"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 971 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Länge</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 972 | expect(menu.shownItem(1).active()).toBe(false); |
| 973 | expect(menu.shownItem(2).name()).toEqual("Autor"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 974 | expect(menu.directElementChildrenByTagName("li")[2].innerHTML).toEqual("<strong>Autor</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 975 | expect(menu.shownItem(2).active()).toBe(false); |
| 976 | expect(menu.shownItem(3)).toBe(undefined); |
| 977 | expect(menu._prefix.active()).toEqual(false); |
| 978 | expect(menu._entry.active()).toEqual(true); |
| 979 | |
| 980 | // Forward |
| 981 | menu.next(); |
| 982 | expect(menu.prefix()).toEqual(""); |
| 983 | expect(menu.alwaysEntryValue()).toEqual(""); |
| 984 | expect(menu.shownItem(0).name()).toEqual("Titel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 985 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Titel</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 986 | expect(menu.shownItem(0).active()).toBe(true); |
| 987 | expect(menu.shownItem(1).name()).toEqual("Untertitel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 988 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Untertitel</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 989 | expect(menu.shownItem(1).active()).toBe(false); |
| 990 | expect(menu.shownItem(2).name()).toEqual("Veröffentlichungsdatum"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 991 | expect(menu.directElementChildrenByTagName("li")[2].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 992 | expect(menu.shownItem(2).active()).toBe(false); |
| 993 | }); |
| 994 | |
| 995 | |
| 996 | it('should be navigatable with a prefix (1)', function () { |
| 997 | var menu = HintMenu.create("cnx/", demolist); |
| 998 | menu._firstActive = true; |
| 999 | |
| 1000 | menu.limit(3); |
| 1001 | |
| 1002 | expect(menu.show()).toBe(true); |
| 1003 | expect(menu.prefix()).toEqual(""); |
| 1004 | expect(menu.alwaysEntryValue()).toEqual(""); |
| 1005 | |
| 1006 | // Add prefix in uppercase - but check in lowercase |
| 1007 | menu.prefix('El'); |
| 1008 | menu.alwaysEntryValue('El'); |
| 1009 | expect(menu.show()).toBe(true); |
| 1010 | |
| 1011 | expect(menu.prefix()).toEqual("El"); |
| 1012 | expect(menu._prefix.active()).toEqual(false); |
| 1013 | expect(menu.alwaysEntryValue()).toEqual("El"); |
| 1014 | expect(menu._entry.active()).toEqual(false); |
| 1015 | expect(menu.shownItem(0).name()).toEqual("Titel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 1016 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1017 | expect(menu.shownItem(0).active()).toBe(true); |
| 1018 | expect(menu.shownItem(1).name()).toEqual("Untertitel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 1019 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1020 | expect(menu.shownItem(1).active()).toBe(false); |
| 1021 | expect(menu.shownItem(2)).toBe(undefined); |
| 1022 | |
| 1023 | // Forward |
| 1024 | menu.next(); |
| 1025 | expect(menu.prefix()).toEqual("El"); |
| 1026 | expect(menu._prefix.active()).toEqual(false); |
| 1027 | expect(menu.alwaysEntryValue()).toEqual("El"); |
| 1028 | expect(menu._entry.active()).toEqual(false); |
| 1029 | expect(menu.shownItem(0).name()).toEqual("Titel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 1030 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1031 | expect(menu.shownItem(0).active()).toBe(false); |
| 1032 | expect(menu.shownItem(1).name()).toEqual("Untertitel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 1033 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1034 | expect(menu.shownItem(1).active()).toBe(true); |
| 1035 | expect(menu.shownItem(2)).toBe(undefined); |
| 1036 | |
| 1037 | // Forward |
| 1038 | menu.next(); |
| 1039 | expect(menu.prefix()).toEqual("El"); |
| 1040 | expect(menu._prefix.active()).toEqual(true); |
| 1041 | expect(menu.alwaysEntryValue()).toEqual("El"); |
| 1042 | expect(menu._entry.active()).toEqual(false); |
| 1043 | expect(menu.shownItem(0).name()).toEqual("Titel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 1044 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1045 | expect(menu.shownItem(0).active()).toBe(false); |
| 1046 | expect(menu.shownItem(1).name()).toEqual("Untertitel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 1047 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1048 | expect(menu.shownItem(1).active()).toBe(false); |
| 1049 | expect(menu.shownItem(2)).toBe(undefined); |
| 1050 | |
| 1051 | // Forward |
| 1052 | menu.next(); |
| 1053 | expect(menu.prefix()).toEqual("El"); |
| 1054 | expect(menu._prefix.active()).toEqual(false); |
| 1055 | expect(menu.alwaysEntryValue()).toEqual("El"); |
| 1056 | expect(menu._entry.active()).toEqual(true); |
| 1057 | expect(menu.shownItem(0).name()).toEqual("Titel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 1058 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1059 | expect(menu.shownItem(0).active()).toBe(false); |
| 1060 | expect(menu.shownItem(1).name()).toEqual("Untertitel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 1061 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1062 | expect(menu.shownItem(1).active()).toBe(false); |
| 1063 | expect(menu.shownItem(2)).toBe(undefined); |
| 1064 | |
| 1065 | menu.prev() |
| 1066 | expect(menu.prefix()).toEqual("El"); |
| 1067 | expect(menu._prefix.active()).toEqual(true); |
| 1068 | expect(menu.alwaysEntryValue()).toEqual("El"); |
| 1069 | expect(menu._entry.active()).toEqual(false); |
| 1070 | expect(menu.shownItem(0).name()).toEqual("Titel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 1071 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1072 | expect(menu.shownItem(0).active()).toBe(false); |
| 1073 | expect(menu.shownItem(1).name()).toEqual("Untertitel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 1074 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1075 | expect(menu.shownItem(1).active()).toBe(false); |
| 1076 | expect(menu.shownItem(2)).toBe(undefined); |
| 1077 | |
| 1078 | // Backward |
| 1079 | menu.prev(); |
| 1080 | expect(menu.prefix()).toEqual("El"); |
| 1081 | expect(menu._prefix.active()).toEqual(false); |
| 1082 | expect(menu.alwaysEntryValue()).toEqual("El"); |
| 1083 | expect(menu._entry.active()).toEqual(false); |
| 1084 | expect(menu.shownItem(0).name()).toEqual("Titel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 1085 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1086 | expect(menu.shownItem(0).active()).toBe(false); |
| 1087 | |
| 1088 | expect(menu.shownItem(1).name()).toEqual("Untertitel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 1089 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1090 | expect(menu.shownItem(1).active()).toBe(true); |
| 1091 | expect(menu.shownItem(2)).toBe(undefined); |
| 1092 | }); |
| 1093 | |
| 1094 | |
| 1095 | it('should be navigatable with a prefix (2)', function () { |
| 1096 | var menu = HintMenu.create("cnx/", demolist); |
| 1097 | menu._firstActive = true; |
| 1098 | |
| 1099 | menu.limit(3); |
| 1100 | expect(menu.show()).toBe(true); |
| 1101 | expect(menu.prefix()).toEqual(""); |
| 1102 | menu.prefix('el'); |
| 1103 | expect(menu.alwaysEntryValue()).toEqual(""); |
| 1104 | menu.alwaysEntryValue('el'); |
| 1105 | expect(menu.show()).toBe(true); |
| 1106 | |
| 1107 | expect(menu.prefix()).toEqual("el"); |
| 1108 | expect(menu._prefix.active()).toEqual(false); |
| 1109 | expect(menu.alwaysEntryValue()).toEqual("el"); |
| 1110 | expect(menu._entry.active()).toEqual(false); |
| 1111 | expect(menu.shownItem(0).name()).toEqual("Titel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 1112 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1113 | expect(menu.shownItem(0).active()).toBe(true); |
| 1114 | expect(menu.shownItem(1).name()).toEqual("Untertitel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 1115 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1116 | expect(menu.shownItem(1).active()).toBe(false); |
| 1117 | expect(menu.shownItem(2)).toBe(undefined); |
| 1118 | |
| 1119 | // Backward |
| 1120 | menu.prev(); |
| 1121 | expect(menu._prefix.active()).toEqual(false); |
| 1122 | expect(menu._entry.active()).toEqual(true); |
| 1123 | |
| 1124 | expect(menu.shownItem(0).name()).toEqual("Titel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 1125 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1126 | expect(menu.shownItem(0).active()).toBe(false); |
| 1127 | |
| 1128 | expect(menu.shownItem(1).name()).toEqual("Untertitel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 1129 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1130 | expect(menu.shownItem(1).active()).toBe(false); |
| 1131 | expect(menu.shownItem(2)).toBe(undefined); |
| 1132 | |
| 1133 | |
| 1134 | // Backward |
| 1135 | menu.prev(); |
| 1136 | expect(menu._prefix.active()).toEqual(true); |
| 1137 | expect(menu._entry.active()).toEqual(false); |
| 1138 | |
| 1139 | expect(menu.shownItem(0).name()).toEqual("Titel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 1140 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1141 | expect(menu.shownItem(0).active()).toBe(false); |
| 1142 | |
| 1143 | expect(menu.shownItem(1).name()).toEqual("Untertitel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 1144 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1145 | expect(menu.shownItem(1).active()).toBe(false); |
| 1146 | expect(menu.shownItem(2)).toBe(undefined); |
| 1147 | |
| 1148 | // Backward |
| 1149 | menu.prev(); |
| 1150 | expect(menu._prefix.active()).toEqual(false); |
| 1151 | expect(menu._entry.active()).toEqual(false); |
| 1152 | expect(menu.shownItem(0).name()).toEqual("Titel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 1153 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1154 | expect(menu.shownItem(0).active()).toBe(false); |
| 1155 | expect(menu.shownItem(1).name()).toEqual("Untertitel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 1156 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1157 | expect(menu.shownItem(1).active()).toBe(true); |
| 1158 | expect(menu.shownItem(2)).toBe(undefined); |
| 1159 | }); |
| 1160 | |
| 1161 | it('should be navigatable with a prefix (3)', function () { |
| 1162 | var menu = HintMenu.create("cnx/", demolist); |
| 1163 | menu._firstActive = true; |
| 1164 | menu.limit(3); |
| 1165 | expect(menu.show()).toBe(true); |
| 1166 | expect(menu.prefix()).toEqual(""); |
| 1167 | menu.prefix('el'); |
| 1168 | expect(menu.alwaysEntryValue()).toEqual(""); |
| 1169 | expect(menu.alwaysEntry().value()).toEqual(""); |
| 1170 | menu.alwaysEntryValue('el'); |
| 1171 | expect(menu.show()).toBe(true); |
| 1172 | |
| 1173 | expect(menu.prefix()).toEqual("el"); |
| 1174 | expect(menu._prefix.active()).toEqual(false); |
| 1175 | expect(menu.alwaysEntry().value()).toEqual("el"); |
| 1176 | expect(menu._entry.active()).toEqual(false); |
| 1177 | expect(menu.shownItem(0).name()).toEqual("Titel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 1178 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1179 | expect(menu.shownItem(0).active()).toBe(true); |
| 1180 | expect(menu.shownItem(1).name()).toEqual("Untertitel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 1181 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1182 | expect(menu.shownItem(1).active()).toBe(false); |
| 1183 | expect(menu.shownItem(2)).toBe(undefined); |
| 1184 | |
| 1185 | // Backward |
| 1186 | menu.prev(); |
| 1187 | expect(menu._prefix.active()).toEqual(false); |
| 1188 | expect(menu._entry.active()).toEqual(true); |
| 1189 | expect(menu.shownItem(0).name()).toEqual("Titel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 1190 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1191 | expect(menu.shownItem(0).active()).toBe(false); |
| 1192 | expect(menu.shownItem(1).name()).toEqual("Untertitel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 1193 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1194 | expect(menu.shownItem(1).active()).toBe(false); |
| 1195 | expect(menu.shownItem(2)).toBe(undefined); |
| 1196 | |
| 1197 | // Backward |
| 1198 | menu.prev(); |
| 1199 | expect(menu._prefix.active()).toEqual(true); |
| 1200 | expect(menu._entry.active()).toEqual(false); |
| 1201 | expect(menu.shownItem(0).name()).toEqual("Titel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 1202 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1203 | expect(menu.shownItem(0).active()).toBe(false); |
| 1204 | expect(menu.shownItem(1).name()).toEqual("Untertitel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 1205 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1206 | expect(menu.shownItem(1).active()).toBe(false); |
| 1207 | expect(menu.shownItem(2)).toBe(undefined); |
| 1208 | |
| 1209 | |
| 1210 | // Forward |
| 1211 | menu.next(); |
| 1212 | expect(menu.prefix()).toEqual("el"); |
| 1213 | expect(menu._prefix.active()).toEqual(false); |
| 1214 | expect(menu._entry.active()).toEqual(true); |
| 1215 | expect(menu.shownItem(0).name()).toEqual("Titel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 1216 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1217 | expect(menu.shownItem(0).active()).toBe(false); |
| 1218 | expect(menu.shownItem(1).name()).toEqual("Untertitel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 1219 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1220 | expect(menu.shownItem(1).active()).toBe(false); |
| 1221 | expect(menu.shownItem(2)).toBe(undefined); |
| 1222 | |
| 1223 | // Forward |
| 1224 | menu.next(); |
| 1225 | expect(menu.prefix()).toEqual("el"); |
| 1226 | expect(menu._prefix.active()).toEqual(false); |
| 1227 | expect(menu._entry.active()).toEqual(false); |
| 1228 | expect(menu.shownItem(0).name()).toEqual("Titel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 1229 | expect(menu.directElementChildrenByTagName("li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1230 | expect(menu.shownItem(0).active()).toBe(true); |
| 1231 | expect(menu.shownItem(1).name()).toEqual("Untertitel"); |
Leo Repp | 7b0fbf9 | 2021-07-14 11:25:59 +0200 | [diff] [blame^] | 1232 | expect(menu.directElementChildrenByTagName("li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>"); |
Leo Repp | 56904d2 | 2021-04-26 15:53:22 +0200 | [diff] [blame] | 1233 | expect(menu.shownItem(1).active()).toBe(false); |
| 1234 | expect(menu.shownItem(2)).toBe(undefined); |
| 1235 | }); |
| 1236 | |
| 1237 | |
| 1238 | |
| 1239 | xit('should scroll to a chosen value after prefixing, if the chosen value is live'); |
| 1240 | }); |
| 1241 | |
| 1242 | describe('KorAP.AlwaysMenu.Entry', function () { |
| 1243 | it('should be initializable', function () { |
| 1244 | var p = alwaysEntryClass.create(); |
| 1245 | expect(p.element().classList.contains('pref')).toBeTruthy(); |
| 1246 | expect(p.isSet()).not.toBeTruthy(); |
| 1247 | expect(p.element().innerHTML).toEqual("Speichern"); |
| 1248 | expect(p.value()).toEqual(""); |
| 1249 | |
| 1250 | /* |
| 1251 | expect(mi.lcField()).toEqual(' baum'); |
| 1252 | */ |
| 1253 | |
| 1254 | }); |
| 1255 | |
| 1256 | it('should be initializable with a different name', function () { |
| 1257 | var p = alwaysEntryClass.create("Save"); |
| 1258 | expect(p.element().classList.contains('pref')).toBeTruthy(); |
| 1259 | expect(p.isSet()).not.toBeTruthy(); |
| 1260 | expect(p.element().innerHTML).toEqual("Save"); |
| 1261 | expect(p.value()).toEqual(""); |
| 1262 | |
| 1263 | /* |
| 1264 | expect(mi.lcField()).toEqual(' baum'); |
| 1265 | */ |
| 1266 | |
| 1267 | }); |
| 1268 | |
| 1269 | it('should be modifiable', function () { |
| 1270 | var p = alwaysEntryClass.create(); |
| 1271 | expect(p.value()).toEqual(''); |
| 1272 | expect(p.element().firstChild).toEqual(document.createTextNode("Speichern")); |
| 1273 | |
| 1274 | // Set string |
| 1275 | expect(p.value('Test')).toEqual('Test'); |
| 1276 | expect(p.value()).toEqual('Test'); |
| 1277 | expect(p.element().firstChild.nodeValue).toEqual('Speichern'); |
| 1278 | |
| 1279 | // Add string |
| 1280 | expect(p.add('ified')).toEqual('Testified'); |
| 1281 | expect(p.value()).toEqual('Testified'); |
| 1282 | expect(p.element().firstChild.nodeValue).toEqual('Speichern'); |
| 1283 | |
| 1284 | // Clear string |
| 1285 | p.clear(); |
| 1286 | expect(p.value()).toEqual(''); |
| 1287 | expect(p.element().firstChild).toEqual(document.createTextNode("Speichern")); |
| 1288 | |
| 1289 | // Set string |
| 1290 | expect(p.value('Test')).toEqual('Test'); |
| 1291 | expect(p.value()).toEqual('Test'); |
| 1292 | expect(p.element().firstChild.nodeValue).toEqual('Speichern'); |
| 1293 | |
| 1294 | expect(p.chop()).toEqual('Tes'); |
| 1295 | expect(p.value()).toEqual('Tes'); |
| 1296 | expect(p.element().firstChild.nodeValue).toEqual('Speichern'); |
| 1297 | |
| 1298 | expect(p.chop()).toEqual('Te'); |
| 1299 | expect(p.value()).toEqual('Te'); |
| 1300 | expect(p.element().firstChild.nodeValue).toEqual('Speichern'); |
| 1301 | |
| 1302 | expect(p.chop()).toEqual('T'); |
| 1303 | expect(p.value()).toEqual('T'); |
| 1304 | expect(p.element().firstChild.nodeValue).toEqual('Speichern'); |
| 1305 | |
| 1306 | expect(p.chop()).toEqual(''); |
| 1307 | expect(p.value()).toEqual(''); |
| 1308 | expect(p.element().firstChild).toEqual(document.createTextNode("Speichern")); |
| 1309 | }); |
| 1310 | |
| 1311 | it('should be activatable', function () { |
| 1312 | var p = alwaysEntryClass.create(); |
| 1313 | expect(p.value()).toEqual(''); |
| 1314 | expect(p.element().firstChild).toEqual(document.createTextNode("Speichern")); |
| 1315 | |
| 1316 | expect(p.value('Test')).toEqual('Test'); |
| 1317 | expect(p.element().firstChild.nodeValue).toEqual('Speichern'); |
| 1318 | |
| 1319 | expect(p.active()).not.toBeTruthy(); |
| 1320 | expect(p.element().classList.contains('active')).not.toBeTruthy(); |
| 1321 | |
| 1322 | p.active(true); |
| 1323 | expect(p.active()).toBeTruthy(); |
| 1324 | expect(p.element().classList.contains('active')).toBeTruthy(); |
| 1325 | }); |
| 1326 | }); |
| 1327 | |
| 1328 | describe('KorAP.AlwaysMenu.Slider', function () { |
| 1329 | |
| 1330 | var demolonglist = [ |
| 1331 | ['Titel', 'title'], |
| 1332 | ['Untertitel', 'subTitle'], |
| 1333 | ['Veröffentlichungsdatum', 'pubDate'], |
| 1334 | ['Länge', 'length'], |
| 1335 | ['Autor', 'author'], |
| 1336 | ['Genre', 'genre'], |
| 1337 | ['corpusID', 'corpusID'], |
| 1338 | ['docID', 'docID'], |
| 1339 | ['textID', 'textID'], |
| 1340 | ]; |
| 1341 | |
| 1342 | it('should correctly be initializable', function () { |
| 1343 | var list = [ |
| 1344 | ["Constituency"], |
| 1345 | ["Lemma"], |
| 1346 | ["Morphology"], |
| 1347 | ["Part-of-Speech"], |
| 1348 | ["Syntax"] |
| 1349 | ]; |
| 1350 | |
| 1351 | var menu = OwnAlwaysMenu.create(list); |
| 1352 | |
| 1353 | menu._firstActive = true; |
| 1354 | menu.limit(3); |
| 1355 | |
| 1356 | expect(menu.show()).toBe(true); |
| 1357 | |
| 1358 | expect(menu.shownItem(0).active()).toBe(true); |
| 1359 | expect(menu.shownItem(1).active()).toBe(false); |
| 1360 | expect(menu.shownItem(2).active()).toBe(false); |
| 1361 | expect(menu.slider().offset()).toEqual(0); |
| 1362 | expect(menu.position).toEqual(0); |
| 1363 | }); |
| 1364 | |
| 1365 | it('should correctly move on arrow keys', function () { |
| 1366 | var list = [ |
| 1367 | ["Constituency"], |
| 1368 | ["Lemma"], |
| 1369 | ["Morphology"], |
| 1370 | ["Part-of-Speech"], |
| 1371 | ["Syntax"] |
| 1372 | ]; |
| 1373 | |
| 1374 | var menu = OwnAlwaysMenu.create(list); |
| 1375 | |
| 1376 | menu._firstActive = true; |
| 1377 | menu.limit(3); |
| 1378 | |
| 1379 | expect(menu.show()).toBe(true); |
| 1380 | |
| 1381 | menu.next(); |
| 1382 | expect(menu.shownItem(0).active()).toBe(false); |
| 1383 | expect(menu.shownItem(1).active()).toBe(true); |
| 1384 | expect(menu.shownItem(2).active()).toBe(false); |
| 1385 | expect(menu._prefix.active()).toBe(false); |
| 1386 | expect(menu._entry.active()).toBe(false); |
| 1387 | expect(menu.slider().offset()).toEqual(0); |
| 1388 | expect(menu.position).toEqual(1); |
| 1389 | |
| 1390 | menu.next(); |
| 1391 | expect(menu.shownItem(0).active()).toBe(false); |
| 1392 | expect(menu.shownItem(1).active()).toBe(false); |
| 1393 | expect(menu.shownItem(2).active()).toBe(true); |
| 1394 | expect(menu._prefix.active()).toBe(false); |
| 1395 | expect(menu._entry.active()).toBe(false); |
| 1396 | expect(menu.slider().offset()).toEqual(0); |
| 1397 | expect(menu.position).toEqual(2); |
| 1398 | |
| 1399 | menu.next(); |
| 1400 | expect(menu.shownItem(0).active()).toBe(false); |
| 1401 | expect(menu.shownItem(1).active()).toBe(false); |
| 1402 | expect(menu.shownItem(2).active()).toBe(true); |
| 1403 | expect(menu._prefix.active()).toBe(false); |
| 1404 | expect(menu._entry.active()).toBe(false); |
| 1405 | expect(menu.slider().offset()).toEqual(1); |
| 1406 | expect(menu.position).toEqual(3); |
| 1407 | |
| 1408 | menu.next(); |
| 1409 | expect(menu.shownItem(0).active()).toBe(false); |
| 1410 | expect(menu.shownItem(1).active()).toBe(false); |
| 1411 | expect(menu.shownItem(2).active()).toBe(true); |
| 1412 | expect(menu._prefix.active()).toBe(false); |
| 1413 | expect(menu._entry.active()).toBe(false); |
| 1414 | expect(menu.slider().offset()).toEqual(2); |
| 1415 | expect(menu.position).toEqual(4); |
| 1416 | |
| 1417 | menu.next(); |
| 1418 | expect(menu.shownItem(0).active()).toBe(false); |
| 1419 | expect(menu.shownItem(1).active()).toBe(false); |
| 1420 | expect(menu.shownItem(2).active()).toBe(false); |
| 1421 | expect(menu._prefix.active()).toBe(false); |
| 1422 | expect(menu._entry.active()).toBe(true); |
| 1423 | expect(menu.slider().offset()).toEqual(2); |
| 1424 | expect(menu.position).toEqual(7); |
| 1425 | |
| 1426 | menu.next(); |
| 1427 | expect(menu.shownItem(0).active()).toBe(true); |
| 1428 | expect(menu.shownItem(1).active()).toBe(false); |
| 1429 | expect(menu.shownItem(2).active()).toBe(false); |
| 1430 | expect(menu._prefix.active()).toBe(false); |
| 1431 | expect(menu._entry.active()).toBe(false); |
| 1432 | expect(menu.slider().offset()).toEqual(0); |
| 1433 | expect(menu.position).toEqual(0); |
| 1434 | |
| 1435 | expect(menu.slider()._slider.style.height).toEqual('60%'); |
| 1436 | }); |
| 1437 | |
| 1438 | }); |
| 1439 | |
| 1440 | describe('KorAP.AlwaysMenu.Benchmark', function () { |
| 1441 | var menu = alwaysMenuClass.create([ |
| 1442 | ['Titel', 'title'], |
| 1443 | ['Untertitel', 'subTitle'], |
| 1444 | ['Veröffentlichungsdatum', 'pubDate'], |
| 1445 | ['Länge', 'length'], |
| 1446 | ['Autor', 'author'] |
| 1447 | ]); |
| 1448 | |
| 1449 | menu.limit(3).show(); |
| 1450 | |
| 1451 | // Some actions |
| 1452 | menu.next(); |
| 1453 | menu.next(); |
| 1454 | menu.prev(); |
| 1455 | menu.prev(); |
| 1456 | menu.prev(); |
| 1457 | |
| 1458 | menu.pageDown(); |
| 1459 | menu.pageUp(); |
| 1460 | |
| 1461 | // There is no fourth item in the list! |
| 1462 | menu.prefix('e').show(4); |
| 1463 | menu.next(); |
| 1464 | menu.next(); |
| 1465 | menu.prev(); |
| 1466 | menu.prev(); |
| 1467 | menu.prev(); |
| 1468 | }); |
| 1469 | }); |