mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-28 23:59:53 +02:00
tests: tweak Jasmine's matchers usage
Use: * toBeNull * toEqual * toBeTrue * toBeFalse * toHaveSize * toHaveClass
This commit is contained in:
@@ -50,7 +50,7 @@ describe('Data', () => {
|
||||
|
||||
Data.set(div, TEST_KEY, data)
|
||||
|
||||
expect(Data.get(div, TEST_KEY)).toBe(data)
|
||||
expect(Data.get(div, TEST_KEY)).toEqual(data)
|
||||
})
|
||||
|
||||
it('should overwrite data if something is already stored', () => {
|
||||
@@ -60,6 +60,7 @@ describe('Data', () => {
|
||||
Data.set(div, TEST_KEY, data)
|
||||
Data.set(div, TEST_KEY, copy)
|
||||
|
||||
// Using `toBe` since spread creates a shallow copy
|
||||
expect(Data.get(div, TEST_KEY)).not.toBe(data)
|
||||
expect(Data.get(div, TEST_KEY)).toBe(copy)
|
||||
})
|
||||
@@ -76,7 +77,7 @@ describe('Data', () => {
|
||||
Data.set(div, TEST_KEY, data)
|
||||
Data.remove(div, UNKNOWN_KEY)
|
||||
|
||||
expect(Data.get(div, TEST_KEY)).toBe(data)
|
||||
expect(Data.get(div, TEST_KEY)).toEqual(data)
|
||||
})
|
||||
|
||||
it('should remove data for a given key', () => {
|
||||
@@ -99,7 +100,7 @@ describe('Data', () => {
|
||||
Data.set(div, UNKNOWN_KEY, copy)
|
||||
|
||||
expect(console.error).toHaveBeenCalled()
|
||||
expect(Data.get(div, UNKNOWN_KEY)).toBe(null)
|
||||
expect(Data.get(div, UNKNOWN_KEY)).toBeNull()
|
||||
})
|
||||
/* eslint-enable no-console */
|
||||
})
|
||||
|
@@ -105,10 +105,10 @@ describe('EventHandler', () => {
|
||||
EventHandler.on(outer, 'mouseleave', '.inner', delegateLeaveSpy)
|
||||
|
||||
EventHandler.on(sibling, 'mouseenter', () => {
|
||||
expect(enterSpy.calls.count()).toBe(2)
|
||||
expect(leaveSpy.calls.count()).toBe(2)
|
||||
expect(delegateEnterSpy.calls.count()).toBe(2)
|
||||
expect(delegateLeaveSpy.calls.count()).toBe(2)
|
||||
expect(enterSpy.calls.count()).toEqual(2)
|
||||
expect(leaveSpy.calls.count()).toEqual(2)
|
||||
expect(delegateEnterSpy.calls.count()).toEqual(2)
|
||||
expect(delegateLeaveSpy.calls.count()).toEqual(2)
|
||||
done()
|
||||
})
|
||||
|
||||
@@ -133,10 +133,10 @@ describe('EventHandler', () => {
|
||||
moveMouse(inner, outer)
|
||||
|
||||
setTimeout(() => {
|
||||
expect(enterSpy.calls.count()).toBe(1)
|
||||
expect(leaveSpy.calls.count()).toBe(1)
|
||||
expect(delegateEnterSpy.calls.count()).toBe(1)
|
||||
expect(delegateLeaveSpy.calls.count()).toBe(1)
|
||||
expect(enterSpy.calls.count()).toEqual(1)
|
||||
expect(leaveSpy.calls.count()).toEqual(1)
|
||||
expect(delegateEnterSpy.calls.count()).toEqual(1)
|
||||
expect(delegateLeaveSpy.calls.count()).toEqual(1)
|
||||
|
||||
// from outer to inner to sibling (adjacent)
|
||||
moveMouse(outer, inner)
|
||||
|
@@ -96,10 +96,10 @@ describe('Manipulator', () => {
|
||||
|
||||
const div = fixtureEl.querySelector('div')
|
||||
|
||||
expect(Manipulator.getDataAttribute(div, 'test')).toEqual(false)
|
||||
expect(Manipulator.getDataAttribute(div, 'test')).toBeFalse()
|
||||
|
||||
div.setAttribute('data-bs-test', 'true')
|
||||
expect(Manipulator.getDataAttribute(div, 'test')).toEqual(true)
|
||||
expect(Manipulator.getDataAttribute(div, 'test')).toBeTrue()
|
||||
|
||||
div.setAttribute('data-bs-test', '1')
|
||||
expect(Manipulator.getDataAttribute(div, 'test')).toEqual(1)
|
||||
@@ -152,8 +152,8 @@ describe('Manipulator', () => {
|
||||
body.append(forceScrollBars)
|
||||
|
||||
const scrollHandler = () => {
|
||||
expect(window.pageYOffset).toBe(scrollY)
|
||||
expect(window.pageXOffset).toBe(scrollX)
|
||||
expect(window.pageYOffset).toEqual(scrollY)
|
||||
expect(window.pageXOffset).toEqual(scrollX)
|
||||
|
||||
const newOffset = Manipulator.offset(div)
|
||||
|
||||
|
@@ -73,7 +73,7 @@ describe('SelectorEngine', () => {
|
||||
|
||||
describe('parents', () => {
|
||||
it('should return parents', () => {
|
||||
expect(SelectorEngine.parents(fixtureEl, 'body').length).toEqual(1)
|
||||
expect(SelectorEngine.parents(fixtureEl, 'body')).toHaveSize(1)
|
||||
})
|
||||
})
|
||||
|
||||
|
Reference in New Issue
Block a user