123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651 |
- describe('Bootstrap Multiselect "Core".', function() {
- beforeEach(function() {
- var $select = $('<select id="multiselect" multiple="multiple"></select>');
-
- for (var i = 1; i < 100; i++) {
- var $option = $('<option value="' + i + '">' + i + '</option>');
-
- if (i < 10) {
- $option.prop('selected', true);
- }
-
- $select.append($option);
- }
-
- $('body').append($select);
-
- $select.multiselect({
- buttonContainer: '<div id="multiselect-container"></div>'
- });
- });
-
- it('Should add the container after the select.', function() {
- expect($('#multiselect-container').length).toBe(1);
- });
-
- it('Should add the multiselect button.', function() {
- expect($('#multiselect-container .multiselect').length).toBe(1);
- });
-
- it('Should add the dropdown menu.', function() {
- expect($('#multiselect-container .dropdown-menu').length).toBe(1);
- });
-
- it('Should add an li element with checkbox and label for each option.', function() {
- expect($('#multiselect-container li').length).toBe(99);
- expect($('#multiselect-container label').length).toBe(99);
- expect($('#multiselect-container input[type="checkbox"]').length).toBe(99);
- });
-
- it('Should preserve selected options.', function() {
- expect($('#multiselect-container input[type="checkbox"]:checked').length).toBe(9);
- expect($('#multiselect option:selected').length).toBe(9);
- });
-
- it('Should be able to select options by value.', function() {
- $('#multiselect').multiselect('select', '10');
-
- expect($('#multiselect option[value="10"]').prop('selected')).toBe(true);
- expect($('#multiselect-container input[value="10"]').prop('checked')).toBe(true);
- });
-
- it('Select method should handle "null" and "undefined" correctly.', function() {
- expect($('#multiselect option:selected').length).toBe(9);
-
- $('#multiselect').multiselect('select', null);
- expect($('#multiselect option:selected').length).toBe(9);
-
- $('#multiselect').multiselect('select', undefined);
- expect($('#multiselect option:selected').length).toBe(9);
- });
-
- it('Should be able to deselect options by value.', function() {
- $('#multiselect').multiselect('select', '10');
- $('#multiselect').multiselect('deselect', '10');
-
- expect($('#multiselect option[value="10"]').prop('selected')).toBe(false);
- expect($('#multiselect-container input[value="10"]').prop('checked')).toBe(false);
- });
-
- it('Deselect method should handle "null" and "undefined" correctly.', function() {
- expect($('#multiselect option:selected').length).toBe(9);
-
- $('#multiselect').multiselect('deselect', null);
- expect($('#multiselect option:selected').length).toBe(9);
-
- $('#multiselect').multiselect('deselect', undefined);
- expect($('#multiselect option:selected').length).toBe(9);
- });
-
- it('Should be able to select options using an array of values.', function() {
- $('#multiselect').multiselect('select', ['10', '11']);
-
- expect($('#multiselect option[value="10"]').prop('selected')).toBe(true);
- expect($('#multiselect-container input[value="10"]').prop('checked')).toBe(true);
-
- expect($('#multiselect option[value="11"]').prop('selected')).toBe(true);
- expect($('#multiselect-container input[value="11"]').prop('checked')).toBe(true);
- });
-
- it('Should be able to deselect options using an array of values.', function() {
- $('#multiselect').multiselect('select', ['10', '11']);
- $('#multiselect').multiselect('deselect', ['10', '11']);
-
- expect($('#multiselect option[value="10"]').prop('selected')).toBe(false);
- expect($('#multiselect-container input[value="10"]').prop('checked')).toBe(false);
-
- expect($('#multiselect option[value="11"]').prop('selected')).toBe(false);
- expect($('#multiselect-container input[value="11"]').prop('checked')).toBe(false);
- });
-
- it('Should be able to disable the multiselect', function() {
- $('#multiselect').multiselect('disable');
-
- expect($('#multiselect').prop('disabled')).toBe(true);
- });
-
- it('Should be able to enable the multiselect', function() {
- $('#multiselect').multiselect('disable');
- $('#multiselect').multiselect('enable');
-
- expect($('#multiselect').prop('disabled')).toBe(false);
- });
-
- it('Should be able to select all options.', function() {
- $('#multiselect').multiselect('selectAll');
-
- for (var i = 1; i < 100; i++) {
- expect($('#multiselect option[value="' + i.toString() + '"]').prop('selected')).toBe(true);
- expect($('#multiselect-container input[value="' + i.toString() + '"]').prop('checked')).toBe(true);
- }
- });
-
- it('Should be able to deselect all options.', function() {
- $('#multiselect').multiselect('selectAll');
-
- for (var i = 1; i < 100; i++) {
- expect($('#multiselect option[value="' + i.toString() + '"]').prop('selected')).toBe(true);
- expect($('#multiselect-container input[value="' + i.toString() + '"]').prop('checked')).toBe(true);
- }
-
- $('#multiselect').multiselect('deselectAll');
-
- for (var i = 1; i < 100; i++) {
- expect($('#multiselect option[value="' + i.toString() + '"]').prop('selected')).toBe(false);
- expect($('#multiselect-container input[value="' + i.toString() + '"]').prop('checked')).toBe(false);
- }
- });
-
- it('Should update the checkboxes according to the selected options after using refresh.', function() {
- for (var i = 10; i < 20; i++) {
- $('#multiselect option[value="' + i + '"]').prop('selected', true);
- }
-
- expect($('#multiselect option:selected').length).toBe(19);
- expect($('#multiselect-container input[type="checkbox"]:checked').length).toBe(9);
-
- $('#multiselect').multiselect('refresh');
-
- expect($('#multiselect-container input[type="checkbox"]:checked').length).toBe(19);
-
- for (var i = 10; i < 20; i++) {
- expect($('#multiselect option[value="' + i + '"]').prop('selected')).toBe(true);
- }
- });
-
- it('Should remove container, button and ul after destroy.', function() {
- $('#multiselect').multiselect('destroy');
-
- // Destroy should remove container, button and ul.
- expect($('#multiselect-container.multiselect-container').length).toBe(0);
- expect($('#multiselect-container .multiselect').length).toBe(0);
- expect($('#multiselect-container .dropdown-menu').length).toBe(0);
- });
-
- it('Should select an option when checkbox is changed (change event).', function() {
- $('#multiselect-container li input[value="10"]').prop('checked', true);
- $('#multiselect-container li input[value="10"]').trigger('change');
-
- expect($('#multiselect-container input[value="10"]').prop('checked')).toBe(true);
- expect($('#multiselect option[value="10"]').prop('selected')).toBe(true);
- });
-
- it('Should deselect an option when checkbox is changed (change event).', function() {
- $('#multiselect-container li input[value="10"]').prop('checked', true);
- $('#multiselect-container li input[value="10"]').trigger('change');
-
- // Already checked above.
-
- $('#multiselect-container li input[value="10"]').prop('checked', false);
- $('#multiselect-container li input[value="10"]').trigger('change');
-
- expect($('#multiselect-container input[value="10"]').prop('checked')).toBe(false);
- expect($('#multiselect option[value="10"]').prop('selected')).toBe(false);
- });
-
- it('Should select an option when checkbox is clicked.', function() {
- $('#multiselect-container li input[value="10"]').click();
-
- expect($('#multiselect-container input[value="10"]').prop('checked')).toBe(true);
- expect($('#multiselect option[value="10"]').prop('selected')).toBe(true);
- });
-
- it('Should deselect an option when checkbox is clicked.', function() {
- $('#multiselect-container li input[value="10"]').click();
- $('#multiselect-container li input[value="10"]').click();
-
- expect($('#multiselect-container input[value="10"]').prop('checked')).toBe(false);
- expect($('#multiselect option[value="10"]').prop('selected')).toBe(false);
- });
-
- afterEach(function() {
- $('#multiselect').multiselect('destroy');
- $('#multiselect').remove();
- });
- });
-
- describe('Bootstrap Multiselect "Single Selection"', function() {
- beforeEach(function() {
- var $select = $('<select id="multiselect"></select>');
-
- for (var i = 1; i < 100; i++) {
- $select.append('<option value="' + i + '">Option ' + i + '</option>');
- }
-
- $('body').append($select);
-
- $select.multiselect({
- buttonContainer: '<div id="multiselect-container"></div>'
- });
- });
-
- it('Should create radio buttons instead of checkboxes.', function() {
- expect($('#multiselect-container input[type="radio"]').length).toBe(99);
- expect($('#multiselect-container input[type="checkbox"]').length).toBe(0);
-
- // Browser selects one option per default.
- expect($('#multiselect option:selected').length).toBe(1);
- });
-
- it('Only one option at a time can be selected.', function() {
- expect($('#multiselect option:selected').length).toBe(1);
-
- var i = 0;
- $('#multiselect-container input').each(function() {
- if (i === 0) {
- expect($(this).prop('checked')).toBe(true);
- i++;
- }
- else {
- expect($(this).prop('checked')).toBe(false);
- $(this).click();
-
- expect($('#multiselect option:selected').length).toBe(1);
- expect($(this).prop('checked')).toBe(true);
- i++;
- }
- });
- });
-
- afterEach(function() {
- $('#multiselect').multiselect('destroy');
- $('#multiselect').remove();
- });
- });
-
- describe('Bootstrap Multiselect "Optgroups"', function() {
- beforeEach(function() {
- var $select = $('<select id="multiselect" multiple="multiple"></select>');
-
- for (var i = 1; i < 11; i++) {
- var $optgroup = $('<optgroup label="Group ' + i + '"></optgroup>');
-
- for (var j = 1; j < 11; j++) {
- $optgroup.append('<option value="' + i + '-' + j + '">Option ' + i + '.' + j + '</option>');
- }
-
- $select.append($optgroup);
- }
-
- $('body').append($select);
-
- $select.multiselect({
- buttonContainer: '<div id="multiselect-container"></div>',
- enableClickableOptGroups: true
- });
- });
-
- it('Should correctly create labels for optgroups.', function() {
- expect($('#multiselect-container li.multiselect-group').length).toBe(10);
- expect($('#multiselect-container li.multiselect-group-clickable').length).toBe(10);
-
- $('#multiselect-container label.multiselect-group').each(function() {
- expect($('input', $(this)).length).toBe(10);
- });
- });
-
- it('Groups should be clickable.', function() {
- expect($('#multiselect option:selected').length).toBe(0);
-
- var i = 0;
- $('#multiselect-container li.multiselect-group').each(function() {
- $('label', $(this)).click();
- expect($('option:selected', $('#multiselect optgroup')[i]).length).toBe(10);
- expect($('#multiselect option:selected').length).toBe(10);
-
- $('label', $(this)).click();
- i++;
- });
- });
-
- afterEach(function() {
- $('#multiselect').multiselect('destroy');
- $('#multiselect').remove();
- });
- });
-
- describe('Bootstrap Multiselect "Dataprovider"', function() {
- beforeEach(function() {
- var $select = $('<select id="multiselect" multiple="multiple"></select>');
-
- $('body').append($select);
-
- $select.multiselect({
- buttonContainer: '<div id="multiselect-container"></div>'
- });
- });
-
- var options = [
- {label: 'Option 1', value: '1', selected: true, title: 'Option 1 Title'},
- {label: 'Option 2', value: '2', title: 'Option 2 Title'},
- {label: 'Option 3', value: '3', selected: true, title: 'Option 3 Title'},
- {label: 'Option 4', value: '4', title: 'Option 4 Title'},
- {label: 'Option 5', value: '5', title: 'Option 5 Title'},
- {label: 'Option 6', value: '6', title: 'Option 6 Title'}
- ];
-
- it("Should be able to add options.", function() {
- $('#multiselect').multiselect('dataprovider', options);
- expect($('#multiselect option').length).toBe(6);
- expect($('#multiselect-container input').length).toBe(6);
-
- expect($('#multiselect option[value="1"]').length).toBe(1);
- expect($('#multiselect option[value="1"]').prop('selected')).toBe(true);
- expect($('#multiselect-container input[value="1"]').prop('checked')).toBe(true);
-
- expect($('#multiselect option[value="2"]').length).toBe(1);
- expect($('#multiselect option[value="2"]').prop('selected')).toBe(false);
- expect($('#multiselect-container input[value="2"]').prop('checked')).toBe(false);
-
- expect($('#multiselect option[value="3"]').length).toBe(1);
- expect($('#multiselect option[value="3"]').prop('selected')).toBe(true);
- expect($('#multiselect-container input[value="3"]').prop('checked')).toBe(true);
-
- expect($('#multiselect option[value="4"]').length).toBe(1);
- expect($('#multiselect option[value="4"]').prop('selected')).toBe(false);
- expect($('#multiselect-container input[value="4"]').prop('checked')).toBe(false);
-
- expect($('#multiselect option[value="5"]').length).toBe(1);
- expect($('#multiselect option[value="5"]').prop('selected')).toBe(false);
- expect($('#multiselect-container input[value="5"]').prop('checked')).toBe(false);
-
- expect($('#multiselect option[value="6"]').length).toBe(1);
- expect($('#multiselect option[value="6"]').prop('selected')).toBe(false);
- expect($('#multiselect-container input[value="6"]').prop('checked')).toBe(false);
- });
-
- it("Should be able to define title.", function() {
- $('#multiselect').multiselect('dataprovider', options);
-
- expect($('#multiselect option[value="1"]').attr('title')).toBe('Option 1 Title');
- expect($('#multiselect option[value="2"]').attr('title')).toBe('Option 2 Title');
- expect($('#multiselect option[value="3"]').attr('title')).toBe('Option 3 Title');
- expect($('#multiselect option[value="4"]').attr('title')).toBe('Option 4 Title');
- expect($('#multiselect option[value="5"]').attr('title')).toBe('Option 5 Title');
- expect($('#multiselect option[value="6"]').attr('title')).toBe('Option 6 Title');
-
- expect($('#multiselect-container input[value="1"]').closest('label').attr('title')).toBe('Option 1 Title');
- expect($('#multiselect-container input[value="2"]').closest('label').attr('title')).toBe('Option 2 Title');
- expect($('#multiselect-container input[value="3"]').closest('label').attr('title')).toBe('Option 3 Title');
- expect($('#multiselect-container input[value="4"]').closest('label').attr('title')).toBe('Option 4 Title');
- expect($('#multiselect-container input[value="5"]').closest('label').attr('title')).toBe('Option 5 Title');
- expect($('#multiselect-container input[value="6"]').closest('label').attr('title')).toBe('Option 6 Title');
- });
-
- var optgroups = [
- {
- label: 'Group 1', children: [
- {label: 'Option 1.1', value: '1-1'},
- {label: 'Option 1.2', value: '1-2'},
- {label: 'Option 1.3', value: '1-3'}
- ]
- },
- {
- label: 'Group 2', children: [
- {label: 'Option 2.1', value: '1'},
- {label: 'Option 2.2', value: '2'},
- {label: 'Option 2.3', value: '3'}
- ]
- }
- ];
-
- it('Should be able to handle optgroups.', function() {
- $('#multiselect').multiselect('dataprovider', optgroups);
-
- expect($('#multiselect optgroup').length).toBe(2);
- expect($('#multiselect option').length).toBe(6);
- expect($('#multiselect-container input').length).toBe(6);
-
- expect($('#multiselect optgroup[label="Group 1"] option').length).toBe(3);
- expect($('#multiselect optgroup[label="Group 2"] option').length).toBe(3);
- });
-
- afterEach(function() {
- $('#multiselect').multiselect('destroy');
- $('#multiselect').remove();
- });
- });
-
- describe('Bootstrap Multiselect "Select All".', function() {
-
- var onSelectAllTriggered = false;
- var onDeselectAllTriggered = false;
-
- beforeEach(function() {
- var $select = $('<select id="multiselect" multiple="multiple"></select>');
-
- for (var i = 1; i < 100; i++) {
- $select.append('<option value="' + i + '">1</option>');
- }
-
- $('body').append($select);
-
- $select.multiselect({
- buttonContainer: '<div id="multiselect-container"></div>',
- includeSelectAllOption: true,
- selectAllValue: 'multiselect-all',
- onSelectAll: function() {
- onSelectAllTriggered = true;
- },
- onDeselectAll: function() {
- onDeselectAllTriggered = true;
- }
- });
- });
-
- it('Should not add an additional option to the select.', function() {
- expect($('#multiselect option[value="multiselect-all"]').length).toBe(0);
- expect($('#multiselect-container input[value="multiselect-all"]').length).toBe(1);
- expect($('#multiselect option').length).toBe(99);
- expect($('#multiselect-container input').length).toBe(100);
- });
-
- it('Should update the select all when all options are selected by the "select" method.', function() {
- expect($('#multiselect option:selected').length).toBe(0);
- expect($('#multiselect-container input[value="multiselect-all"]').prop('checked')).toBe(false);
-
- for (var i = 1; i < 100; i++) {
- $('#multiselect').multiselect('select', i.toString());
- expect($('#multiselect option[value="' + i.toString() + '"]').prop('selected')).toBe(true);
- }
-
- expect($('#multiselect option:selected').length).toBe(99);
- expect($('#multiselect-container input').length).toBe(100);
- expect($('#multiselect-container input[value="multiselect-all"]').prop('checked')).toBe(true);
- });
-
- it('Should update the select all when all options are deselected by the "deselect" method (first all options are selected as before).', function() {
- expect($('#multiselect option:selected').length).toBe(0);
- expect($('#multiselect-container input[value="multiselect-all"]').prop('checked')).toBe(false);
-
- for (var i = 1; i < 100; i++) {
- $('#multiselect').multiselect('select', i.toString());
- }
-
- expect($('#multiselect option:selected').length).toBe(99);
- expect($('#multiselect-container input:checked').length).toBe(100);
- expect($('#multiselect-container input[value="multiselect-all"]').prop('checked')).toBe(true);
-
- for (var i = 1; i < 100; i++) {
- $('#multiselect').multiselect('deselect', i.toString());
- }
-
- expect($('#multiselect option:selected').length).toBe(0);
- expect($('#multiselect-container input[value="multiselect-all"]').prop('checked')).toBe(false);
- });
-
- it('Should update the select all option when all options are selected by the change event.', function() {
- expect($('#multiselect option:selected').length).toBe(0);
- expect($('#multiselect-container input[value="multiselect-all"]').prop('checked')).toBe(false);
-
- // Change all checkboxes except the select all one.
- $('#multiselect-container input[value!="multiselect-all"]').prop('checked', true);
- $('#multiselect-container input[value!="multiselect-all"]').trigger('change');
-
- expect($('#multiselect option:selected[value!="multiselect-all"]').length).toBe(99);
-
- // 100 options seleted including the select all.
- expect($('#multiselect option:selected').length).toBe(99);
- expect($('#multiselect-container input[value="multiselect-all"]').prop('checked')).toBe(true);
- });
-
- it('Should update the select all option when all options are deselected by the change event.', function() {
- expect($('#multiselect option:selected').length).toBe(0);
- expect($('#multiselect-container input[value="multiselect-all"]').prop('checked')).toBe(false);
-
- $('#multiselect-container input[value!="multiselect-all"]').prop('checked', true);
- $('#multiselect-container input[value!="multiselect-all"]').trigger('change');
-
- expect($('#multiselect option:selected[value!="multiselect-all"]').length).toBe(99);
-
- expect($('#multiselect option:selected').length).toBe(99);
- expect($('#multiselect-container input[value="multiselect-all"]').prop('checked')).toBe(true);
-
- // Change all checkboxes except the select all one.
- $('#multiselect-container input[value!="multiselect-all"]').prop('checked', false);
- $('#multiselect-container input[value!="multiselect-all"]').trigger('change');
-
- expect($('#multiselect option:selected').length).toBe(0);
- expect($('#multiselect-container input[value="multiselect-all"]').prop('checked')).toBe(false);
- });
-
- it('Should update the select all option when all options are selected by the click event.', function() {
- expect($('#multiselect option:selected').length).toBe(0);
- expect($('#multiselect-container input[value="multiselect-all"]').prop('checked')).toBe(false);
-
- $('#multiselect-container input[value!="multiselect-all"]').click();
-
- expect($('#multiselect option:selected').length).toBe(99);
- expect($('#multiselect-container input[value="multiselect-all"]').prop('checked')).toBe(true);
- });
-
- it('Should update the select all option when all options are deselected by the click event.', function() {
- expect($('#multiselect option:selected').length).toBe(0);
- expect($('#multiselect-container input[value="multiselect-all"]').prop('checked')).toBe(false);
-
- $('#multiselect-container input[value!="multiselect-all"]').click();
-
- expect($('#multiselect option:selected').length).toBe(99);
- expect($('#multiselect-container input[value="multiselect-all"]').prop('checked')).toBe(true);
-
- $('#multiselect-container input[value!="multiselect-all"]').click();
-
- expect($('#multiselect option:selected').length).toBe(0);
- expect($('#multiselect-container input[value="multiselect-all"]').prop('checked')).toBe(false);
- });
-
- it('Should trigger onSelectAll based on the change event.', function() {
- expect($('#multiselect option:selected').length).toBe(0);
- expect($('#multiselect-container input[value="multiselect-all"]').prop('checked')).toBe(false);
-
- // Change all checkboxes except the select all one.
- $('#multiselect-container input[value!="multiselect-all"]').prop('checked', true);
- $('#multiselect-container input[value!="multiselect-all"]').trigger('change');
-
- expect($('#multiselect option:selected[value!="multiselect-all"]').length).toBe(99);
-
- // 100 options seleted including the select all.
- expect($('#multiselect option:selected').length).toBe(99);
- expect($('#multiselect-container input[value="multiselect-all"]').prop('checked')).toBe(true);
-
- expect(onSelectAllTriggered).toBe(true);
- });
-
- it('Should trigger onSelectAll based on the click event.', function() {
- expect($('#multiselect option:selected').length).toBe(0);
- expect($('#multiselect-container input[value="multiselect-all"]').prop('checked')).toBe(false);
-
- $('#multiselect-container input[value!="multiselect-all"]').click();
-
- expect($('#multiselect option:selected').length).toBe(99);
- expect($('#multiselect-container input[value="multiselect-all"]').prop('checked')).toBe(true);
-
- expect(onSelectAllTriggered).toBe(true);
- });
-
- it('Should trigger onSelectAll on function call.', function() {
- $('#multiselect').multiselect('selectAll', true, true);
- expect(onSelectAllTriggered).toBe(true);
- });
-
- afterEach(function() {
- $('#multiselect').multiselect('destroy');
- $('#multiselect').remove();
- });
- });
-
- describe('Bootstrap Multiselect Specific Issues', function() {
-
- it('#393', function() {
- var $select = $('<select id="multiselect" multiple="multiple"></select>');
-
- for (var i = 1; i < 100; i++) {
- $select.append('<option value="' + i + '">1</option>');
- }
-
- $('body').append($select);
-
- $select.multiselect({
- buttonContainer: '<div id="multiselect-container"></div>',
- includeSelectAllOption: true,
- selectAllValue: 0
- });
-
- expect($('#multiselect-container input[value="0"]').length).toBe(1);
- expect($('#multiselect-container input[value="0"]').prop('checked')).toBe(false);
-
- $('#multiselect').multiselect('selectAll');
-
- expect($('#multiselect option:selected').length).toBe(99);
- expect($('#multiselect-container input[value="0"]').prop('checked')).toBe(true);
-
- $('#multiselect').multiselect('deselectAll');
-
- expect($('#multiselect option:selected').length).toBe(0);
- expect($('#multiselect-container input[value="0"]').prop('checked')).toBe(false);
-
- $('#multiselect-container input[value="0"]').click();
-
- expect($('#multiselect option:selected').length).toBe(99);
- expect($('#multiselect-container input[value="0"]').prop('checked')).toBe(true);
-
- $('#multiselect-container input[value="0"]').click();
-
- expect($('#multiselect option:selected').length).toBe(0);
- expect($('#multiselect-container input[value="0"]').prop('checked')).toBe(false);
-
- $('#multiselect').multiselect('destroy');
- $('#multiselect').remove();
- });
-
- it('#405', function() {
- var selection = document.getSelection();
- var range = document.createRange();
- var $selection = $('<span>Some text to select</span>');
- var $select = $('<select id="multiselect" multiple="multiple"></select>');
-
- for (var i = 1; i < 5; i++) {
- $select.append('<option value="' + i + '">select option</option>');
- }
-
- $('body').append($selection).append($select);
-
- $select.multiselect({
- buttonContainer: '<div id="multiselect-container"></div>',
- });
-
- range.selectNodeContents($selection.get(0));
-
- selection.removeAllRanges();
- selection.addRange(range);
-
- if (document.getSelection().type === 'Range') {
- $('#multiselect-container').find('a:first label').trigger('click');
- expect($('#multiselect-container').find('input:first').prop('checked')).toBe(true);
- }
-
- $('#multiselect').multiselect('destroy');
- $('#multiselect').remove();
- $selection.remove();
- });
- });
|