lint & refactor PR #187

This commit is contained in:
Kevin Jahns
2020-04-01 23:39:27 +02:00
parent 195b26d90f
commit c87caafeb6
3 changed files with 28 additions and 22 deletions

View File

@@ -164,11 +164,19 @@ export const testToJson = tc => {
*/
export const testToDeltaEmbedAttributes = tc => {
const { text0 } = init(tc, { users: 1 })
text0.insertEmbed(0, { image: 'imageSrc.png' }, { width: 100 })
const [delta0] = text0.toDelta();
t.assert(!!delta0.attributes, 'toDelta correctly reads attributes')
const { text0: text1 } = init(tc, { users: 1 })
text1.insertEmbed(1, { image: 'imageSrc.png' })
const [delta1] = text1.toDelta();
t.assert(!delta1.hasOwnProperty('attributes'), 'toDelta does not set attributes key when no attributes are present')
text0.insert(0, 'ab', { bold: true })
text0.insertEmbed(1, { image: 'imageSrc.png' }, { width: 100 })
const delta0 = text0.toDelta()
t.compare(delta0, [{ insert: 'a', attributes: { bold: true } }, { insert: { image: 'imageSrc.png' }, attributes: { width: 100 } }, { insert: 'b', attributes: { bold: true } }])
}
/**
* @param {t.TestCase} tc
*/
export const testToDeltaEmbedNoAttributes = tc => {
const { text0 } = init(tc, { users: 1 })
text0.insert(0, 'ab', { bold: true })
text0.insertEmbed(1, { image: 'imageSrc.png' })
const delta0 = text0.toDelta()
t.compare(delta0, [{ insert: 'a', attributes: { bold: true } }, { insert: { image: 'imageSrc.png' } }, { insert: 'b', attributes: { bold: true } }], 'toDelta does not set attributes key when no attributes are present')
}