mirror of
https://github.com/tenrok/bootstrap.git
synced 2026-06-17 19:21:23 +03:00
Merge branch 'master' into v4
Conflicts: .gitignore Gruntfile.js _config.yml dist/css/bootstrap-theme.css dist/css/bootstrap-theme.min.css dist/css/bootstrap.css dist/css/bootstrap.css.map dist/css/bootstrap.min.css dist/js/bootstrap.js dist/js/bootstrap.min.js docs/_includes/components/navbar.html docs/_includes/components/progress-bars.html docs/_includes/css/grid.html docs/_includes/css/overview.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/disabling-responsiveness.html docs/_includes/getting-started/download.html docs/_includes/getting-started/examples.html docs/_includes/getting-started/license.html docs/_includes/getting-started/third-party-support.html docs/_includes/js/alerts.html docs/_includes/js/buttons.html docs/_includes/js/carousel.html docs/_includes/js/collapse.html docs/_includes/js/dropdowns.html docs/_includes/js/modal.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/_includes/nav/main.html docs/about.html docs/assets/css/docs.min.css docs/assets/css/src/docs.css docs/assets/js/customize.min.js docs/assets/js/raw-files.min.js docs/assets/js/src/customizer.js docs/dist/css/bootstrap-theme.css docs/dist/css/bootstrap-theme.min.css docs/dist/css/bootstrap.css docs/dist/css/bootstrap.css.map docs/dist/css/bootstrap.min.css docs/dist/js/bootstrap.js docs/dist/js/bootstrap.min.js docs/migration.html js/affix.js js/alert.js js/button.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/tests/visual/modal.html js/tooltip.js less/component-animations.less less/jumbotron.less less/mixins/background-variant.less less/mixins/buttons.less less/mixins/responsive-visibility.less less/mixins/text-emphasis.less less/navbar.less less/navs.less less/scaffolding.less less/tooltip.less less/utilities.less less/variables.less package.json scss/_buttons.scss scss/_forms.scss scss/_modal.scss
This commit is contained in:
@@ -4,6 +4,7 @@ $(function () {
|
||||
QUnit.module('popover plugin')
|
||||
|
||||
QUnit.test('should be defined on jquery object', function (assert) {
|
||||
assert.expect(1)
|
||||
assert.ok($(document.body).popover, 'popover method is defined')
|
||||
})
|
||||
|
||||
@@ -19,10 +20,12 @@ $(function () {
|
||||
})
|
||||
|
||||
QUnit.test('should provide no conflict', function (assert) {
|
||||
assert.expect(1)
|
||||
assert.strictEqual($.fn.popover, undefined, 'popover was set back to undefined (org value)')
|
||||
})
|
||||
|
||||
QUnit.test('should return jquery collection containing the element', function (assert) {
|
||||
assert.expect(2)
|
||||
var $el = $('<div/>')
|
||||
var $popover = $el.bootstrapPopover()
|
||||
assert.ok($popover instanceof $, 'returns jquery collection')
|
||||
@@ -30,6 +33,7 @@ $(function () {
|
||||
})
|
||||
|
||||
QUnit.test('should render popover element', function (assert) {
|
||||
assert.expect(2)
|
||||
var $popover = $('<a href="#" title="mdo" data-content="https://twitter.com/mdo">@mdo</a>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapPopover('show')
|
||||
@@ -40,12 +44,14 @@ $(function () {
|
||||
})
|
||||
|
||||
QUnit.test('should store popover instance in popover data object', function (assert) {
|
||||
assert.expect(1)
|
||||
var $popover = $('<a href="#" title="mdo" data-content="https://twitter.com/mdo">@mdo</a>').bootstrapPopover()
|
||||
|
||||
assert.ok($popover.data('bs.popover'), 'popover instance exists')
|
||||
})
|
||||
|
||||
QUnit.test('should store popover trigger in popover instance data object', function (assert) {
|
||||
assert.expect(1)
|
||||
var $popover = $('<a href="#" title="ResentedHook">@ResentedHook</a>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapPopover()
|
||||
@@ -56,6 +62,7 @@ $(function () {
|
||||
})
|
||||
|
||||
QUnit.test('should get title and content from options', function (assert) {
|
||||
assert.expect(4)
|
||||
var $popover = $('<a href="#">@fat</a>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapPopover({
|
||||
@@ -78,6 +85,7 @@ $(function () {
|
||||
})
|
||||
|
||||
QUnit.test('should not duplicate HTML object', function (assert) {
|
||||
assert.expect(6)
|
||||
var $div = $('<div/>').html('loves writing tests (╯°□°)╯︵ ┻━┻')
|
||||
|
||||
var $popover = $('<a href="#">@fat</a>')
|
||||
@@ -104,6 +112,7 @@ $(function () {
|
||||
})
|
||||
|
||||
QUnit.test('should get title and content from attributes', function (assert) {
|
||||
assert.expect(4)
|
||||
var $popover = $('<a href="#" title="@mdo" data-content="loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻" >@mdo</a>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapPopover()
|
||||
@@ -119,6 +128,7 @@ $(function () {
|
||||
|
||||
|
||||
QUnit.test('should get title and content from attributes ignoring options passed via js', function (assert) {
|
||||
assert.expect(4)
|
||||
var $popover = $('<a href="#" title="@mdo" data-content="loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻" >@mdo</a>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapPopover({
|
||||
@@ -136,6 +146,7 @@ $(function () {
|
||||
})
|
||||
|
||||
QUnit.test('should respect custom template', function (assert) {
|
||||
assert.expect(3)
|
||||
var $popover = $('<a href="#">@fat</a>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapPopover({
|
||||
@@ -154,6 +165,7 @@ $(function () {
|
||||
})
|
||||
|
||||
QUnit.test('should destroy popover', function (assert) {
|
||||
assert.expect(7)
|
||||
var $popover = $('<div/>')
|
||||
.bootstrapPopover({
|
||||
trigger: 'hover'
|
||||
@@ -174,6 +186,7 @@ $(function () {
|
||||
})
|
||||
|
||||
QUnit.test('should render popover element using delegated selector', function (assert) {
|
||||
assert.expect(2)
|
||||
var $div = $('<div><a href="#" title="mdo" data-content="http://twitter.com/mdo">@mdo</a></div>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapPopover({
|
||||
@@ -181,18 +194,19 @@ $(function () {
|
||||
trigger: 'click'
|
||||
})
|
||||
|
||||
$div.find('a').click()
|
||||
$div.find('a').trigger('click')
|
||||
assert.notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
|
||||
$div.find('a').click()
|
||||
$div.find('a').trigger('click')
|
||||
assert.strictEqual($('.popover').length, 0, 'popover was removed')
|
||||
})
|
||||
|
||||
QUnit.test('should detach popover content rather than removing it so that event handlers are left intact', function (assert) {
|
||||
assert.expect(1)
|
||||
var $content = $('<div class="content-with-handler"><a class="btn btn-warning">Button with event handler</a></div>').appendTo('#qunit-fixture')
|
||||
|
||||
var handlerCalled = false
|
||||
$('.content-with-handler .btn').click(function () {
|
||||
$('.content-with-handler .btn').on('click', function () {
|
||||
handlerCalled = true
|
||||
})
|
||||
|
||||
@@ -214,7 +228,7 @@ $(function () {
|
||||
.one('hidden.bs.popover', function () {
|
||||
$div
|
||||
.one('shown.bs.popover', function () {
|
||||
$('.content-with-handler .btn').click()
|
||||
$('.content-with-handler .btn').trigger('click')
|
||||
$div.bootstrapPopover('destroy')
|
||||
assert.ok(handlerCalled, 'content\'s event handler still present')
|
||||
done()
|
||||
@@ -227,9 +241,22 @@ $(function () {
|
||||
})
|
||||
|
||||
QUnit.test('should throw an error when initializing popover on the document object without specifying a delegation selector', function (assert) {
|
||||
assert.expect(1)
|
||||
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!'))
|
||||
})
|
||||
|
||||
QUnit.test('should do nothing when an attempt is made to hide an uninitialized popover', function (assert) {
|
||||
assert.expect(1)
|
||||
|
||||
var $popover = $('<span data-toggle="popover" data-title="some title" data-content="some content">some text</span>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.on('hidden.bs.popover shown.bs.popover', function () {
|
||||
assert.ok(false, 'should not fire any popover events')
|
||||
})
|
||||
.bootstrapPopover('hide')
|
||||
assert.strictEqual($popover.data('bs.popover'), undefined, 'should not initialize the popover')
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user