Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanghc committed Oct 27, 2022
1 parent 45d1531 commit 92b7a48
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .release-it.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module.exports = {
tagName: "v${version}",
commitMessage: "release: v${version}",
requireCleanWorkingDir: false,
requireBranch: "main",
requireBranch: "master",
},
hooks: {
"before:init": ["git pull origin main", "npm run test"],
"before:init": ["git pull origin master", "npm run test"],
},
npm: {
publish: false,
Expand Down
2 changes: 1 addition & 1 deletion src/module/parse-elem-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { DOMElement } from '../utils/dom'
import { IDomEditor, SlateDescendant, SlateElement } from '@wangeditor/editor'
import { IDomEditor, SlateDescendant } from '@wangeditor/editor'
import { ImageElement } from './custom-types'


Expand Down
1 change: 0 additions & 1 deletion src/module/render-elem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import {h, VNode} from 'snabbdom'
import {DomEditor, IDomEditor, SlateElement} from '@wangeditor/editor'
import {ImageElement} from './custom-types'
import {data} from "autoprefixer";

interface IImageSize {
width?: string
Expand Down
2 changes: 1 addition & 1 deletion test/module/elem-to-html.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('float-image elem-to-html', () => {
const html = elemToHtmlConf.elemToHtml(elem, '')

expect(html).toBe(
`<img src="${src}" alt="logo" data-href="${href}" style="width:'100'; height:'80'; float:none"/>`
`<img src="${src}" alt="logo" data-href="${href}" style="width: 100;height: 80;float: none;"/>`
)
})
})
6 changes: 4 additions & 2 deletions test/module/parse-elem-html.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
* @author Yanghc
*/

import { $ } from 'dom7'
import $ from 'dom7'
import createEditor from '../utils/create-editor'
import {parseHtmlConf} from '../../src/module/parse-elem-html'

describe('parse elem html', () => {
const editor = createEditor()

it('parse html', () => {
debugger;
const $img = $(
'<img src="hello.png" alt="hello" data-href="http://localhost/" style="width: 10px; height: 5px;"/>'
'<img src="hello.png" alt="hello" data-href="http://localhost/" width="10px" height="5px" />'
)

// match selector
Expand All @@ -28,6 +29,7 @@ describe('parse elem html', () => {
style: {
width: '10px',
height: '5px',
float: '',
},
children: [{ text: '' }],
})
Expand Down
4 changes: 2 additions & 2 deletions test/module/render-elem.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ describe('float-image render-elem', () => {

const containerVnode = renderImageConf.renderElem(elem, null, editor) as any
expect(containerVnode.sel).toBe('div')
expect(containerVnode.data.className).toBe('w-e-image-container')
expect(containerVnode.data.props.className).toBe('w-e-image-container')
expect(containerVnode.data.style.width).toBe('100')
expect(containerVnode.data.style.height).toBe('80')
expect(containerVnode.data.style.float).toBe('none')

const imageVnode = containerVnode.children[0] as any
expect(imageVnode.sel).toBe('img')
expect(imageVnode.data.src).toBe(src)
expect(imageVnode.data['data-href']).toBe(href)
expect(imageVnode.data.dataHref).toBe(href)
})
})

0 comments on commit 92b7a48

Please sign in to comment.