diff options
Diffstat (limited to 'js/tests/unit')
| -rw-r--r-- | js/tests/unit/button.js | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/js/tests/unit/button.js b/js/tests/unit/button.js index 724545a53..68e052e22 100644 --- a/js/tests/unit/button.js +++ b/js/tests/unit/button.js @@ -106,17 +106,19 @@ $(function () { QUnit.test('should check for closest matching toggle', function (assert) { assert.expect(12) - var groupHTML = '<div class="btn-group" data-toggle="buttons">' + - '<label class="btn btn-primary active">' + - '<input type="radio" name="options" id="option1" checked="true"> Option 1' + - '</label>' + - '<label class="btn btn-primary">' + - '<input type="radio" name="options" id="option2"> Option 2' + - '</label>' + - '<label class="btn btn-primary">' + - '<input type="radio" name="options" id="option3"> Option 3' + - '</label>' + - '</div>' + var groupHTML = + '<div class="btn-group" data-toggle="buttons">' + + ' <label class="btn btn-primary active">' + + ' <input type="radio" name="options" id="option1" checked="true"> Option 1' + + ' </label>' + + ' <label class="btn btn-primary">' + + ' <input type="radio" name="options" id="option2"> Option 2' + + ' </label>' + + ' <label class="btn btn-primary">' + + ' <input type="radio" name="options" id="option3"> Option 3' + + ' </label>' + + '</div>' + var $group = $(groupHTML).appendTo('#qunit-fixture') var $btn1 = $group.children().eq(0) @@ -126,13 +128,16 @@ $(function () { assert.ok($btn1.find('input').prop('checked'), 'btn1 is checked') assert.ok(!$btn2.hasClass('active'), 'btn2 does not have active class') assert.ok(!$btn2.find('input').prop('checked'), 'btn2 is not checked') - $btn2.find('input').trigger('click') + + EventHandler.trigger($btn2.find('input')[0], 'click') + assert.ok(!$btn1.hasClass('active'), 'btn1 does not have active class') assert.ok(!$btn1.find('input').prop('checked'), 'btn1 is not checked') assert.ok($btn2.hasClass('active'), 'btn2 has active class') assert.ok($btn2.find('input').prop('checked'), 'btn2 is checked') - $btn2.find('input').trigger('click') // Clicking an already checked radio should not un-check it + EventHandler.trigger($btn2.find('input')[0], 'click') // clicking an already checked radio should not un-check it + assert.ok(!$btn1.hasClass('active'), 'btn1 does not have active class') assert.ok(!$btn1.find('input').prop('checked'), 'btn1 is not checked') assert.ok($btn2.hasClass('active'), 'btn2 has active class') |
