Your IP : 216.73.216.86


Current Path : /home/emeraadmin/www/4d695/
Upload File :
Current File : /home/emeraadmin/www/4d695/bootstrap-tagsinput.zip

PK\�\���pp input_with_object_items.tests.jsnu�[���describe("bootstrap-tagsinput", function() {

  describe("with objects as items", function() {
    testTagsInput('<input type="text" />', function() {
      it("adding a item should throw an exception", function() {
        var element = this.$element;
        expect(function() { element.tagsinput('add', {}); }).toThrow("Can't add objects when itemValue option is not set");
      });
    });

    testTagsInput('<input type="text" />', { itemValue: function(item) { return item.value; } }, function() {
      describe("adding an item", function() {
        var item;
        beforeEach(function() {
          item = { value: 1 };
          this.$element.tagsinput('add', item);
        });
        it("'items' should return the item", function() {
          expect(this.$element.tagsinput('items')[0]).toBe(item);
        });
        it("val() should return the item's value", function() {
          expect(this.$element.val()).toBe("1");
        });
        it("tag's text should be the item's value", function() {
          expect($('.tag', this.$sandbox).text()).toBe("1");
        });
      });
    });

    testTagsInput('<input type="text" />', { itemValue: 'value' }, function() {
      describe("adding an item", function() {
        var item;
        beforeEach(function() {
          item = { value: 1 };
          this.$element.tagsinput('add', item);
        });
        it("'items' should return the item", function() {
          expect(this.$element.tagsinput('items')[0]).toBe(item);
        });
        it("'items' should returns exactly 1 item", function() {
          expect(this.$element.tagsinput('items').length).toBe(1);
        });
        it("val() should return the item's value", function() {
          expect(this.$element.val()).toBe("1");
        });
        it("tag's text should be the item's value", function() {
          expect($('.tag', this.$sandbox).text()).toBe("1");
        });
      });
    });

    testTagsInput('<input type="text" />', { itemValue: function(item) { return item.value; }, itemText: function(item) { return item.text; } }, function() {
      describe("adding an item", function() {
        var item = { value: 1, text: 'some' };
        beforeEach(function() {
          this.$element.tagsinput('add', item);
        });
        it("'items' should return the item", function() {
          expect(this.$element.tagsinput('items')[0]).toBe(item);
        });
        it("val() should return the item's value", function() {
          expect(this.$element.val()).toBe("1");
        });
        it("tag's text should be the item's text", function() {
          expect($('.tag', this.$sandbox).text()).toBe("some");
        });

        describe("change item and invoke 'refesh'", function() {
          beforeEach(function() {
            item.text = 'changed';
            this.$element.tagsinput('refresh');
          });

          it("should update tags's text", function() {
            expect($('.tag', this.$sandbox).text()).toBe('changed');
          });
          it("tag should still have remove button", function() {
            expect($('[data-role=remove]', this.$sandbox)[0]).not.toBeUndefined();
          });
        });
      });
    });
	
    testTagsInput('<input type="text" />', { itemValue: function(item) { return item.value; }, itemText: function(item) { return item.text; }, itemTitle: function(item) { return item.title; } }, function() {
	  describe("adding an item with a title", function() {
        var item;
        beforeEach(function() {
          item = { value: 1, text: 'one', title: 'number one' };
          this.$element.tagsinput('add', item);
        });
        it("'items' should return the item", function() {
          expect(this.$element.tagsinput('items')[0]).toBe(item);
        });
        it("'items' should returns exactly 1 item", function() {
          expect(this.$element.tagsinput('items').length).toBe(1);
        });
        it("val() should return the item's value", function() {
          expect(this.$element.val()).toBe("1");
        });
        it("tag's text should be the item's value", function() {
          expect($('.tag', this.$sandbox).text()).toBe("one");
        });
		it("tag's title should be the item's title", function() {
		  expect($('.tag', this.$sandbox).attr('title')).toBe("number one");
		});
	  });
	});
  });
});PK\�\#���IIreproduced_bugs.tests.jsnu�[���describe("bootstrap-tagsinput", function() {

  describe("Reproduced bugs", function() {

    describe("#1: Demo error", function() {

      testTagsInput('<input type="text" value="some_tag" />', function() {
        it("clicking remove button should remove item", function() {
          $('[data-role=remove]', this.$sandbox).trigger('click');
          expect(this.$element.tagsinput('items').length).toBe(0);
        });
        it("clicking remove button should remove tag element", function() {
          $('[data-role=remove]', this.$sandbox).trigger('click');
          expect($('.tag', this.$sandbox).length).toBe(0);
        });
      });
    });

    describe("#11: Cannot remove an item by programming", function() {
      testTagsInput('<input type="text" />', { itemValue: function(item) { return item.value; } }, function() {
        describe("add two different objects with same value", function() {
          var item1 = { value: 1 },
              item2 = { value: 1 };

          beforeEach(function() {
            this.$element.tagsinput('add', item1);
            this.$element.tagsinput('add', item2);
          });
          it("'items' should return the first added item", function() {
            expect(this.$element.tagsinput('items')[0]).toBe(item1);
          });
          it("'items' should return exactly 1 item", function() {
            expect(this.$element.tagsinput('items').length).toBe(1);
          });
          it("should have exactly 1 tag", function() {
            expect($('.tag', this.$sandbox).length).toBe(1);
          });
        });

        describe("remove item", function() {
          beforeEach(function() {
            this.$element.tagsinput('add', { value: 1 });
          });
          it("by value, should remove then item", function() {
            this.$element.tagsinput('remove', 1);
            expect(this.$element.tagsinput('items').length).toBe(0);
          });
          it("by value, should remove then tag", function() {
            this.$element.tagsinput('remove', 1);
            expect($('.tag', this.$sandbox).length).toBe(0);
          });
          it("by different instance, should remove then tag", function() {
            this.$element.tagsinput('remove', { value: 1 });
            expect($('.tag', this.$sandbox).length).toBe(0);
          });
          it("should remove items when none of the items have a matching value", function() {
            this.$element.tagsinput('add', { value: 1 });
            this.$element.tagsinput('remove', 2);
            expect(this.$element.tagsinput('items').length).toBe(1);
          });
        });
      });

      testTagsInput('<select />', { itemValue: function(item) { return item.value; } }, function() {
        describe("add two objects", function() {
          var item1 = { value: 1 },
              item2 = { value: 2 };

          beforeEach(function() {
            this.$element.tagsinput('add', item1);
            this.$element.tagsinput('add', item2);
          });
          it("'items' should return the last added item", function() {
            expect(this.$element.tagsinput('items')[0]).toBe(item2);
          });
          it("'items' should return exactly 1 item", function() {
            expect(this.$element.tagsinput('items').length).toBe(1);
          });
          it("should have exactly 1 tag", function() {
            expect($('.tag', this.$sandbox).length).toBe(1);
          });
          it("val() should return first item's value", function() {
            expect(this.$element.val()).toBe("2");
          });
        });
      });
    });

    describe("#34: Error in ReloadPage", function() {
      describe("init tagsinput with objects as items, but with value set on element", function() {
        testTagsInput('<input type="text" value="1" />', { itemValue: function(item) { return item.value; } }, function() {
          it("should have no tags", function() {
            expect(this.$element.tagsinput('items').length).toBe(0);
          });
        });

        testTagsInput('<select><option value="1" /></select>', { itemValue: function(item) { return item.value; } }, function() {
          it("should have no tags", function() {
            expect(this.$element.tagsinput('items').length).toBe(0);
          });
        });
      });
    });

    describe("#90: Error in reinitialization (arg1 and arg2 are undefined)", function() {
      describe("init tagsinput twice", function() {
        testTagsInput('<input type="text" value="1" />', { itemValue: function(item) { return item.value; } }, function() {
          it("should not fail if an element is reinitialized", function () {
            this.$element.tagsinput();
          });
          it("should return the original instance if already initialized", function () {
            return this.$element.tagsinput() === this;
          });
        });
      });
    });
    
    describe("#142: Initialization of Null Values for Multi Select field", function() {
      testTagsInput('<select multiple data-role="tagsinput"></select>', function() {
        it("Initializing an empty select shouldn't throw an error.", function() {
            $("select[multiple][data-role=tagsinput]").tagsinput();
        });
      });
    });

    describe("#128: Custom classes for tags don't work if entered as strings", function() {
      testTagsInput('<input type="text" value="1" />', { tagClass: 'big' }, function() {
        it("should have a tag with class 'big' when using tagClass option as string", function() {
            expect($(".big", this.$tagsinput).length).toBe(1);
        });
      });

      testTagsInput('<input type="text" value="1" />', { tagClass: function() { return 'big'; } }, function() {
        it("should have a tag with class 'big' when using tagClass option as function", function() {
            expect($(".big", this.$tagsinput).length).toBe(1);
        });
      });
    });

    describe("#107: Fixed bug when removing items", function() {
      testTagsInput('<input type="text" value="yes,no" />', function() {
        it("should not remove items when remove a non-existing item", function() {
            this.$element.tagsinput('remove', 'maybe');
            expect(this.$element.tagsinput('items').length).toBe(2);
        });
      });
    });
  });
});PK\�\v\H�LL input_with_string_items.tests.jsnu�[���describe("bootstrap-tagsinput", function() {

  describe("with strings as items", function() {

    testTagsInput('<input type="text" />', { trimValue: true }, function(){
      it("trim item values", function() {
        this.$element.tagsinput('add', ' some_tag  ');
        this.$element.tagsinput('add', 'some_tag  ');
        expect(this.$element.val()).toBe('some_tag');
      });
    });

    testTagsInput('<input type="text" />', function() {
      it("should hide input", function() {
        expect(this.$element.css('display')).toBe('none');
      });

      it("should add tag on when pressing ENTER", function() {
        this.$tagsinput_input.val('some_tag');
        this.$tagsinput_input.trigger($.Event('keypress', { which: 13 }));
        expect(this.$element.tagsinput('items').length).toBe(1);
      });
	  
      it("should add tag on when pressing COMMA ,", function() {
        this.$tagsinput_input.val('some_tag');
        this.$tagsinput_input.trigger($.Event('keypress', { which: 44 }));
        expect(this.$element.tagsinput('items').length).toBe(1);
      });


      describe("should not add tag", function() {
        it("when adding same item twice", function() {
          this.$element.tagsinput('add', 'some_tag');
          this.$element.tagsinput('add', 'some_tag');
          expect(this.$element.val()).toBe('some_tag');
        });

        it("when adding empty string", function() {
          this.$element.tagsinput('add', '');
          expect(this.$element.tagsinput('items').length).toBe(0);
        });

        it("when adding whitespace string", function() {
          this.$element.tagsinput('add', ' ');
          expect(this.$element.tagsinput('items').length).toBe(0);
        });

        it("when adding undefined", function() {
          this.$element.tagsinput('add', undefined);
          expect(this.$element.tagsinput('items').length).toBe(0);
        });

        it("when adding null", function() {
          this.$element.tagsinput('add', null);
          expect(this.$element.tagsinput('items').length).toBe(0);
        });
      });

      describe("should add tag", function() {
        it("when adding boolean false", function() {
          this.$element.tagsinput('add', false);
          expect(this.$element.tagsinput('items').length).toBe(1);
        });

        it("when adding boolean true", function() {
          this.$element.tagsinput('add', false);
          expect(this.$element.tagsinput('items').length).toBe(1);
        });
      });

      describe("invoke 'add' with a string", function() {
        beforeEach(function() {
          this.$element.tagsinput('add', 'some_tag');
        });

        it("val() should return 'some_tag'", function() {
          expect(this.$element.val()).toBe('some_tag');
        });

        it("'items' should return 1 item", function() {
          expect(this.$element.tagsinput('items').length).toBe(1);
        });

        describe("invoking 'remove'", function() {

          beforeEach(function() {
            this.$element.tagsinput('remove', 'some_tag');
          });

          it("val() should should return null", function() {
            expect(this.$element.val()).toBe('');
          });
        });
      });

      describe("invoke 'add' with a string containing a comma", function() {
        beforeEach(function() {
          this.$element.tagsinput('add', 'before,after');
        });

        it("val() should return 'before,after'", function() {
          expect(this.$element.val()).toBe('before,after');
        });

        it("'items' should return 2 items", function() {
          expect(this.$element.tagsinput('items').length).toBe(2);
        });
      });

      it("'focus' should place focus in input", function() {
        this.$element.tagsinput('focus');
        expect(hasFocus(this.$tagsinput_input)).toBe(true);
      });
    });

    testTagsInput('<input type="text" value="some,tags" />', function() {
      it('should have 2 tags', function() {
        expect(this.$element.tagsinput('items').length).toBe(2);
      });


      describe("invoke 'removeAll'", function() {
        beforeEach(function() {
          this.$element.tagsinput('removeAll');
        });

        it("should remove both tags", function() {
          expect(this.$element.tagsinput('items').length).toBe(0);
        });

        it("val() should return ''", function() {
          expect(this.$element.val()).toBe('');
        });
      });

      describe("BACKSPACE", function() {
        beforeEach(function() {
          this.$element.tagsinput('focus');
        });

        it('after last tag, should remove the last tag', function() {
          this.$tagsinput_input.trigger($.Event('keydown', { which: 8 }));
          expect(this.$element.tagsinput('items')[0]).toBe('some');
        });

        it('after last tag, should remove the last tag', function() {
          this.$tagsinput_input.trigger($.Event('keydown', { which: 8 }));
          expect(this.$element.tagsinput('items').length).toBe(1);
        });

        it('after first tag, should remove the first tag', function() {
          this.$tagsinput_input.trigger($.Event('keydown', { which: 37 }));
          this.$tagsinput_input.trigger($.Event('keydown', { which: 8 }));
          expect(this.$element.tagsinput('items')[0]).toBe('tags');
        });
      });

      describe("DELETE", function() {
        beforeEach(function() {
          this.$element.tagsinput('focus');
          // move cursor before last tag
          this.$tagsinput_input.trigger($.Event('keydown', { which: 37 }));
        });

        it('before last tag, should remove the last tag', function() {
          this.$tagsinput_input.trigger($.Event('keydown', { which: 46 }));
          expect(this.$element.tagsinput('items')[0]).toBe('some');
        });

        it('before last tag, should remove the last tag', function() {
          this.$tagsinput_input.trigger($.Event('keydown', { which: 46 }));
          expect(this.$element.tagsinput('items').length).toBe(1);
        });

        it('before first tag, should remove the first tag', function() {
          this.$tagsinput_input.trigger($.Event('keydown', { which: 37 }));
            this.$tagsinput_input.trigger($.Event('keydown', { which: 46 }));
          expect(this.$element.tagsinput('items')[0]).toBe('tags');
        });
      });
    });

    testTagsInput('<input type="text" value="some,tag"/>', { maxTags: 2 }, function() {
      it("should have class 'bootstrap-tagsinput-max'", function() {
        expect(this.$tagsinput.hasClass('bootstrap-tagsinput-max')).toBe(true);
      });
         
      describe("adding another tag", function() {
        it("should not add the tag", function() {
          this.$element.tagsinput('add', 'another');
          expect(this.$element.tagsinput('items').length).toBe(2);
        });
      });

      describe("removing a tags", function() {
        it("should not have class 'bootstrap-tagsinput-max'", function() {
          this.$element.tagsinput('remove', 'some');
          expect(this.$tagsinput.hasClass('bootstrap-tagsinput-max')).toBe(false);
        });
      })
    });

    testTagsInput('<input type="text" />', { confirmKeys: [9] }, function() {
      it("should add tag on when pressing TAB", function() {
        this.$tagsinput_input.val('some_tag');
        this.$tagsinput_input.trigger($.Event('keypress', { which: 9 }));
        expect(this.$element.tagsinput('items').length).toBe(1);
      });
    });
  });  
});
PK\�\s�0e��!select_with_string_items.tests.jsnu�[���describe("bootstrap-tagsinput", function() {

  describe("with strings as items", function() {

    testTagsInput("<select multiple />", function() {

      describe("when added 1 item", function() {
        beforeEach(function() {
          this.$element.tagsinput('add', 'some_tag');
        });

        it("val() should return array containing 1 item", function() {
          expect(this.$element.val()[0]).toBe('some_tag');
        });

        describe("invoking 'remove'", function() {
          beforeEach(function() {
            this.$element.tagsinput('remove', 'some_tag');
          });

          it("val() should should return null", function() {
            expect(this.$element.val()).toBeNull();
          });

          it("there should be no <option /> elements", function() {
            expect($("option", this.$sandbox).length).toBe(0);
          });
        });
      });

      describe("when added item containing a comma", function() {
        beforeEach(function() {
          this.$element.tagsinput('add', 'before,after');
        });

        it("val() should return array containing 1 item", function() {
          expect(this.$element.val()[0]).toBe('before,after');
        });
      });
    });

    testTagsInput('<select multiple><option value="some">some</option></select>', function() {
      it('should have one tag', function() {
        expect(this.$element.tagsinput('items')[0]).toBe('some');
      });
    });
  });
});PK\�\�\�|��!select_with_object_items.tests.jsnu�[���describe("bootstrap-tagsinput", function() {

  describe("with objects as items", function() {
    
    testTagsInput('<select multiple />', { itemValue: function(item) { return item.value; }, itemText: function(item) { return item.text; } }, function() {
      describe("adding an item", function() {
        var item;
        beforeEach(function() {
          item = { value: 1, text: 'some' };
          this.$element.tagsinput('add', item);
        });
        it("'items' should return the item", function() {
          expect(this.$element.tagsinput('items')[0]).toBe(item);
        });
        it("val() should return the item's value", function() {
          expect(this.$element.val()[0]).toBe("1");
        });
        it("tag's text should be the item's text", function() {
          expect($('.tag', this.$sandbox).text()).toBe("some");
        });

        describe("change item's value and text and invoke 'refesh'", function() {
          beforeEach(function() {
            item.value = 2;
            item.text = 'changed';
            this.$element.tagsinput('refresh');
          });

          it("should update tags's text", function() {
            expect($('.tag', this.$sandbox).text()).toBe('changed');
          });
          it("val() should return item's new value", function() {
            expect(this.$element.val()[0]).toBe("2");
          });
        });
      });
    });
  });
});PK\�\�ǁ''events.tests.jsnu�[���describe("bootstrap-tagsinput", function() {

  describe("events", function() {
    testTagsInput('<input type="text" />', function() {
      it("beforeItemAdd canceled", function() {
        this.$element.on('beforeItemAdd', function(event) {
          event.cancel = true;
        });
        this.$element.tagsinput('add', 'some');
        expect(this.$element.tagsinput('items').length).toBe(0);
      });
    });

    testTagsInput('<input type="text" value="1" />', function() {
      it("beforeItemRemove canceled", function() {
        this.$element.on('beforeItemRemove', function(event) {
          event.cancel = true;
        });
        this.$element.tagsinput('remove', '1');
        expect(this.$element.tagsinput('items').length).toBe(1);
      });
    });
  });
});
PK\�\���pp input_with_object_items.tests.jsnu�[���PK\�\#���II�reproduced_bugs.tests.jsnu�[���PK\�\v\H�LL Q+input_with_string_items.tests.jsnu�[���PK\�\s�0e��!�Iselect_with_string_items.tests.jsnu�[���PK\�\�\�|��!%Pselect_with_object_items.tests.jsnu�[���PK\�\�ǁ''#Vevents.tests.jsnu�[���PK)�Y