1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-09 15:16:51 +02:00

Remove potential false positive assertions (#33288)

* Remove potential false positive assertions

querySelector() returns null but

expect(document.querySelector('...')).toBeDefined()

tests that the value is not undefined

* Migrated assertions from .toBeDefined() to .not.toBeNull() for .getInstance() calls in tests

* Migrate offcanvas assertions from .toBeDefined() to .not.toBeNull() for .getInstance() call

* convert more cases to not.toBeNull assertions

Co-authored-by: XhmikosR <xhmikosr@gmail.com>
This commit is contained in:
Ben Lertlumprasertkul
2021-05-11 06:45:57 +01:00
committed by GitHub
parent 9c3ab6557e
commit 052def4568
13 changed files with 67 additions and 67 deletions

View File

@@ -91,7 +91,7 @@ describe('Button', () => {
const btnEl = fixtureEl.querySelector('.btn')
const button = new Button(btnEl)
expect(Button.getInstance(btnEl)).toBeDefined()
expect(Button.getInstance(btnEl)).not.toBeNull()
button.dispose()
@@ -126,7 +126,7 @@ describe('Button', () => {
jQueryMock.fn.button.call(jQueryMock, 'toggle')
expect(Button.getInstance(btnEl)).toBeDefined()
expect(Button.getInstance(btnEl)).not.toBeNull()
expect(btnEl.classList.contains('active')).toEqual(true)
})
@@ -140,7 +140,7 @@ describe('Button', () => {
jQueryMock.fn.button.call(jQueryMock)
expect(Button.getInstance(btnEl)).toBeDefined()
expect(Button.getInstance(btnEl)).not.toBeNull()
expect(btnEl.classList.contains('active')).toEqual(false)
})
})