Files
Compass/common/tests/unit/cleanDoc.test.ts
Martin Braquet ba9b3cfb06 Add pretty formatting (#29)
* Test

* Add pretty formatting

* Fix Tests

* Fix Tests

* Fix Tests

* Fix

* Add pretty formatting fix

* Fix

* Test

* Fix tests

* Clean typeckech

* Add prettier check

* Fix api tsconfig

* Fix api tsconfig

* Fix tsconfig

* Fix

* Fix

* Prettier
2026-02-20 17:32:27 +01:00

105 lines
2.3 KiB
TypeScript

import {cleanDoc} from '../../src/util/parse'
describe('cleanDoc', () => {
it('no change', () => {
const doc = {
type: 'doc',
content: [
{
type: 'paragraph',
content: [{type: 'text', text: 'Good morning Sir'}, {type: 'hardBreak'}],
},
{
type: 'paragraph',
content: [
{
type: 'text',
text: 'Hello World',
},
],
},
],
}
const cleanedDoc = cleanDoc(doc)
expect(cleanedDoc).toEqual(doc)
})
it('trims start hard breaks', () => {
const doc = {
type: 'doc',
content: [
{
type: 'paragraph',
content: [
{type: 'hardBreak'},
{type: 'hardBreak'},
{type: 'text', text: 'Good morning Sir'},
{type: 'hardBreak'},
],
},
{
type: 'paragraph',
content: [
{
type: 'text',
text: 'Hello World',
},
],
},
],
}
const cleanedDoc = cleanDoc(doc)
expect(cleanedDoc).toEqual({
type: 'doc',
content: [
{
type: 'paragraph',
content: [{type: 'text', text: 'Good morning Sir'}, {type: 'hardBreak'}],
},
{
type: 'paragraph',
content: [
{
type: 'text',
text: 'Hello World',
},
],
},
],
})
})
it('trims end hard breaks', () => {
const doc = {
type: 'doc',
content: [
{
type: 'paragraph',
content: [{type: 'text', text: 'Good morning Sir'}, {type: 'hardBreak'}],
},
{
type: 'paragraph',
content: [{type: 'text', text: 'Hello World'}, {type: 'hardBreak'}, {type: 'hardBreak'}],
},
],
}
const cleanedDoc = cleanDoc(doc)
expect(cleanedDoc).toEqual({
type: 'doc',
content: [
{
type: 'paragraph',
content: [{type: 'text', text: 'Good morning Sir'}, {type: 'hardBreak'}],
},
{
type: 'paragraph',
content: [
{
type: 'text',
text: 'Hello World',
},
],
},
],
})
})
})