mirror of
https://github.com/tenrok/bootstrap.git
synced 2026-06-17 19:21:23 +03:00
Merge branch 'master' into v4
Conflicts: .travis.yml Gruntfile.js bower.json dist/css/bootstrap.css dist/css/bootstrap.css.map dist/css/bootstrap.min.css dist/js/bootstrap.js dist/js/bootstrap.min.js docs/_data/glyphicons.yml docs/_includes/components/breadcrumbs.html docs/_includes/components/button-dropdowns.html docs/_includes/components/button-groups.html docs/_includes/components/dropdowns.html docs/_includes/components/glyphicons.html docs/_includes/components/labels.html docs/_includes/components/list-group.html docs/_includes/components/media.html docs/_includes/components/navs.html docs/_includes/components/panels.html docs/_includes/components/progress-bars.html docs/_includes/components/thumbnails.html docs/_includes/components/wells.html docs/_includes/css/buttons.html docs/_includes/css/forms.html docs/_includes/css/helpers.html docs/_includes/css/images.html docs/_includes/css/less.html docs/_includes/customizer-variables.html docs/_includes/getting-started/accessibility.html docs/_includes/getting-started/browser-device-support.html docs/_includes/getting-started/community.html docs/_includes/getting-started/examples.html docs/_includes/getting-started/grunt.html docs/_includes/getting-started/license.html docs/_includes/getting-started/template.html docs/_includes/header.html docs/_includes/js/affix.html docs/_includes/js/alerts.html docs/_includes/js/carousel.html docs/_includes/js/collapse.html docs/_includes/js/dropdowns.html docs/_includes/js/modal.html docs/_includes/js/overview.html docs/_includes/js/popovers.html docs/_includes/js/scrollspy.html docs/_includes/js/tabs.html docs/_includes/js/tooltips.html docs/_includes/js/transitions.html docs/_includes/nav/javascript.html docs/_layouts/default.html docs/assets/css/docs.min.css docs/assets/css/src/docs.css docs/assets/js/customize.min.js docs/assets/js/docs.min.js docs/assets/js/raw-files.min.js docs/assets/js/vendor/FileSaver.js docs/assets/js/vendor/autoprefixer.js docs/assets/js/vendor/uglify.min.js docs/dist/css/bootstrap.css docs/dist/css/bootstrap.css.map docs/dist/css/bootstrap.min.css docs/dist/js/bootstrap.min.js docs/examples/blog/index.html docs/examples/carousel/index.html docs/examples/cover/index.html docs/examples/dashboard/index.html docs/examples/narrow-jumbotron/narrow-jumbotron.css docs/examples/navbar-fixed-top/index.html docs/examples/navbar-static-top/index.html docs/examples/non-responsive/index.html docs/examples/non-responsive/non-responsive.css docs/examples/theme/index.html grunt/configBridge.json js/affix.js js/carousel.js js/collapse.js js/dropdown.js js/modal.js js/popover.js js/scrollspy.js js/tab.js js/tests/unit/affix.js js/tests/unit/button.js js/tests/unit/carousel.js js/tests/unit/modal.js js/tests/unit/tooltip.js js/tooltip.js less/badges.less less/glyphicons.less less/type.less less/variables.less package.json scss/_dropdown.scss scss/_forms.scss test-infra/npm-shrinkwrap.json
This commit is contained in:
+64
-57
@@ -1,61 +1,61 @@
|
||||
$(function () {
|
||||
'use strict';
|
||||
|
||||
module('popover plugin')
|
||||
QUnit.module('popover plugin')
|
||||
|
||||
test('should be defined on jquery object', function () {
|
||||
ok($(document.body).popover, 'popover method is defined')
|
||||
QUnit.test('should be defined on jquery object', function (assert) {
|
||||
assert.ok($(document.body).popover, 'popover method is defined')
|
||||
})
|
||||
|
||||
module('popover', {
|
||||
setup: function () {
|
||||
QUnit.module('popover', {
|
||||
beforeEach: function () {
|
||||
// Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode
|
||||
$.fn.bootstrapPopover = $.fn.popover.noConflict()
|
||||
},
|
||||
teardown: function () {
|
||||
afterEach: function () {
|
||||
$.fn.popover = $.fn.bootstrapPopover
|
||||
delete $.fn.bootstrapPopover
|
||||
}
|
||||
})
|
||||
|
||||
test('should provide no conflict', function () {
|
||||
strictEqual($.fn.popover, undefined, 'popover was set back to undefined (org value)')
|
||||
QUnit.test('should provide no conflict', function (assert) {
|
||||
assert.strictEqual($.fn.popover, undefined, 'popover was set back to undefined (org value)')
|
||||
})
|
||||
|
||||
test('should return jquery collection containing the element', function () {
|
||||
QUnit.test('should return jquery collection containing the element', function (assert) {
|
||||
var $el = $('<div/>')
|
||||
var $popover = $el.bootstrapPopover()
|
||||
ok($popover instanceof $, 'returns jquery collection')
|
||||
strictEqual($popover[0], $el[0], 'collection contains element')
|
||||
assert.ok($popover instanceof $, 'returns jquery collection')
|
||||
assert.strictEqual($popover[0], $el[0], 'collection contains element')
|
||||
})
|
||||
|
||||
test('should render popover element', function () {
|
||||
QUnit.test('should render popover element', function (assert) {
|
||||
var $popover = $('<a href="#" title="mdo" data-content="https://twitter.com/mdo">@mdo</a>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapPopover('show')
|
||||
|
||||
notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
assert.notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
$popover.bootstrapPopover('hide')
|
||||
equal($('.popover').length, 0, 'popover removed')
|
||||
assert.strictEqual($('.popover').length, 0, 'popover removed')
|
||||
})
|
||||
|
||||
test('should store popover instance in popover data object', function () {
|
||||
QUnit.test('should store popover instance in popover data object', function (assert) {
|
||||
var $popover = $('<a href="#" title="mdo" data-content="https://twitter.com/mdo">@mdo</a>').bootstrapPopover()
|
||||
|
||||
ok($popover.data('bs.popover'), 'popover instance exists')
|
||||
assert.ok($popover.data('bs.popover'), 'popover instance exists')
|
||||
})
|
||||
|
||||
test('should store popover trigger in popover instance data object', function () {
|
||||
QUnit.test('should store popover trigger in popover instance data object', function (assert) {
|
||||
var $popover = $('<a href="#" title="ResentedHook">@ResentedHook</a>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapPopover()
|
||||
|
||||
$popover.bootstrapPopover('show')
|
||||
|
||||
ok($('.popover').data('bs.popover'), 'popover trigger stored in instance data')
|
||||
assert.ok($('.popover').data('bs.popover'), 'popover trigger stored in instance data')
|
||||
})
|
||||
|
||||
test('should get title and content from options', function () {
|
||||
QUnit.test('should get title and content from options', function (assert) {
|
||||
var $popover = $('<a href="#">@fat</a>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapPopover({
|
||||
@@ -69,15 +69,15 @@ $(function () {
|
||||
|
||||
$popover.bootstrapPopover('show')
|
||||
|
||||
notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
equal($('.popover .popover-title').text(), '@fat', 'title correctly inserted')
|
||||
equal($('.popover .popover-content').text(), 'loves writing tests (╯°□°)╯︵ ┻━┻', 'content correctly inserted')
|
||||
assert.notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
assert.strictEqual($('.popover .popover-title').text(), '@fat', 'title correctly inserted')
|
||||
assert.strictEqual($('.popover .popover-content').text(), 'loves writing tests (╯°□°)╯︵ ┻━┻', 'content correctly inserted')
|
||||
|
||||
$popover.bootstrapPopover('hide')
|
||||
equal($('.popover').length, 0, 'popover was removed')
|
||||
assert.strictEqual($('.popover').length, 0, 'popover was removed')
|
||||
})
|
||||
|
||||
test('should not duplicate HTML object', function () {
|
||||
QUnit.test('should not duplicate HTML object', function (assert) {
|
||||
var $div = $('<div/>').html('loves writing tests (╯°□°)╯︵ ┻━┻')
|
||||
|
||||
var $popover = $('<a href="#">@fat</a>')
|
||||
@@ -89,36 +89,36 @@ $(function () {
|
||||
})
|
||||
|
||||
$popover.bootstrapPopover('show')
|
||||
notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
equal($('.popover .popover-content').html(), $div, 'content correctly inserted')
|
||||
assert.notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
assert.equal($('.popover .popover-content').html(), $div, 'content correctly inserted')
|
||||
|
||||
$popover.bootstrapPopover('hide')
|
||||
equal($('.popover').length, 0, 'popover was removed')
|
||||
assert.strictEqual($('.popover').length, 0, 'popover was removed')
|
||||
|
||||
$popover.bootstrapPopover('show')
|
||||
notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
equal($('.popover .popover-content').html(), $div, 'content correctly inserted')
|
||||
assert.notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
assert.equal($('.popover .popover-content').html(), $div, 'content correctly inserted')
|
||||
|
||||
$popover.bootstrapPopover('hide')
|
||||
equal($('.popover').length, 0, 'popover was removed')
|
||||
assert.strictEqual($('.popover').length, 0, 'popover was removed')
|
||||
})
|
||||
|
||||
test('should get title and content from attributes', function () {
|
||||
QUnit.test('should get title and content from attributes', function (assert) {
|
||||
var $popover = $('<a href="#" title="@mdo" data-content="loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻" >@mdo</a>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapPopover()
|
||||
.bootstrapPopover('show')
|
||||
|
||||
notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
equal($('.popover .popover-title').text(), '@mdo', 'title correctly inserted')
|
||||
equal($('.popover .popover-content').text(), 'loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻', 'content correctly inserted')
|
||||
assert.notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
assert.strictEqual($('.popover .popover-title').text(), '@mdo', 'title correctly inserted')
|
||||
assert.strictEqual($('.popover .popover-content').text(), 'loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻', 'content correctly inserted')
|
||||
|
||||
$popover.bootstrapPopover('hide')
|
||||
equal($('.popover').length, 0, 'popover was removed')
|
||||
assert.strictEqual($('.popover').length, 0, 'popover was removed')
|
||||
})
|
||||
|
||||
|
||||
test('should get title and content from attributes ignoring options passed via js', function () {
|
||||
QUnit.test('should get title and content from attributes ignoring options passed via js', function (assert) {
|
||||
var $popover = $('<a href="#" title="@mdo" data-content="loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻" >@mdo</a>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapPopover({
|
||||
@@ -127,15 +127,15 @@ $(function () {
|
||||
})
|
||||
.bootstrapPopover('show')
|
||||
|
||||
notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
equal($('.popover .popover-title').text(), '@mdo', 'title correctly inserted')
|
||||
equal($('.popover .popover-content').text(), 'loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻', 'content correctly inserted')
|
||||
assert.notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
assert.strictEqual($('.popover .popover-title').text(), '@mdo', 'title correctly inserted')
|
||||
assert.strictEqual($('.popover .popover-content').text(), 'loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻', 'content correctly inserted')
|
||||
|
||||
$popover.bootstrapPopover('hide')
|
||||
equal($('.popover').length, 0, 'popover was removed')
|
||||
assert.strictEqual($('.popover').length, 0, 'popover was removed')
|
||||
})
|
||||
|
||||
test('should respect custom template', function () {
|
||||
QUnit.test('should respect custom template', function (assert) {
|
||||
var $popover = $('<a href="#">@fat</a>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapPopover({
|
||||
@@ -146,34 +146,34 @@ $(function () {
|
||||
|
||||
$popover.bootstrapPopover('show')
|
||||
|
||||
notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
ok($('.popover').hasClass('foobar'), 'custom class is present')
|
||||
assert.notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
assert.ok($('.popover').hasClass('foobar'), 'custom class is present')
|
||||
|
||||
$popover.bootstrapPopover('hide')
|
||||
equal($('.popover').length, 0, 'popover was removed')
|
||||
assert.strictEqual($('.popover').length, 0, 'popover was removed')
|
||||
})
|
||||
|
||||
test('should destroy popover', function () {
|
||||
QUnit.test('should destroy popover', function (assert) {
|
||||
var $popover = $('<div/>')
|
||||
.bootstrapPopover({
|
||||
trigger: 'hover'
|
||||
})
|
||||
.on('click.foo', $.noop)
|
||||
|
||||
ok($popover.data('bs.popover'), 'popover has data')
|
||||
ok($._data($popover[0], 'events').mouseover && $._data($popover[0], 'events').mouseout, 'popover has hover event')
|
||||
equal($._data($popover[0], 'events').click[0].namespace, 'foo', 'popover has extra click.foo event')
|
||||
assert.ok($popover.data('bs.popover'), 'popover has data')
|
||||
assert.ok($._data($popover[0], 'events').mouseover && $._data($popover[0], 'events').mouseout, 'popover has hover event')
|
||||
assert.strictEqual($._data($popover[0], 'events').click[0].namespace, 'foo', 'popover has extra click.foo event')
|
||||
|
||||
$popover.bootstrapPopover('show')
|
||||
$popover.bootstrapPopover('destroy')
|
||||
|
||||
ok(!$popover.hasClass('in'), 'popover is hidden')
|
||||
ok(!$popover.data('popover'), 'popover does not have data')
|
||||
equal($._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')
|
||||
assert.ok(!$popover.hasClass('in'), 'popover is hidden')
|
||||
assert.ok(!$popover.data('popover'), 'popover does not have data')
|
||||
assert.strictEqual($._data($popover[0], 'events').click[0].namespace, 'foo', 'popover still has click.foo')
|
||||
assert.ok(!$._data($popover[0], 'events').mouseover && !$._data($popover[0], 'events').mouseout, 'popover does not have any events')
|
||||
})
|
||||
|
||||
test('should render popover element using delegated selector', function () {
|
||||
QUnit.test('should render popover element using delegated selector', function (assert) {
|
||||
var $div = $('<div><a href="#" title="mdo" data-content="http://twitter.com/mdo">@mdo</a></div>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapPopover({
|
||||
@@ -182,13 +182,13 @@ $(function () {
|
||||
})
|
||||
|
||||
$div.find('a').click()
|
||||
notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
assert.notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
|
||||
$div.find('a').click()
|
||||
equal($('.popover').length, 0, 'popover was removed')
|
||||
assert.strictEqual($('.popover').length, 0, 'popover was removed')
|
||||
})
|
||||
|
||||
test('should detach popover content rather than removing it so that event handlers are left intact', function (assert) {
|
||||
QUnit.test('should detach popover content rather than removing it so that event handlers are left intact', function (assert) {
|
||||
var $content = $('<div class="content-with-handler"><a class="btn btn-warning">Button with event handler</a></div>').appendTo('#qunit-fixture')
|
||||
|
||||
var handlerCalled = false
|
||||
@@ -216,7 +216,7 @@ $(function () {
|
||||
.one('shown.bs.popover', function () {
|
||||
$('.content-with-handler .btn').click()
|
||||
$div.bootstrapPopover('destroy')
|
||||
ok(handlerCalled, 'content\'s event handler still present')
|
||||
assert.ok(handlerCalled, 'content\'s event handler still present')
|
||||
done()
|
||||
})
|
||||
.bootstrapPopover('show')
|
||||
@@ -225,4 +225,11 @@ $(function () {
|
||||
})
|
||||
.bootstrapPopover('show')
|
||||
})
|
||||
|
||||
QUnit.test('should throw an error when initializing popover on the document object without specifying a delegation selector', function (assert) {
|
||||
assert.throws(function () {
|
||||
$(document).bootstrapPopover({ title: 'What am I on?', content: 'My selector is missing' })
|
||||
}, new Error('`selector` option must be specified when initializing popover on the window.document object!'))
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user