2020-11-01 06:45:36 +08:00
|
|
|
/// <reference types="cypress" />
|
|
|
|
|
2020-11-30 16:42:53 +08:00
|
|
|
import fromString from '@tiptap/core/src/utilities/fromString'
|
2020-11-01 06:45:36 +08:00
|
|
|
|
|
|
|
describe('fromString', () => {
|
2020-11-01 06:56:31 +08:00
|
|
|
it('should return a string', () => {
|
2020-11-01 06:45:36 +08:00
|
|
|
const value = fromString('test')
|
|
|
|
|
|
|
|
expect(value).to.eq('test')
|
|
|
|
})
|
|
|
|
|
2020-11-01 06:56:31 +08:00
|
|
|
it('should convert to a number', () => {
|
2020-11-01 06:45:36 +08:00
|
|
|
const value = fromString('1')
|
|
|
|
|
|
|
|
expect(value).to.eq(1)
|
|
|
|
})
|
|
|
|
|
2020-11-01 06:56:31 +08:00
|
|
|
it('should convert to a floating number', () => {
|
2020-11-01 06:45:36 +08:00
|
|
|
const value = fromString('1.2')
|
|
|
|
|
|
|
|
expect(value).to.eq(1.2)
|
|
|
|
})
|
|
|
|
|
2020-11-01 06:56:31 +08:00
|
|
|
it('should not convert to a number with exponent', () => {
|
2020-11-01 06:45:36 +08:00
|
|
|
const value = fromString('1e1')
|
|
|
|
|
|
|
|
expect(value).to.eq('1e1')
|
|
|
|
})
|
|
|
|
|
2020-11-01 06:56:31 +08:00
|
|
|
it('should convert to true', () => {
|
2020-11-01 06:45:36 +08:00
|
|
|
const value = fromString('true')
|
|
|
|
|
|
|
|
expect(value).to.eq(true)
|
|
|
|
})
|
|
|
|
|
2020-11-01 06:56:31 +08:00
|
|
|
it('should convert to false', () => {
|
2020-11-01 06:45:36 +08:00
|
|
|
const value = fromString('false')
|
|
|
|
|
|
|
|
expect(value).to.eq(false)
|
|
|
|
})
|
2020-11-01 06:56:31 +08:00
|
|
|
|
|
|
|
it('should return non-strings', () => {
|
|
|
|
const value = fromString(null)
|
|
|
|
|
|
|
|
expect(value).to.eq(null)
|
|
|
|
})
|
2020-11-01 06:45:36 +08:00
|
|
|
})
|