bootstrap-source/bootstrap-3.0.3/js/tests/unit/button.js
changeset 115 a9d04f5f5650
parent 114 6093dda9fe38
child 116 00287f05dc6a
     1.1 --- a/bootstrap-source/bootstrap-3.0.3/js/tests/unit/button.js	Sat Jan 18 12:34:36 2014 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,122 +0,0 @@
     1.4 -$(function () {
     1.5 -
     1.6 -    module("button")
     1.7 -
     1.8 -      test("should provide no conflict", function () {
     1.9 -        var button = $.fn.button.noConflict()
    1.10 -        ok(!$.fn.button, 'button was set back to undefined (org value)')
    1.11 -        $.fn.button = button
    1.12 -      })
    1.13 -
    1.14 -      test("should be defined on jquery object", function () {
    1.15 -        ok($(document.body).button, 'button method is defined')
    1.16 -      })
    1.17 -
    1.18 -      test("should return element", function () {
    1.19 -        ok($(document.body).button()[0] == document.body, 'document.body returned')
    1.20 -      })
    1.21 -
    1.22 -      test("should return set state to loading", function () {
    1.23 -        var btn = $('<button class="btn" data-loading-text="fat">mdo</button>')
    1.24 -        equal(btn.html(), 'mdo', 'btn text equals mdo')
    1.25 -        btn.button('loading')
    1.26 -        equal(btn.html(), 'fat', 'btn text equals fat')
    1.27 -        stop()
    1.28 -        setTimeout(function () {
    1.29 -          ok(btn.attr('disabled'), 'btn is disabled')
    1.30 -          ok(btn.hasClass('disabled'), 'btn has disabled class')
    1.31 -          start()
    1.32 -        }, 0)
    1.33 -      })
    1.34 -
    1.35 -      test("should return reset state", function () {
    1.36 -        var btn = $('<button class="btn" data-loading-text="fat">mdo</button>')
    1.37 -        equal(btn.html(), 'mdo', 'btn text equals mdo')
    1.38 -        btn.button('loading')
    1.39 -        equal(btn.html(), 'fat', 'btn text equals fat')
    1.40 -        stop()
    1.41 -        setTimeout(function () {
    1.42 -          ok(btn.attr('disabled'), 'btn is disabled')
    1.43 -          ok(btn.hasClass('disabled'), 'btn has disabled class')
    1.44 -          start()
    1.45 -          stop()
    1.46 -          btn.button('reset')
    1.47 -          equal(btn.html(), 'mdo', 'btn text equals mdo')
    1.48 -          setTimeout(function () {
    1.49 -            ok(!btn.attr('disabled'), 'btn is not disabled')
    1.50 -            ok(!btn.hasClass('disabled'), 'btn does not have disabled class')
    1.51 -            start()
    1.52 -          }, 0)
    1.53 -        }, 0)
    1.54 -
    1.55 -      })
    1.56 -
    1.57 -      test("should toggle active", function () {
    1.58 -        var btn = $('<button class="btn">mdo</button>')
    1.59 -        ok(!btn.hasClass('active'), 'btn does not have active class')
    1.60 -        btn.button('toggle')
    1.61 -        ok(btn.hasClass('active'), 'btn has class active')
    1.62 -      })
    1.63 -
    1.64 -      test("should toggle active when btn children are clicked", function () {
    1.65 -        var btn = $('<button class="btn" data-toggle="button">mdo</button>')
    1.66 -          , inner = $('<i></i>')
    1.67 -        btn
    1.68 -          .append(inner)
    1.69 -          .appendTo($('#qunit-fixture'))
    1.70 -        ok(!btn.hasClass('active'), 'btn does not have active class')
    1.71 -        inner.click()
    1.72 -        ok(btn.hasClass('active'), 'btn has class active')
    1.73 -      })
    1.74 -
    1.75 -      test("should toggle active when btn children are clicked within btn-group", function () {
    1.76 -        var btngroup = $('<div class="btn-group" data-toggle="buttons"></div>')
    1.77 -          , btn = $('<button class="btn">fat</button>')
    1.78 -          , inner = $('<i></i>')
    1.79 -        btngroup
    1.80 -          .append(btn.append(inner))
    1.81 -          .appendTo($('#qunit-fixture'))
    1.82 -        ok(!btn.hasClass('active'), 'btn does not have active class')
    1.83 -        inner.click()
    1.84 -        ok(btn.hasClass('active'), 'btn has class active')
    1.85 -      })
    1.86 -
    1.87 -      test("should check for closest matching toggle", function () {
    1.88 -        var group = '<div class="btn-group" data-toggle="buttons">' +
    1.89 -          '<label class="btn btn-primary active">' +
    1.90 -            '<input type="radio" name="options" id="option1" checked="true"> Option 1' +
    1.91 -          '</label>' +
    1.92 -          '<label class="btn btn-primary">' +
    1.93 -            '<input type="radio" name="options" id="option2"> Option 2' +
    1.94 -          '</label>' +
    1.95 -          '<label class="btn btn-primary">' +
    1.96 -            '<input type="radio" name="options" id="option3"> Option 3' +
    1.97 -          '</label>' +
    1.98 -        '</div>'
    1.99 -
   1.100 -        group = $(group)
   1.101 -
   1.102 -        var btn1 = $(group.children()[0])
   1.103 -        var btn2 = $(group.children()[1])
   1.104 -        var btn3 = $(group.children()[2])
   1.105 -
   1.106 -        group.appendTo($('#qunit-fixture'))
   1.107 -
   1.108 -        ok(btn1.hasClass('active'), 'btn1 has active class')
   1.109 -        ok(btn1.find('input').prop('checked'), 'btn1 is checked')
   1.110 -        ok(!btn2.hasClass('active'), 'btn2 does not have active class')
   1.111 -        ok(!btn2.find('input').prop('checked'), 'btn2 is not checked')
   1.112 -        btn2.find('input').click()
   1.113 -        ok(!btn1.hasClass('active'), 'btn1 does not have active class')
   1.114 -        ok(!btn1.find('input').prop('checked'), 'btn1 is checked')
   1.115 -        ok(btn2.hasClass('active'), 'btn2 has active class')
   1.116 -        ok(btn2.find('input').prop('checked'), 'btn2 is checked')
   1.117 -
   1.118 -        btn2.find('input').click() /* clicking an already checked radio should not un-check it */
   1.119 -        ok(!btn1.hasClass('active'), 'btn1 does not have active class')
   1.120 -        ok(!btn1.find('input').prop('checked'), 'btn1 is checked')
   1.121 -        ok(btn2.hasClass('active'), 'btn2 has active class')
   1.122 -        ok(btn2.find('input').prop('checked'), 'btn2 is checked')
   1.123 -      })
   1.124 -
   1.125 -})
Impressum Datenschutzerklärung