Fix selectMenu test suite
diff --git a/dev/js/spec/selectMenuSpec.js b/dev/js/spec/selectMenuSpec.js
index 3be39fd..5f0c909 100644
--- a/dev/js/spec/selectMenuSpec.js
+++ b/dev/js/spec/selectMenuSpec.js
@@ -2,48 +2,57 @@
['selectMenu'],
function (selectMenuClass) {
+ /*
+ * Check for preselected values
+ */
+
describe('KorAP.SelectMenu', function () {
var list = [
- {
- content : 'Poliqarp',
- value : 'poliqarp',
- desc : 'The Polish National Corpus QL'
- },
- {
- content : 'Cosmas II',
- value : 'cosmas2',
- desc : 'The Polish National Corpus QL'
- },
- {
- content : 'Annis',
- value : 'annis'
- },
- {
- content : 'CQL v1.2',
- value : 'cql'
- }
+ {
+ content : 'Poliqarp',
+ value : 'poliqarp',
+ desc : 'The Polish National Corpus QL'
+ },
+ {
+ content : 'Cosmas II',
+ value : 'cosmas2',
+ desc : 'The Polish National Corpus QL'
+ },
+ {
+ content : 'Annis',
+ value : 'annis'
+ },
+ {
+ content : 'CQL v1.2',
+ value : 'cql'
+ }
];
-
+
it('should replace a select element', function () {
- var div = document.createElement('div');
- var element = div.appendChild(document.createElement('select'));
- for (i in list) {
- var opt = element.appendChild(document.createElement('option'));
- opt.setAttribute('value', list[i].value);
- opt.appendChild(document.createTextNode(list[i].content));
- };
+ var div = document.createElement('div');
+ var element = div.appendChild(document.createElement('select'));
+ for (i in list) {
+ var opt = element.appendChild(document.createElement('option'));
+ opt.setAttribute('value', list[i].value);
+ opt.appendChild(document.createTextNode(list[i].content));
+ };
- var menu = selectMenuClass.create(element);
+ var menu = selectMenuClass.create(div);
- expect(element.style.display).toEqual('none');
+ expect(element.style.display).toEqual('none');
- menu.show();
+ // This selects the first item
+ expect(menu.select()).toEqual(0);
+ expect(menu._title.textContent).toEqual('Poliqarp');
+
+ // Now show the menu
+ menu.showSelected();
- expect(menu.item(0).active()).toBe(true);
- expect(menu.item(0).noMore()).toBe(true);
+ expect(menu.item(0).active()).toBe(true);
+ expect(menu.item(0).noMore()).toBe(true);
- // TODO: Improve lcfield!!!!!!
- expect(menu.shownItem(0).lcField()).toEqual(' poliqarp');
+ // TODO: Improve lcfield!!!!!!
+ expect(menu.shownItem(0).lcField()).toEqual(' poliqarp');
});
});
}