diff options
| author | XhmikosR <[email protected]> | 2017-08-21 14:49:41 +0300 |
|---|---|---|
| committer | XhmikosR <[email protected]> | 2019-02-20 22:05:45 +0200 |
| commit | aba87279fd849435d00818532b312a977392ef24 (patch) | |
| tree | a1c642f66e5aed24c17298e54867a3d9eebf9be7 /js/tests | |
| parent | 47242cd0fea278001dda666f9aafd5d8bcb3513a (diff) | |
| download | bootstrap-aba87279fd849435d00818532b312a977392ef24.tar.xz bootstrap-aba87279fd849435d00818532b312a977392ef24.zip | |
button without jquery
Diffstat (limited to 'js/tests')
| -rw-r--r-- | js/tests/unit/button.js | 31 | ||||
| -rw-r--r-- | js/tests/visual/button.html | 2 |
2 files changed, 20 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') diff --git a/js/tests/visual/button.html b/js/tests/visual/button.html index 818160da3..774e755eb 100644 --- a/js/tests/visual/button.html +++ b/js/tests/visual/button.html @@ -46,6 +46,8 @@ <script src="../../../node_modules/jquery/dist/jquery.slim.min.js"></script> <script src="../../dist/dom/eventHandler.js"></script> + <script src="../../dist/dom/selectorEngine.js"></script> + <script src="../../dist/dom/data.js"></script> <script src="../../dist/util.js"></script> <script src="../../dist/button.js"></script> </body> |
