Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 1 | function emitKeyboardEvent (element, type, keyCode) { |
| 2 | // event type : keydown, keyup, keypress |
| 3 | // http://stackoverflow.com/questions/596481/simulate-javascript-key-events |
| 4 | // http://stackoverflow.com/questions/961532/firing-a-keyboard-event-in-javascript |
| 5 | var keyboardEvent = document.createEvent("KeyboardEvent"); |
| 6 | var initMethod = typeof keyboardEvent.initKeyboardEvent !== 'undefined' ? |
| 7 | "initKeyboardEvent" : "initKeyEvent"; |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 8 | keyboardEvent[initMethod]( |
| 9 | type, |
Akron | 308db38 | 2016-05-30 22:34:07 +0200 | [diff] [blame] | 10 | true, // bubbles |
| 11 | true, // cancelable |
| 12 | window, // viewArg: should be window |
| 13 | false, // ctrlKeyArg |
| 14 | false, // altKeyArg |
| 15 | false, // shiftKeyArg |
| 16 | false, // metaKeyArg |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 17 | keyCode, // keyCodeArg : unsigned long the virtual key code, else 0 |
Akron | 308db38 | 2016-05-30 22:34:07 +0200 | [diff] [blame] | 18 | 0 // charCodeArgs : unsigned long the Unicode character |
| 19 | // associated with the depressed key, else 0 |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 20 | ); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 21 | element.dispatchEvent(keyboardEvent); |
| 22 | }; |
| 23 | |
| 24 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 25 | define(['hint'], function () { |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 26 | var hintClass = require("hint"); |
| 27 | var inputClass = require("hint/input"); |
| 28 | var contextClass = require("hint/contextanalyzer"); |
| 29 | var menuClass = require("hint/menu"); |
| 30 | var menuItemClass = require("hint/item"); |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 31 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 32 | describe('KorAP.InputField', function () { |
| 33 | var input; |
Nils Diewald | 1c54692 | 2015-04-13 01:56:19 +0000 | [diff] [blame] | 34 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 35 | beforeEach(function () { |
| 36 | input = document.createElement("input"); |
| 37 | input.setAttribute('type', "text"); |
| 38 | input.setAttribute("value", "abcdefghijklmno"); |
| 39 | input.style.position = 'absolute'; |
| 40 | document.getElementsByTagName('body')[0].appendChild(input); |
| 41 | input.style.top = "20px"; |
| 42 | input.style.left = "30px"; |
| 43 | input.focus(); |
| 44 | input.selectionStart = 5; |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 45 | }); |
| 46 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 47 | afterEach(function () { |
| 48 | document.getElementsByTagName("body")[0].removeChild( |
Akron | 95abaf4 | 2018-04-26 15:33:22 +0200 | [diff] [blame] | 49 | input |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 50 | ); |
| 51 | }); |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 52 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 53 | afterAll(function () { |
| 54 | try { |
Akron | 1a5a587 | 2016-09-05 20:17:14 +0200 | [diff] [blame] | 55 | var mirrors = document.querySelectorAll(".hint.mirror"); |
| 56 | for (var i in mirrors) { |
| 57 | mirrors[i].parentNode.removeChild(mirrors[i]) |
| 58 | }; |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 59 | } |
| 60 | catch (e) {}; |
| 61 | }); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 62 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 63 | it('should be initializable', function () { |
| 64 | // Supports: context, searchField |
| 65 | var inputField = inputClass.create(input); |
| 66 | expect(inputField._element).not.toBe(undefined); |
| 67 | }); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 68 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 69 | it('should have text', function () { |
| 70 | expect(input.value).toEqual('abcdefghijklmno'); |
| 71 | var inputField = inputClass.create(input); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 72 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 73 | expect(inputField.value()).toEqual("abcdefghijklmno"); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 74 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 75 | expect(input.selectionStart).toEqual(5); |
| 76 | expect(inputField.element().selectionStart).toEqual(5); |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 77 | expect(inputField._split()[0]).toEqual("abcde"); |
| 78 | expect(inputField._split()[1]).toEqual("fghijklmno"); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 79 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 80 | inputField.insert("xyz"); |
| 81 | expect(inputField.value()).toEqual('abcdexyzfghijklmno'); |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 82 | expect(inputField._split()[0]).toEqual("abcdexyz"); |
| 83 | expect(inputField._split()[1]).toEqual("fghijklmno"); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 84 | }); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 85 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 86 | it('should be correctly positioned', function () { |
| 87 | expect(input.value).toEqual('abcdefghijklmno'); |
| 88 | var inputField = inputClass.create(input); |
| 89 | document.getElementsByTagName("body")[0].appendChild(input); |
| 90 | inputField.reposition(); |
| 91 | expect(input.style.left).toEqual("30px"); |
| 92 | expect(inputField.mirror().style.left.match(/^(\d+)px$/)[1]).toBeGreaterThan(29); |
| 93 | expect(inputField.mirror().style.top.match(/^(\d+)px$/)[1]).toBeGreaterThan(20); |
| 94 | }); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 95 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 96 | it('should have a correct context', function () { |
| 97 | expect(input.value).toEqual('abcdefghijklmno'); |
| 98 | var inputField = inputClass.create(input); |
| 99 | expect(inputField.value()).toEqual("abcdefghijklmno"); |
| 100 | expect(inputField.element().selectionStart).toEqual(5); |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 101 | expect(inputField._split()[0]).toEqual("abcde"); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 102 | expect(inputField.context()).toEqual("abcde"); |
| 103 | }); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 104 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 105 | /* |
| 106 | it('should be correctly triggerable', function () { |
| 107 | // https://developer.mozilla.org/samples/domref/dispatchEvent.html |
| 108 | var hint = KorAP.Hint.create({ "inputField" : input }); |
| 109 | emitKeyboardEvent(hint.inputField.element, "keypress", 20); |
| 110 | }); |
| 111 | */ |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 112 | }); |
| 113 | |
Nils Diewald | 1c54692 | 2015-04-13 01:56:19 +0000 | [diff] [blame] | 114 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 115 | describe('KorAP.ContextAnalyzer', function () { |
| 116 | it('should be initializable', function () { |
| 117 | var analyzer = contextClass.create(")"); |
| 118 | expect(analyzer).toBe(undefined); |
| 119 | analyzer = contextClass.create(".+?"); |
| 120 | expect(analyzer).not.toBe(undefined); |
| 121 | }); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 122 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 123 | it('should check correctly', function () { |
| 124 | analyzer = contextClass.create(KorAP.context); |
| 125 | expect(analyzer.test("cnx/]cnx/c=")).toEqual("cnx/c="); |
| 126 | expect(analyzer.test("cnx/c=")).toEqual("cnx/c="); |
| 127 | expect(analyzer.test("cnx/c=np mate/m=mood:")).toEqual("mate/m=mood:"); |
| 128 | expect(analyzer.test("impcnx/")).toEqual("impcnx/"); |
| 129 | expect(analyzer.test("cnx/c=npcnx/")).toEqual("npcnx/"); |
| 130 | expect(analyzer.test("mate/m=degree:pos corenlp/ne_dewac_175m_600=")) |
Akron | 1a5a587 | 2016-09-05 20:17:14 +0200 | [diff] [blame] | 131 | .toEqual("corenlp/ne_dewac_175m_600="); |
Akron | 113cc1a | 2016-01-22 21:17:57 +0100 | [diff] [blame] | 132 | expect(analyzer.test("corenlp/")).toEqual("corenlp/"); |
| 133 | expect(analyzer.test("corenlp/c=")).toEqual("corenlp/c="); |
| 134 | expect(analyzer.test("corenlp/c=PP-")).toEqual("corenlp/c=PP-"); |
| 135 | expect(analyzer.test("corenlp/c=XY-")).toEqual("corenlp/c=XY-"); |
Akron | cff9bac | 2016-01-25 21:39:38 +0100 | [diff] [blame] | 136 | expect(analyzer.test("sgbr/l=")).toEqual("sgbr/l="); |
| 137 | expect(analyzer.test("sgbr/lv=")).toEqual("sgbr/lv="); |
| 138 | expect(analyzer.test("sgbr/p=")).toEqual("sgbr/p="); |
Akron | ee9ef4a | 2016-06-03 12:50:08 +0200 | [diff] [blame] | 139 | expect(analyzer.test("")).toEqual(undefined); |
| 140 | expect(analyzer.test("abcdecnx/")).toEqual("abcdecnx/"); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 141 | }); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 142 | }); |
| 143 | |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 144 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 145 | describe('KorAP.Hint', function () { |
Akron | e91da78 | 2017-12-15 17:17:50 +0100 | [diff] [blame] | 146 | KorAP.annotationHelper = { |
Akron | 02360e4 | 2016-06-07 13:41:12 +0200 | [diff] [blame] | 147 | "-" : [ |
Akron | 1a5a587 | 2016-09-05 20:17:14 +0200 | [diff] [blame] | 148 | ["Base Annotation", "base/s=", "Structure"], |
| 149 | ["CoreNLP", "corenlp/", "Constituency, Named Entities, Part-of-Speech"] |
Akron | 02360e4 | 2016-06-07 13:41:12 +0200 | [diff] [blame] | 150 | ], |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 151 | "corenlp/" : [ |
Akron | 1a5a587 | 2016-09-05 20:17:14 +0200 | [diff] [blame] | 152 | ["Named Entity", "ne=" , "Combined"], |
| 153 | ["Named Entity", "ne_dewac_175m_600=" , "ne_dewac_175m_600"], |
| 154 | ["Named Entity", "ne_hgc_175m_600=", "ne_hgc_175m_600"] |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 155 | ] |
| 156 | }; |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 157 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 158 | beforeEach(function () { |
| 159 | input = document.createElement("input"); |
| 160 | input.setAttribute("type", "text"); |
| 161 | input.setAttribute("value", "abcdefghijklmno"); |
| 162 | input.style.position = 'absolute'; |
| 163 | input.style.top = "20px"; |
| 164 | input.style.left = "30px"; |
| 165 | input.focus(); |
| 166 | input.selectionStart = 5; |
| 167 | }); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 168 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 169 | it('should be initializable', function () { |
| 170 | // Supports: context, searchField |
| 171 | var hint = hintClass.create({ |
Akron | 1a5a587 | 2016-09-05 20:17:14 +0200 | [diff] [blame] | 172 | inputField : input |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 173 | }); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 174 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 175 | expect(hint).toBeTruthy(); |
| 176 | }); |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 177 | |
Akron | 1a5a587 | 2016-09-05 20:17:14 +0200 | [diff] [blame] | 178 | |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 179 | it('should alert at char pos', function () { |
| 180 | var hint = hintClass.create({ |
Akron | 1a5a587 | 2016-09-05 20:17:14 +0200 | [diff] [blame] | 181 | inputField : input |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 182 | }); |
| 183 | |
| 184 | expect(hint.active()).toBeFalsy(); |
| 185 | |
| 186 | expect(hint.alert(4, 'That does not work!')).toBeTruthy(); |
| 187 | |
| 188 | expect(hint.active()).toBeTruthy(); |
| 189 | |
| 190 | var container = hint.inputField().container(); |
| 191 | expect(container.firstChild.classList.contains('hint')).toBe(true); |
| 192 | expect(container.firstChild.classList.contains('alert')).toBe(true); |
| 193 | expect(container.firstChild.textContent).toEqual('That does not work!'); |
| 194 | expect(hint.inputField().mirrorValue()).toEqual('abcd'); |
| 195 | |
| 196 | expect(hint.alert(4, 'That does not work!')).toBeFalsy(); |
| 197 | |
| 198 | // Update - meaning: hide alert |
| 199 | hint.update(); |
| 200 | |
| 201 | expect(hint.alert().active).toBeFalsy(); |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 202 | expect(hint.active()).toBeFalsy(); |
Akron | 1a5a587 | 2016-09-05 20:17:14 +0200 | [diff] [blame] | 203 | |
| 204 | // Show again |
| 205 | expect(hint.alert(5, 'That does not work!')).toBeTruthy(); |
| 206 | expect(hint.inputField().mirrorValue()).toEqual('abcde'); |
| 207 | expect(hint.alert().active).toBeTruthy(); |
| 208 | expect(hint.active()).toBeTruthy(); |
| 209 | |
| 210 | // Show menu, hide alert! |
| 211 | hint.show(false); |
| 212 | expect(hint.active()).toBeTruthy(); |
| 213 | expect(hint.inputField().mirrorValue()).toEqual('abcde'); |
| 214 | expect(hint.alert().active).toBeFalsy(); |
| 215 | |
| 216 | // Show again |
| 217 | expect(hint.alert(5, 'That does not work!')).toBeTruthy(); |
| 218 | expect(hint.inputField().mirrorValue()).toEqual('abcde'); |
| 219 | expect(hint.alert().active).toBeTruthy(); |
| 220 | expect(hint.active()).toBeTruthy(); |
| 221 | |
| 222 | // Show menu, hide alert! |
| 223 | hint.show(false); |
| 224 | expect(hint.active()).toBeTruthy(); |
| 225 | expect(hint.inputField().mirrorValue()).toEqual('abcde'); |
| 226 | expect(hint.alert().active).toBeFalsy(); |
Akron | ee9ef4a | 2016-06-03 12:50:08 +0200 | [diff] [blame] | 227 | }); |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 228 | |
Akron | 1a5a587 | 2016-09-05 20:17:14 +0200 | [diff] [blame] | 229 | |
| 230 | |
Akron | ee9ef4a | 2016-06-03 12:50:08 +0200 | [diff] [blame] | 231 | it('should view main menu on default', function () { |
| 232 | var hint = hintClass.create({ |
Akron | 1a5a587 | 2016-09-05 20:17:14 +0200 | [diff] [blame] | 233 | inputField : input |
Akron | ee9ef4a | 2016-06-03 12:50:08 +0200 | [diff] [blame] | 234 | }); |
| 235 | |
| 236 | expect(hint.active()).toBeFalsy(); |
| 237 | |
| 238 | hint.inputField().insert('der Baum corenlp/'); |
Akron | ee9ef4a | 2016-06-03 12:50:08 +0200 | [diff] [blame] | 239 | |
Akron | 8eaeb2e | 2016-08-29 18:26:28 +0200 | [diff] [blame] | 240 | var cont = hint.inputField().container(); |
| 241 | |
| 242 | expect(cont.getElementsByTagName('div').length).toBe(1); |
| 243 | expect(cont.getElementsByTagName('ul').length).toBe(0); |
| 244 | expect(cont.firstChild).toEqual(cont.firstChild); |
| 245 | |
| 246 | // Show menu, if a relevant context exists |
| 247 | // There is a menu for corenlp/ |
Akron | 02360e4 | 2016-06-07 13:41:12 +0200 | [diff] [blame] | 248 | hint.show(false); |
| 249 | |
Akron | 8eaeb2e | 2016-08-29 18:26:28 +0200 | [diff] [blame] | 250 | expect(hint.inputField().container().getElementsByTagName('ul').length).toEqual(1); |
| 251 | expect(hint.inputField().container().getElementsByTagName('li').length).toEqual(3); |
Akron | 65c7435 | 2016-09-02 17:23:39 +0200 | [diff] [blame] | 252 | |
Akron | 8eaeb2e | 2016-08-29 18:26:28 +0200 | [diff] [blame] | 253 | // Hide the menu and focus on the input |
| 254 | hint.unshow(); |
Akron | 65c7435 | 2016-09-02 17:23:39 +0200 | [diff] [blame] | 255 | |
| 256 | expect(hint.inputField().container().getElementsByTagName('div').length).toEqual(1); |
| 257 | expect(hint.inputField().container().getElementsByTagName('li').length).toEqual(0); |
Akron | ee9ef4a | 2016-06-03 12:50:08 +0200 | [diff] [blame] | 258 | |
Akron | 02360e4 | 2016-06-07 13:41:12 +0200 | [diff] [blame] | 259 | hint.unshow(); |
Akron | 65c7435 | 2016-09-02 17:23:39 +0200 | [diff] [blame] | 260 | |
Akron | ee9ef4a | 2016-06-03 12:50:08 +0200 | [diff] [blame] | 261 | hint.inputField().insert(' hhhh'); |
Akron | 65c7435 | 2016-09-02 17:23:39 +0200 | [diff] [blame] | 262 | |
Akron | ee9ef4a | 2016-06-03 12:50:08 +0200 | [diff] [blame] | 263 | // show with context |
Akron | 02360e4 | 2016-06-07 13:41:12 +0200 | [diff] [blame] | 264 | hint.show(false); |
Akron | 65c7435 | 2016-09-02 17:23:39 +0200 | [diff] [blame] | 265 | |
Akron | ee9ef4a | 2016-06-03 12:50:08 +0200 | [diff] [blame] | 266 | expect(hint.inputField().container().getElementsByTagName('div').length).toEqual(4); |
| 267 | expect(hint.inputField().container().getElementsByTagName('ul').length).toEqual(1); |
Akron | 02360e4 | 2016-06-07 13:41:12 +0200 | [diff] [blame] | 268 | expect(hint.inputField().container().getElementsByTagName('li').length).toEqual(2); |
| 269 | |
Akron | ee9ef4a | 2016-06-03 12:50:08 +0200 | [diff] [blame] | 270 | hint.unshow(); |
| 271 | hint.inputField().insert(' aaaa/'); |
| 272 | |
| 273 | // show with context |
| 274 | hint.show(true); |
| 275 | |
Akron | 1a5a587 | 2016-09-05 20:17:14 +0200 | [diff] [blame] | 276 | expect(hint.inputField().container().getElementsByTagName('div').length).toEqual(1); |
| 277 | expect(hint.inputField().container().getElementsByTagName('ul').length).toEqual(0); |
| 278 | }); |
| 279 | |
Akron | 95abaf4 | 2018-04-26 15:33:22 +0200 | [diff] [blame] | 280 | |
| 281 | it('should open menus depending on the context', function () { |
| 282 | var hint = hintClass.create({ |
| 283 | inputField : input |
| 284 | }); |
| 285 | hint.inputField().reset(); |
| 286 | |
| 287 | expect(hint.active()).toBeFalsy(); |
| 288 | |
| 289 | // show with context |
| 290 | hint.show(false); |
| 291 | |
| 292 | expect(hint.active()).toBeTruthy(); |
| 293 | |
| 294 | expect(hint.inputField().container().getElementsByTagName('li')[0].firstChild.innerText).toEqual("Base Annotation"); |
| 295 | |
| 296 | // Type in prefix |
| 297 | hint.active().prefix("cor").show(); |
| 298 | expect(hint.active().prefix()).toEqual("cor"); |
| 299 | |
| 300 | // Click first step |
| 301 | expect(hint.inputField().container().getElementsByTagName('li')[0].firstChild.firstChild.innerText).toEqual("Cor"); |
| 302 | hint.inputField().container().getElementsByTagName('li')[0].click(); |
| 303 | |
| 304 | expect(hint.active()).toBeTruthy(); |
| 305 | |
| 306 | // Click second step |
| 307 | expect(hint.inputField().container().getElementsByTagName('li')[0].firstChild.innerText).toEqual("Named Entity"); |
| 308 | hint.inputField().container().getElementsByTagName('li')[0].click() |
| 309 | |
| 310 | // Invisible menu |
| 311 | expect(hint.inputField().container().getElementsByTagName('li')[0]).toBeUndefined(); |
| 312 | |
| 313 | // Inactive menu |
| 314 | expect(hint.active()).toBeFalsy(); |
| 315 | |
| 316 | // show with context |
| 317 | hint.show(false); |
| 318 | |
| 319 | // No prefix |
| 320 | expect(hint.active().prefix()).toEqual(""); |
| 321 | }); |
| 322 | |
| 323 | |
Akron | 1a5a587 | 2016-09-05 20:17:14 +0200 | [diff] [blame] | 324 | it('should not view main menu if context is mandatory', function () { |
| 325 | var hint = hintClass.create({ |
| 326 | inputField : input |
| 327 | }); |
| 328 | |
| 329 | expect(hint.active()).toBeFalsy(); |
| 330 | |
| 331 | // Fine |
| 332 | hint.inputField().insert('der Baum corenlp/'); |
| 333 | hint.show(true); |
| 334 | expect(hint.active()).toBeTruthy(); |
| 335 | |
| 336 | // Not analyzable |
| 337 | hint.inputField().insert('jhgjughjfhgnhfcvgnhj'); |
| 338 | hint.show(true); |
| 339 | expect(hint.active()).toBeFalsy(); |
| 340 | |
| 341 | // Not available |
| 342 | hint.inputField().insert('jhgjughjfhgnhfcvgnhj/'); |
| 343 | hint.show(true); |
| 344 | expect(hint.active()).toBeFalsy(); |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 345 | }); |
Akron | 5746ecf | 2018-06-23 10:57:24 +0200 | [diff] [blame^] | 346 | |
| 347 | |
| 348 | it('should show the assistant bar on blur', function () { |
| 349 | var hint = hintClass.create({ |
| 350 | inputField : input |
| 351 | }); |
| 352 | // Fine |
| 353 | hint.inputField().insert('der Baum corenlp/'); |
| 354 | hint.show(true); |
| 355 | expect(hint.active()).toBeTruthy(); |
| 356 | |
| 357 | // Blur |
| 358 | hint.active().hideWithoutDestruction(); |
| 359 | expect(hint.active()).toBeFalsy(); |
| 360 | }); |
Akron | 65c7435 | 2016-09-02 17:23:39 +0200 | [diff] [blame] | 361 | |
Akron | 02360e4 | 2016-06-07 13:41:12 +0200 | [diff] [blame] | 362 | xit('should remove all menus on escape'); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 363 | }); |
| 364 | |
Akron | 65c7435 | 2016-09-02 17:23:39 +0200 | [diff] [blame] | 365 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 366 | describe('KorAP.HintMenuItem', function () { |
| 367 | it('should be initializable', function () { |
| 368 | expect( |
Akron | 1a5a587 | 2016-09-05 20:17:14 +0200 | [diff] [blame] | 369 | function() { menuItemClass.create([]) } |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 370 | ).toThrow(new Error("Missing parameters")); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 371 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 372 | expect( |
Akron | 1a5a587 | 2016-09-05 20:17:14 +0200 | [diff] [blame] | 373 | function() { menuItemClass.create(['CoreNLP']) } |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 374 | ).toThrow(new Error("Missing parameters")); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 375 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 376 | var menuItem = menuItemClass.create(['CoreNLP', 'corenlp/']); |
| 377 | expect(menuItem.name()).toEqual('CoreNLP'); |
| 378 | expect(menuItem.action()).toEqual('corenlp/'); |
| 379 | expect(menuItem.desc()).toBeUndefined(); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 380 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 381 | menuItem = menuItemClass.create( |
Akron | 1a5a587 | 2016-09-05 20:17:14 +0200 | [diff] [blame] | 382 | ['CoreNLP', 'corenlp/', 'It\'s funny'] |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 383 | ); |
| 384 | expect(menuItem.name()).toEqual('CoreNLP'); |
| 385 | expect(menuItem.action()).toEqual('corenlp/'); |
| 386 | expect(menuItem.desc()).not.toBeUndefined(); |
| 387 | expect(menuItem.desc()).toEqual('It\'s funny'); |
| 388 | }); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 389 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 390 | it('should have an element', function () { |
| 391 | var menuItem = menuItemClass.create(['CoreNLP', 'corenlp/']); |
| 392 | expect(menuItem.element()).not.toBe(undefined); |
| 393 | expect(menuItem.element().nodeName).toEqual("LI"); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 394 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 395 | var title = menuItem.element().firstChild; |
| 396 | expect(title.nodeName).toEqual("SPAN"); |
| 397 | expect(title.firstChild.nodeType).toEqual(3); |
| 398 | expect(title.firstChild.nodeValue).toEqual("CoreNLP"); |
| 399 | expect(menuItem.element().childNodes[0]).not.toBe(undefined); |
| 400 | expect(menuItem.element().childNodes[1]).toBe(undefined); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 401 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 402 | menuItem = menuItemClass.create( |
Akron | 1a5a587 | 2016-09-05 20:17:14 +0200 | [diff] [blame] | 403 | ['CoreNLP', 'corenlp/', 'my DescRiption'] |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 404 | ); |
| 405 | expect(menuItem.element()).not.toBe(undefined); |
| 406 | expect(menuItem.element().nodeName).toEqual("LI"); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 407 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 408 | title = menuItem.element().firstChild; |
| 409 | expect(title.nodeName).toEqual("SPAN"); |
| 410 | expect(title.firstChild.nodeType).toEqual(3); // TextNode |
| 411 | expect(title.firstChild.nodeValue).toEqual("CoreNLP"); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 412 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 413 | expect(menuItem.element().childNodes[0]).not.toBe(undefined); |
| 414 | expect(menuItem.element().childNodes[1]).not.toBe(undefined); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 415 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 416 | var desc = menuItem.element().lastChild; |
| 417 | expect(desc.nodeName).toEqual("SPAN"); |
| 418 | expect(desc.firstChild.nodeType).toEqual(3); // TextNode |
| 419 | expect(desc.firstChild.nodeValue).toEqual("my DescRiption"); |
| 420 | }); |
Nils Diewald | 1c54692 | 2015-04-13 01:56:19 +0000 | [diff] [blame] | 421 | |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 422 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 423 | it('should be activatable and deactivateable by class', function () { |
| 424 | var menuItem = menuItemClass.create(['CoreNLP', 'corenlp/']); |
| 425 | expect(menuItem.active()).toBe(false); |
| 426 | expect(menuItem.element().getAttribute("class")).toBe(null); |
| 427 | menuItem.active(true); |
| 428 | expect(menuItem.active()).toBe(true); |
| 429 | expect(menuItem.element().getAttribute("class")).toEqual("active"); |
| 430 | menuItem.active(false); // Is active |
| 431 | expect(menuItem.active()).toBe(false); |
| 432 | expect(menuItem.element().getAttribute("class")).toEqual(""); |
| 433 | menuItem.active(true); |
| 434 | expect(menuItem.active()).toBe(true); |
| 435 | expect(menuItem.element().getAttribute("class")).toEqual("active"); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 436 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 437 | menuItem = menuItemClass.create(['CoreNLP', 'corenlp/']); |
| 438 | expect(menuItem.active()).toBe(false); |
| 439 | expect(menuItem.element().getAttribute("class")).toBe(null); |
| 440 | menuItem.active(false); // Is not active |
| 441 | expect(menuItem.active()).toBe(false); |
| 442 | expect(menuItem.element().getAttribute("class")).toBe(null); |
| 443 | }); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 444 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 445 | it('should be set to boundary', function () { |
| 446 | var menuItem = menuItemClass.create(['CoreNLP', 'corenlp/']); |
| 447 | expect(menuItem.active()).toBe(false); |
| 448 | expect(menuItem.element().getAttribute("class")).toBe(null); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 449 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 450 | // Set active |
| 451 | menuItem.active(true); |
| 452 | expect(menuItem.active()).toBe(true); |
| 453 | expect(menuItem.noMore()).toBe(false); |
| 454 | expect(menuItem.element().getAttribute("class")).toEqual("active"); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 455 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 456 | // Set no more |
| 457 | menuItem.noMore(true); |
| 458 | expect(menuItem.active()).toBe(true); |
| 459 | expect(menuItem.noMore()).toBe(true); |
| 460 | expect(menuItem.element().getAttribute("class")).toEqual("active no-more"); |
Nils Diewald | 1c54692 | 2015-04-13 01:56:19 +0000 | [diff] [blame] | 461 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 462 | // No no more |
| 463 | menuItem.noMore(false); |
| 464 | expect(menuItem.active()).toBe(true); |
| 465 | expect(menuItem.noMore()).toBe(false); |
| 466 | expect(menuItem.element().getAttribute("class")).toEqual("active"); |
Nils Diewald | 1c54692 | 2015-04-13 01:56:19 +0000 | [diff] [blame] | 467 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 468 | // Set no more, deactivate |
| 469 | menuItem.noMore(true); |
| 470 | menuItem.active(false); |
| 471 | expect(menuItem.active()).toBe(false); |
| 472 | expect(menuItem.noMore()).toBe(true); |
| 473 | expect(menuItem.element().getAttribute("class")).toEqual("no-more"); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 474 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 475 | // Set active |
| 476 | menuItem.active(true); |
| 477 | expect(menuItem.active()).toBe(true); |
| 478 | expect(menuItem.noMore()).toBe(true); |
| 479 | expect(menuItem.element().getAttribute("class")).toEqual("no-more active"); |
| 480 | }); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 481 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 482 | it('should be highlightable', function () { |
| 483 | // Highlight in the middle |
| 484 | var menuItem = menuItemClass.create(['CoreNLP', 'corenlp/']); |
| 485 | menuItem.highlight("ren"); |
| 486 | expect(menuItem.element().innerHTML).toEqual("<span>Co<mark>reN</mark>LP</span>"); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 487 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 488 | menuItem.lowlight(); |
| 489 | expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span>"); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 490 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 491 | // Starting highlight |
| 492 | menuItem = menuItemClass.create(['CoreNLP', 'corenlp/']); |
| 493 | menuItem.highlight("cor"); |
| 494 | expect(menuItem.element().innerHTML).toEqual("<span><mark>Cor</mark>eNLP</span>"); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 495 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 496 | menuItem.lowlight(); |
| 497 | expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span>"); |
| 498 | |
| 499 | // Starting highlight - short |
| 500 | menuItem = menuItemClass.create(['CoreNLP', 'corenlp/']); |
| 501 | menuItem.highlight("c"); |
| 502 | expect(menuItem.element().innerHTML).toEqual("<span><mark>C</mark>oreNLP</span>"); |
| 503 | |
| 504 | menuItem.lowlight(); |
| 505 | expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span>"); |
| 506 | |
| 507 | // Highlight at the end |
| 508 | menuItem = menuItemClass.create(['CoreNLP', 'corenlp/']); |
| 509 | menuItem.highlight("nlp"); |
| 510 | expect(menuItem.element().innerHTML).toEqual("<span>Core<mark>NLP</mark></span>"); |
| 511 | |
| 512 | menuItem.lowlight(); |
| 513 | expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span>"); |
| 514 | |
| 515 | // Highlight at the end - short |
| 516 | menuItem = menuItemClass.create(['CoreNLP', 'corenlp/']); |
| 517 | menuItem.highlight("p"); |
| 518 | expect(menuItem.element().innerHTML).toEqual("<span>CoreNL<mark>P</mark></span>"); |
| 519 | |
| 520 | menuItem.lowlight(); |
| 521 | expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span>"); |
| 522 | |
| 523 | // No highlight |
| 524 | menuItem = menuItemClass.create(['CoreNLP', 'corenlp/']); |
| 525 | menuItem.highlight("xp"); |
| 526 | expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span>"); |
| 527 | |
| 528 | menuItem.lowlight(); |
| 529 | expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span>"); |
| 530 | |
| 531 | // Highlight in the middle - first |
| 532 | menuItem = menuItemClass.create(['CoreNLP', 'corenlp/', 'This is my Example']); |
| 533 | |
| 534 | menuItem.highlight("ren"); |
| 535 | expect(menuItem.element().innerHTML).toEqual("<span>Co<mark>reN</mark>LP</span><span class=\"desc\">This is my Example</span>"); |
| 536 | |
| 537 | menuItem.lowlight(); |
| 538 | expect(menuItem.element().innerHTML).toEqual('<span>CoreNLP</span><span class="desc">This is my Example</span>'); |
| 539 | |
| 540 | // Highlight in the middle - second |
| 541 | menuItem = menuItemClass.create(['CoreNLP', 'corenlp/', 'This is my Example']); |
| 542 | menuItem.highlight("ampl"); |
| 543 | expect(menuItem.element().innerHTML).toEqual('<span>CoreNLP</span><span class="desc">This is my Ex<mark>ampl</mark>e</span>'); |
| 544 | |
| 545 | menuItem.lowlight(); |
| 546 | expect(menuItem.element().innerHTML).toEqual('<span>CoreNLP</span><span class="desc">This is my Example</span>'); |
| 547 | |
| 548 | // Highlight in the middle - both |
| 549 | menuItem = menuItemClass.create(['CoreNLP', 'corenlp/', 'This is my Example']); |
| 550 | |
| 551 | menuItem.highlight("e"); |
| 552 | expect(menuItem.element().innerHTML).toEqual('<span>Cor<mark>e</mark>NLP</span><span class="desc">This is my <mark>E</mark>xampl<mark>e</mark></span>'); |
| 553 | |
| 554 | menuItem.lowlight(); |
| 555 | expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span><span class=\"desc\">This is my Example</span>"); |
| 556 | |
| 557 | // Highlight in the end - second |
| 558 | menuItem = menuItemClass.create(['CoreNLP', 'corenlp/', 'This is my Example']); |
| 559 | menuItem.highlight("le"); |
| 560 | expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span><span class=\"desc\">This is my Examp<mark>le</mark></span>"); |
| 561 | |
| 562 | menuItem.lowlight(); |
| 563 | expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span><span class=\"desc\">This is my Example</span>"); |
| 564 | |
| 565 | // Highlight at the beginning - second |
| 566 | menuItem = menuItemClass.create(['CoreNLP', 'corenlp/', 'This is my Example']); |
| 567 | menuItem.highlight("this"); |
| 568 | expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span><span class=\"desc\"><mark>This</mark> is my Example</span>"); |
| 569 | |
| 570 | menuItem.lowlight(); |
| 571 | expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span><span class=\"desc\">This is my Example</span>"); |
Akron | 6ed1399 | 2016-05-23 18:06:05 +0200 | [diff] [blame] | 572 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 573 | }); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 574 | }); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 575 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 576 | describe('KorAP.HintMenu', function () { |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 577 | var list = [ |
| 578 | ["Constituency", "c=", "Example 1"], |
| 579 | ["Lemma", "l="], |
| 580 | ["Morphology", "m=", "Example 2"], |
| 581 | ["Part-of-Speech", "p="], |
| 582 | ["Syntax", "syn="] |
| 583 | ]; |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 584 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 585 | it('should be initializable', function () { |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 586 | var menu = menuClass.create(null, "cnx/", list); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 587 | expect(menu.element().nodeName).toEqual('UL'); |
Akron | 65c7435 | 2016-09-02 17:23:39 +0200 | [diff] [blame] | 588 | // expect(menu.element().style.opacity).toEqual("0"); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 589 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 590 | menu.limit(8); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 591 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 592 | // view |
| 593 | menu.show(); |
Akron | 6ed1399 | 2016-05-23 18:06:05 +0200 | [diff] [blame] | 594 | expect(menu.prefix()).toBe(''); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 595 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 596 | // First element in list |
| 597 | expect(menu.item(0).active()).toBe(true); |
| 598 | expect(menu.item(0).noMore()).toBe(true); |
| 599 | |
| 600 | // Middle element in list |
| 601 | expect(menu.item(2).active()).toBe(false); |
| 602 | expect(menu.item(2).noMore()).toBe(false); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 603 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 604 | // Last element in list |
| 605 | expect(menu.item(menu.length() - 1).active()).toBe(false); |
| 606 | expect(menu.item(menu.length() - 1).noMore()).toBe(true); |
Akron | 6ed1399 | 2016-05-23 18:06:05 +0200 | [diff] [blame] | 607 | |
| 608 | expect(menu.shownItem(0).active()).toBeTruthy(); |
| 609 | expect(menu.shownItem(0).lcField()).toEqual(' constituency example 1'); |
| 610 | expect(menu.shownItem(1).lcField()).toEqual(' lemma'); |
| 611 | expect(menu.shownItem(2).lcField()).toEqual(' morphology example 2'); |
| 612 | |
| 613 | menu.next(); |
| 614 | expect(menu.shownItem(1).active()).toBeTruthy(); |
| 615 | |
| 616 | menu.next(); |
| 617 | expect(menu.shownItem(2).active()).toBeTruthy(); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 618 | }); |
Nils Diewald | 19ccee9 | 2014-12-08 11:30:08 +0000 | [diff] [blame] | 619 | }); |
| 620 | }); |