add tests to fromString
This commit is contained in:
@@ -19,3 +19,4 @@ export { default as generateHTML } from './src/utils/generateHTML'
|
|||||||
export { default as getHTMLFromFragment } from './src/utils/getHTMLFromFragment'
|
export { default as getHTMLFromFragment } from './src/utils/getHTMLFromFragment'
|
||||||
export { default as getMarkAttrs } from './src/utils/getMarkAttrs'
|
export { default as getMarkAttrs } from './src/utils/getMarkAttrs'
|
||||||
export { default as mergeAttributes } from './src/utils/mergeAttributes'
|
export { default as mergeAttributes } from './src/utils/mergeAttributes'
|
||||||
|
export { default as fromString } from './src/utils/fromString'
|
||||||
|
|||||||
41
tests/cypress/integration/core/fromString.spec.ts
Normal file
41
tests/cypress/integration/core/fromString.spec.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
import { fromString } from '@tiptap/core'
|
||||||
|
|
||||||
|
describe('fromString', () => {
|
||||||
|
it('parse a string', () => {
|
||||||
|
const value = fromString('test')
|
||||||
|
|
||||||
|
expect(value).to.eq('test')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('parse a number', () => {
|
||||||
|
const value = fromString('1')
|
||||||
|
|
||||||
|
expect(value).to.eq(1)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('parse a floating number', () => {
|
||||||
|
const value = fromString('1.2')
|
||||||
|
|
||||||
|
expect(value).to.eq(1.2)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('parse not a number with exponent', () => {
|
||||||
|
const value = fromString('1e1')
|
||||||
|
|
||||||
|
expect(value).to.eq('1e1')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('parse a boolean (true)', () => {
|
||||||
|
const value = fromString('true')
|
||||||
|
|
||||||
|
expect(value).to.eq(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('parse a boolean (false)', () => {
|
||||||
|
const value = fromString('false')
|
||||||
|
|
||||||
|
expect(value).to.eq(false)
|
||||||
|
})
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user