diff options
| author | Alexandr Kondrashov <[email protected]> | 2015-09-11 16:43:00 +0300 |
|---|---|---|
| committer | Alexandr Kondrashov <[email protected]> | 2015-09-11 16:43:00 +0300 |
| commit | c9725926b2f30bed4e37f57c20ef8ffeb2fd233b (patch) | |
| tree | 2964ad7556549dd3e0712bdfdbc5fc4ae7a9b45f /js/tests/unit | |
| parent | 353e0a49a97c24d89f6cdb95014419d4137dee6e (diff) | |
| parent | b811f8cf9628dbcbfe994f71588c5a0c921a092d (diff) | |
| download | bootstrap-c9725926b2f30bed4e37f57c20ef8ffeb2fd233b.tar.xz bootstrap-c9725926b2f30bed4e37f57c20ef8ffeb2fd233b.zip | |
Merge remote-tracking branch 'twbs/v4-dev' into patch-1
Conflicts:
scss/_custom-forms.scss
scss/_variables.scss
Diffstat (limited to 'js/tests/unit')
| -rw-r--r-- | js/tests/unit/.jshintrc | 6 | ||||
| -rw-r--r-- | js/tests/unit/popover.js | 36 | ||||
| -rw-r--r-- | js/tests/unit/tooltip.js | 29 |
3 files changed, 65 insertions, 6 deletions
diff --git a/js/tests/unit/.jshintrc b/js/tests/unit/.jshintrc deleted file mode 100644 index 22e878512..000000000 --- a/js/tests/unit/.jshintrc +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends" : "../../.jshintrc", - "devel" : true, - "es3" : false, - "qunit" : true -} diff --git a/js/tests/unit/popover.js b/js/tests/unit/popover.js index 8347e9f03..894468695 100644 --- a/js/tests/unit/popover.js +++ b/js/tests/unit/popover.js @@ -86,6 +86,42 @@ $(function () { assert.strictEqual($('.popover').length, 0, 'popover was removed') }) + QUnit.test('should allow DOMElement title and content (html: true)', function (assert) { + assert.expect(5) + var title = document.createTextNode('@glebm <3 writing tests') + var content = $('<i>¯\\_(ツ)_/¯</i>').get(0) + var $popover = $('<a href="#" rel="tooltip"/>') + .appendTo('#qunit-fixture') + .bootstrapPopover({ html: true, title: title, content: content }) + + $popover.bootstrapPopover('show') + + assert.notEqual($('.popover').length, 0, 'popover inserted') + assert.strictEqual($('.popover .popover-title').text(), '@glebm <3 writing tests', 'title inserted') + assert.ok($.contains($('.popover').get(0), title), 'title node moved, not copied') + // toLowerCase because IE8 will return <I>...</I> + assert.strictEqual($('.popover .popover-content').html().toLowerCase(), '<i>¯\\_(ツ)_/¯</i>', 'content inserted') + assert.ok($.contains($('.popover').get(0), content), 'content node moved, not copied') + }) + + QUnit.test('should allow DOMElement title and content (html: false)', function (assert) { + assert.expect(5) + var title = document.createTextNode('@glebm <3 writing tests') + var content = $('<i>¯\\_(ツ)_/¯</i>').get(0) + var $popover = $('<a href="#" rel="tooltip"/>') + .appendTo('#qunit-fixture') + .bootstrapPopover({ title: title, content: content }) + + $popover.bootstrapPopover('show') + + assert.notEqual($('.popover').length, 0, 'popover inserted') + assert.strictEqual($('.popover .popover-title').text(), '@glebm <3 writing tests', 'title inserted') + assert.ok(!$.contains($('.popover').get(0), title), 'title node copied, not moved') + assert.strictEqual($('.popover .popover-content').html(), '¯\\_(ツ)_/¯', 'content inserted') + assert.ok(!$.contains($('.popover').get(0), content), 'content node copied, not moved') + }) + + QUnit.test('should not duplicate HTML object', function (assert) { assert.expect(6) var $div = $('<div/>').html('loves writing tests (╯°□°)╯︵ ┻━┻') diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js index f4deb29f8..934e26b9e 100644 --- a/js/tests/unit/tooltip.js +++ b/js/tests/unit/tooltip.js @@ -119,6 +119,35 @@ $(function () { assert.strictEqual($tooltip.data('bs.tooltip').tip.parentNode, null, 'tooltip removed') }) + QUnit.test('should allow DOMElement title (html: false)', function (assert) { + assert.expect(3) + var title = document.createTextNode('<3 writing tests') + var $tooltip = $('<a href="#" rel="tooltip"/>') + .appendTo('#qunit-fixture') + .bootstrapTooltip({ title: title }) + + $tooltip.bootstrapTooltip('show') + + assert.notEqual($('.tooltip').length, 0, 'tooltip inserted') + assert.strictEqual($('.tooltip').text(), '<3 writing tests', 'title inserted') + assert.ok(!$.contains($('.tooltip').get(0), title), 'title node copied, not moved') + }) + + QUnit.test('should allow DOMElement title (html: true)', function (assert) { + assert.expect(3) + var title = document.createTextNode('<3 writing tests') + var $tooltip = $('<a href="#" rel="tooltip"/>') + .appendTo('#qunit-fixture') + .bootstrapTooltip({ html: true, title: title }) + + $tooltip.bootstrapTooltip('show') + + assert.notEqual($('.tooltip').length, 0, 'tooltip inserted') + assert.strictEqual($('.tooltip').text(), '<3 writing tests', 'title inserted') + assert.ok($.contains($('.tooltip').get(0), title), 'title node moved, not copied') + }) + + QUnit.test('should respect custom classes', function (assert) { assert.expect(2) var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"/>') |
