Added a method to container that allows for removing items dynamically
Change-Id: Ibcc5eee453a65943a80141ada4cebe0aed0112f6
diff --git a/dev/js/spec/containerMenuSpec.js b/dev/js/spec/containerMenuSpec.js
index 61f919f..40d72e0 100644
--- a/dev/js/spec/containerMenuSpec.js
+++ b/dev/js/spec/containerMenuSpec.js
@@ -96,7 +96,7 @@
}
};
- describe('OwnContainerMenu', function () {
+ describe('KorAP.ContainerMenu', function () {
var list = [
["Constituency"],
@@ -327,6 +327,50 @@
});
+ it('should allow removing an item from the container list', function () {/**var list = [
+ ["Constituency"],
+ ["Lemma"],
+ ["Morphology"],
+ ["Part-of-Speech"],
+ ["Syntax"]
+ ];
+ */
+ var menu = OwnContainerMenu.create(list,ExampleItemList);
+ menu._firstActive = true;
+ menu.limit(3);
+ expect(menu.show()).toBe(true);
+ menu.next();
+ menu.next();
+ menu.next();
+ menu.next();
+ expect(menu.shownItem(2).active()).toBe(true);
+ expect(menu.container().item(0).active()).toBe(false);
+ expect(menu.container().item(1).active()).toBe(false);
+ expect(menu.container().item(2).active()).toBe(false); //prefix
+ expect(menu.container().item(2)).toEqual(menu._prefix);
+ expect(menu.container().length()).toBe(3);
+ menu.container().removeItemByIndex(0);
+ expect(menu.shownItem(2).active()).toBe(true);
+ expect(menu.container().item(0).active()).toBe(false);
+ expect(menu.container().item(1).active()).toBe(false); //prefix
+ expect(menu.container().item(1)).toEqual(menu._prefix);
+ expect(menu.container().length()).toBe(2);
+ menu.next();
+ expect(menu.shownItem(2).active()).toBe(false);
+ expect(menu.container().item(0).active()).toBe(true);
+ expect(menu.container().item(1).active()).toBe(false); //prefix
+ expect(menu.container().item(1)).toEqual(menu._prefix);
+ expect(menu.container().length()).toBe(2);
+ menu.container().removeItemByIndex(0);
+ expect(menu.shownItem(2).active()).toBe(false);
+ expect(menu.shownItem(0).active()).toBe(true);
+ expect(menu.container().item(0).active()).toBe(false); //prefix //would be selected, if it were not ""
+ expect(menu.container().item(0)).toEqual(menu._prefix);
+ expect(menu.container().length()).toBe(1);
+
+
+
+ });
it('should be nextable', function () {
var menu = OwnContainerMenu.create(list);
menu._firstActive = true;
@@ -2055,7 +2099,8 @@
expect(menu.slider().length()).toEqual(4);
});
});
- describe('Container', function () {
+
+ describe('KorAP.ContainerMenu.Container', function () {
it("should be initializable with no additional container items", function () {
var list = [
["Constituency"],
@@ -2085,8 +2130,6 @@
expect(container.liveLength()).toEqual(1);
menu.prev();
expect(container.active()).toBeTruthy();
-
-
});
});