mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-21 09:16:30 -05:00
test: add tests for convertInlineStyleToMap
With the new code added, it seemed like good opportunity to add some tests here. Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
620b7d9fa8
commit
a55eac74fc
1 changed files with 29 additions and 0 deletions
29
html-to-react/src/utils/convertInlineStyleToMap.spec.ts
Normal file
29
html-to-react/src/utils/convertInlineStyleToMap.spec.ts
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2024 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { convertInlineStyleToMap } from './convertInlineStyleToMap.js'
|
||||
|
||||
describe('convertInlineStyleToMap', () => {
|
||||
it('should split on normal ;', () => {
|
||||
const styleObject = convertInlineStyleToMap('display: flex;flex-flow: row;')
|
||||
expect(Object.keys(styleObject)).toHaveLength(2)
|
||||
expect(styleObject.display).toEqual('flex')
|
||||
expect(styleObject.flexFlow).toEqual('row')
|
||||
})
|
||||
it('should not split on a ; in string', () => {
|
||||
const styleObject = convertInlineStyleToMap(
|
||||
"background-image: url('data:image/svg+xml;base64,...');"
|
||||
)
|
||||
expect(Object.keys(styleObject)).toHaveLength(1)
|
||||
expect(styleObject.backgroundImage).toEqual(
|
||||
"url('data:image/svg+xml;base64,...')"
|
||||
)
|
||||
})
|
||||
it('should not split on an escaped ;', () => {
|
||||
const styleObject = convertInlineStyleToMap('content: \\;;')
|
||||
expect(Object.keys(styleObject)).toHaveLength(1)
|
||||
expect(styleObject.content).toEqual('\\;')
|
||||
})
|
||||
})
|
Loading…
Reference in a new issue