refactor tests

This commit is contained in:
Philipp Kühn
2020-10-31 23:56:31 +01:00
parent cb647de043
commit d810054492
6 changed files with 17 additions and 28 deletions

View File

@@ -1,11 +0,0 @@
/// <reference types="cypress" />
import { capitalize } from '@tiptap/core'
describe('capitalize test', () => {
it('capitalize a word', () => {
const capitalized = capitalize('test')
expect(capitalized).to.eq('Test')
})
})

View File

@@ -1,5 +0,0 @@
describe('example test', () => {
it('should work', () => {
expect('<p>Example Text</p>').to.eq('<p>Example Text</p>')
})
})

View File

@@ -1,41 +1,47 @@
/// <reference types="cypress" />
import { fromString } from '@tiptap/core'
import fromString from '@tiptap/core/src/utils/fromString'
describe('fromString', () => {
it('parse a string', () => {
it('should return a string', () => {
const value = fromString('test')
expect(value).to.eq('test')
})
it('parse a number', () => {
it('should convert to a number', () => {
const value = fromString('1')
expect(value).to.eq(1)
})
it('parse a floating number', () => {
it('should convert to a floating number', () => {
const value = fromString('1.2')
expect(value).to.eq(1.2)
})
it('parse not a number with exponent', () => {
it('should not convert to a number with exponent', () => {
const value = fromString('1e1')
expect(value).to.eq('1e1')
})
it('parse a boolean (true)', () => {
it('should convert to true', () => {
const value = fromString('true')
expect(value).to.eq(true)
})
it('parse a boolean (false)', () => {
it('should convert to false', () => {
const value = fromString('false')
expect(value).to.eq(false)
})
it('should return non-strings', () => {
const value = fromString(null)
expect(value).to.eq(null)
})
})