1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-14 01:24:19 +02:00

tests: streamline HTML end tags (#30648)

This commit is contained in:
XhmikosR
2020-05-06 09:20:08 +03:00
committed by GitHub
parent 23aaee8c6f
commit 967e6071ba
10 changed files with 130 additions and 124 deletions

View File

@@ -64,7 +64,7 @@ describe('Tooltip', () => {
describe('constructor', () => {
it('should not take care of disallowed data attributes', () => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" data-sanitize="false" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" data-sanitize="false" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
@@ -73,7 +73,7 @@ describe('Tooltip', () => {
})
it('should convert title and content to string if numbers', () => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl, {
@@ -94,7 +94,7 @@ describe('Tooltip', () => {
trigger: 'click'
})
containerEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
containerEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipInContainerEl = containerEl.querySelector('a')
@@ -108,7 +108,7 @@ describe('Tooltip', () => {
})
it('should allow to pass config to popper.js with `popperConfig`', () => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl, {
@@ -125,7 +125,7 @@ describe('Tooltip', () => {
describe('enable', () => {
it('should enable a tooltip', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
@@ -143,7 +143,7 @@ describe('Tooltip', () => {
describe('disable', () => {
it('should disable tooltip', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
@@ -165,7 +165,7 @@ describe('Tooltip', () => {
describe('toggleEnabled', () => {
it('should toggle enabled', () => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
@@ -180,7 +180,7 @@ describe('Tooltip', () => {
describe('toggle', () => {
it('should do nothing if disabled', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
@@ -200,7 +200,7 @@ describe('Tooltip', () => {
})
it('should show a tooltip', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
@@ -214,7 +214,7 @@ describe('Tooltip', () => {
})
it('should call toggle and show the tooltip when trigger is "click"', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl, {
@@ -232,7 +232,7 @@ describe('Tooltip', () => {
})
it('should hide a tooltip', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
@@ -250,7 +250,7 @@ describe('Tooltip', () => {
})
it('should call toggle and hide the tooltip when trigger is "click"', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl, {
@@ -274,7 +274,7 @@ describe('Tooltip', () => {
describe('dispose', () => {
it('should destroy a tooltip', () => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
@@ -287,7 +287,7 @@ describe('Tooltip', () => {
})
it('should destroy a tooltip and remove it from the dom', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
@@ -307,7 +307,7 @@ describe('Tooltip', () => {
describe('show', () => {
it('should show a tooltip', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
@@ -325,7 +325,7 @@ describe('Tooltip', () => {
})
it('should show a tooltip on mobile', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
@@ -344,7 +344,7 @@ describe('Tooltip', () => {
})
it('should show a tooltip relative to placement option', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl, {
@@ -366,7 +366,7 @@ describe('Tooltip', () => {
})
it('should not error when trying to show a tooltip that has been removed from the dom', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
@@ -393,7 +393,7 @@ describe('Tooltip', () => {
})
it('should show a tooltip with a dom element container', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl, {
@@ -409,7 +409,7 @@ describe('Tooltip', () => {
})
it('should show a tooltip with a jquery element container', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl, {
@@ -428,7 +428,7 @@ describe('Tooltip', () => {
})
it('should show a tooltip with a selector in container', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl, {
@@ -444,7 +444,7 @@ describe('Tooltip', () => {
})
it('should show a tooltip with placement as a function', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const spy = jasmine.createSpy('placement').and.returnValue('top')
const tooltipEl = fixtureEl.querySelector('a')
@@ -462,7 +462,7 @@ describe('Tooltip', () => {
})
it('should show a tooltip with offset as a function', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const spy = jasmine.createSpy('offset').and.returnValue({})
const tooltipEl = fixtureEl.querySelector('a')
@@ -480,7 +480,7 @@ describe('Tooltip', () => {
})
it('should show a tooltip without the animation', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl, {
@@ -499,7 +499,7 @@ describe('Tooltip', () => {
})
it('should throw an error the element is not visible', () => {
fixtureEl.innerHTML = '<a href="#" style="display: none" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" style="display: none" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
@@ -512,7 +512,7 @@ describe('Tooltip', () => {
})
it('should not show a tooltip if show.bs.tooltip is prevented', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
@@ -537,7 +537,7 @@ describe('Tooltip', () => {
})
it('should show tooltip if leave event hasn\'t occurred before delay expires', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl, {
@@ -559,7 +559,7 @@ describe('Tooltip', () => {
})
it('should not show tooltip if leave event occurs before delay expires', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl, {
@@ -583,7 +583,7 @@ describe('Tooltip', () => {
})
it('should not hide tooltip if leave event occurs and enter event occurs within the hide delay', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl, {
@@ -614,7 +614,7 @@ describe('Tooltip', () => {
describe('hide', () => {
it('should hide a tooltip', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
@@ -630,7 +630,7 @@ describe('Tooltip', () => {
})
it('should hide a tooltip on mobile', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
@@ -652,7 +652,7 @@ describe('Tooltip', () => {
})
it('should hide a tooltip without animation', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl, {
@@ -670,7 +670,7 @@ describe('Tooltip', () => {
})
it('should not hide a tooltip if hide event is prevented', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const assertDone = () => {
setTimeout(() => {
@@ -699,7 +699,7 @@ describe('Tooltip', () => {
describe('update', () => {
it('should call popper schedule update', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
@@ -717,7 +717,7 @@ describe('Tooltip', () => {
})
it('should do nothing if the tooltip is not shown', () => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
@@ -729,7 +729,7 @@ describe('Tooltip', () => {
describe('isWithContent', () => {
it('should return true if there is content', () => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
@@ -738,7 +738,7 @@ describe('Tooltip', () => {
})
it('should return false if there is no content', () => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title=""/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
@@ -749,7 +749,7 @@ describe('Tooltip', () => {
describe('getTipElement', () => {
it('should create the tip element and return it', () => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
@@ -761,7 +761,7 @@ describe('Tooltip', () => {
})
it('should return the created tip element', () => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
@@ -780,7 +780,7 @@ describe('Tooltip', () => {
describe('setContent', () => {
it('should set tip content', () => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
@@ -797,7 +797,7 @@ describe('Tooltip', () => {
describe('setElementContent', () => {
it('should do nothing if the element is null', () => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
@@ -808,7 +808,7 @@ describe('Tooltip', () => {
it('should add the content as a child of the element', () => {
fixtureEl.innerHTML = [
'<a href="#" rel="tooltip" title="Another tooltip"/>',
'<a href="#" rel="tooltip" title="Another tooltip">',
'<div id="childContent"></div>'
].join('')
@@ -825,7 +825,7 @@ describe('Tooltip', () => {
it('should do nothing if the content is a child of the element', () => {
fixtureEl.innerHTML = [
'<a href="#" rel="tooltip" title="Another tooltip"/>',
'<a href="#" rel="tooltip" title="Another tooltip">',
'<div id="childContent"></div>'
].join('')
@@ -843,7 +843,7 @@ describe('Tooltip', () => {
it('should add the content as a child of the element for jQuery elements', () => {
fixtureEl.innerHTML = [
'<a href="#" rel="tooltip" title="Another tooltip"/>',
'<a href="#" rel="tooltip" title="Another tooltip">',
'<div id="childContent"></div>'
].join('')
@@ -860,7 +860,7 @@ describe('Tooltip', () => {
it('should add the child text content in the element', () => {
fixtureEl.innerHTML = [
'<a href="#" rel="tooltip" title="Another tooltip"/>',
'<a href="#" rel="tooltip" title="Another tooltip">',
'<div id="childContent">Tooltip</div>'
].join('')
@@ -874,7 +874,7 @@ describe('Tooltip', () => {
})
it('should add html without sanitize it', () => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl, {
@@ -888,7 +888,7 @@ describe('Tooltip', () => {
})
it('should add html sanitized', () => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl, {
@@ -906,7 +906,7 @@ describe('Tooltip', () => {
})
it('should add text content', () => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
@@ -919,7 +919,7 @@ describe('Tooltip', () => {
describe('getTitle', () => {
it('should return the title', () => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"/>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
@@ -928,7 +928,7 @@ describe('Tooltip', () => {
})
it('should call title function', () => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" />'
fixtureEl.innerHTML = '<a href="#" rel="tooltip"></a>'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl, {