Add unit test
This commit is contained in:
parent
3a38bdd416
commit
94e45b1b65
26
src/utils/getDefaultToolbarButtons.test.js
Normal file
26
src/utils/getDefaultToolbarButtons.test.js
Normal file
@ -0,0 +1,26 @@
|
||||
import getDefaultToolbarButtons from './getDefaultToolbarButtons.js'
|
||||
|
||||
describe('getDefaultToolbarButtons.js', () => {
|
||||
it('returns a non-empty array', () => {
|
||||
const basePath = '/'
|
||||
|
||||
const buttons = getDefaultToolbarButtons(basePath)
|
||||
|
||||
expect(buttons.length).toBeGreaterThan(0)
|
||||
})
|
||||
|
||||
it('uses the provided basePath in buttons with an svgUrl property', () => {
|
||||
const basePath = '/demo/'
|
||||
|
||||
const buttons = getDefaultToolbarButtons(basePath)
|
||||
const hasOneOrMoreButtonsWithSvgUrlProperty = buttons.some(btn =>
|
||||
btn.hasOwnProperty('svgUrl')
|
||||
)
|
||||
const usesBasePathInButtonSvgUrls = buttons.every(
|
||||
btn => !btn.hasOwnProperty('svgUrl') || btn.svgUrl.includes(basePath)
|
||||
)
|
||||
|
||||
expect(hasOneOrMoreButtonsWithSvgUrlProperty).toBeTruthy()
|
||||
expect(usesBasePathInButtonSvgUrls).toBeTruthy()
|
||||
})
|
||||
})
|
||||
Loading…
Reference in New Issue
Block a user