$(function () {

  module('popover')

  test('should provide no conflict', function () {
    var popover = $.fn.popover.noConflict()
    ok(!$.fn.popover, 'popover was set back to undefined (org value)')
    $.fn.popover = popover
  })

  test('should be defined on jquery object', function () {
    var div = $('<div></div>')
    ok(div.popover, 'popover method is defined')
  })

  test('should return element', function () {
    var div = $('<div></div>')
    ok(div.popover() == div, 'document.body returned')
  })

  test('should render popover element', function () {
    $.support.transition = false
    var popover = $('<a href="#" title="mdo" data-content="http://twitter.com/mdo">@mdo</a>')
      .appendTo('#qunit-fixture')
      .popover('show')

    ok($('.popover').length, 'popover was inserted')
    popover.popover('hide')
    ok(!$('.popover').length, 'popover removed')
  })

  test('should store popover instance in popover data object', function () {
    $.support.transition = false
    var popover = $('<a href="#" title="mdo" data-content="http://twitter.com/mdo">@mdo</a>')
      .popover()

    ok(!!popover.data('bs.popover'), 'popover instance exists')
  })

  test('should get title and content from options', function () {
    $.support.transition = false
    var popover = $('<a href="#">@fat</a>')
      .appendTo('#qunit-fixture')
      .popover({
        title: function () {
          return '@fat'
        },
        content: function () {
          return 'loves writing tests （╯°□°）╯︵ ┻━┻'
        }
      })

    popover.popover('show')

    ok($('.popover').length, 'popover was inserted')
    equal($('.popover .popover-title').text(), '@fat', 'title correctly inserted')
    equal($('.popover .popover-content').text(), 'loves writing tests （╯°□°）╯︵ ┻━┻', 'content correctly inserted')

    popover.popover('hide')
    ok(!$('.popover').length, 'popover was removed')
    $('#qunit-fixture').empty()
  })

  test('should get title and content from attributes', function () {
    $.support.transition = false
    var popover = $('<a href="#" title="@mdo" data-content="loves data attributes (づ｡◕‿‿◕｡)づ ︵ ┻━┻" >@mdo</a>')
      .appendTo('#qunit-fixture')
      .popover()
      .popover('show')

    ok($('.popover').length, 'popover was inserted')
    equal($('.popover .popover-title').text(), '@mdo', 'title correctly inserted')
    equal($('.popover .popover-content').text(), 'loves data attributes (づ｡◕‿‿◕｡)づ ︵ ┻━┻', 'content correctly inserted')

    popover.popover('hide')
    ok(!$('.popover').length, 'popover was removed')
    $('#qunit-fixture').empty()
  })


  test('should get title and content from attributes #2', function () {
    $.support.transition = false
    var popover = $('<a href="#" title="@mdo" data-content="loves data attributes (づ｡◕‿‿◕｡)づ ︵ ┻━┻" >@mdo</a>')
      .appendTo('#qunit-fixture')
      .popover({
        title: 'ignored title option',
        content: 'ignored content option'
      })
      .popover('show')

    ok($('.popover').length, 'popover was inserted')
    equal($('.popover .popover-title').text(), '@mdo', 'title correctly inserted')
    equal($('.popover .popover-content').text(), 'loves data attributes (づ｡◕‿‿◕｡)づ ︵ ┻━┻', 'content correctly inserted')

    popover.popover('hide')
    ok(!$('.popover').length, 'popover was removed')
    $('#qunit-fixture').empty()
  })

  test('should respect custom classes', function () {
    $.support.transition = false
    var popover = $('<a href="#">@fat</a>')
      .appendTo('#qunit-fixture')
      .popover({
        title: 'Test',
        content: 'Test',
        template: '<div class="popover foobar"><div class="arrow"></div><div class="inner"><h3 class="title"></h3><div class="content"><p></p></div></div></div>'
      })

    popover.popover('show')

    ok($('.popover').length, 'popover was inserted')
    ok($('.popover').hasClass('foobar'), 'custom class is present')

    popover.popover('hide')
    ok(!$('.popover').length, 'popover was removed')
    $('#qunit-fixture').empty()
  })

  test('should destroy popover', function () {
    var popover = $('<div/>').popover({trigger: 'hover'}).on('click.foo', function () {})
    ok(popover.data('bs.popover'), 'popover has data')
    ok($._data(popover[0], 'events').mouseover && $._data(popover[0], 'events').mouseout, 'popover has hover event')
    ok($._data(popover[0], 'events').click[0].namespace == 'foo', 'popover has extra click.foo event')
    popover.popover('show')
    popover.popover('destroy')
    ok(!popover.hasClass('in'), 'popover is hidden')
    ok(!popover.data('popover'), 'popover does not have data')
    ok($._data(popover[0],'events').click[0].namespace == 'foo', 'popover still has click.foo')
    ok(!$._data(popover[0], 'events').mouseover && !$._data(popover[0], 'events').mouseout, 'popover does not have any events')
  })

})

@@ -1933,32 +1933,890 @@
 ).empty()%0A  %7D)%0A%0A
+  test('should not duplicate HTML object', function () %7B%0A    $.support.transition = false%0A%0A    $div = $('%3Cdiv%3E').html('loves writing tests %EF%BC%88%E2%95%AF%C2%B0%E2%96%A1%C2%B0%EF%BC%89%E2%95%AF%EF%B8%B5 %E2%94%BB%E2%94%81%E2%94%BB')%0A%0A    var popover = $('%3Ca href=%22#%22%3E@fat%3C/a%3E')%0A      .appendTo('#qunit-fixture')%0A      .popover(%7B%0A        content: function () %7B%0A          return $div%0A        %7D%0A      %7D)%0A%0A    popover.popover('show')%0A    ok($('.popover').length, 'popover was inserted')%0A    equal($('.popover .popover-content').html(), $div, 'content correctly inserted')%0A%0A    popover.popover('hide')%0A    ok(!$('.popover').length, 'popover was removed')%0A%0A    popover.popover('show')%0A    ok($('.popover').length, 'popover was inserted')%0A    equal($('.popover .popover-content').html(), $div, 'content correctly inserted')%0A%0A    popover.popover('hide')%0A    ok(!$('.popover').length, 'popover was removed')%0A    $('#qunit-fixture').empty()%0A  %7D)%0A%0A
   test('should g

Add test for popover.