From 8cb36d608e38e4cfdfe01e876e35e3f031e68963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AB=A5=E6=B1=89?= <798008773@qq.com> Date: Sat, 11 Jul 2020 17:59:25 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E5=9B=9E=E8=BD=A6=E8=B7=B3=E5=87=BA?= =?UTF-8?q?=E5=BC=95=E7=94=A8=E6=A8=A1=E5=9D=97(=E6=9C=AA=E5=AE=8C?= =?UTF-8?q?=E6=88=90)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/menus/quote.test.ts | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/test/menus/quote.test.ts b/test/menus/quote.test.ts index c287d01..882d027 100644 --- a/test/menus/quote.test.ts +++ b/test/menus/quote.test.ts @@ -7,9 +7,11 @@ import Editor from '../../src/editor' import Quote from '../../src/menus/quote/index' import mockCmdFn from '../fns/command-mock' import { getMenuInstance } from '../fns/menus' +import { NodeType } from '../../src/text/getChildrenJSON' let editor: Editor let quoteMenu: Quote +let evt: any test('引用', () => { editor = createEditor(document, 'div1') // 赋值给全局变量 @@ -22,3 +24,36 @@ test('引用', () => { ;(quoteMenu as Quote).clickHandler() expect(document.execCommand).toBeCalledWith('formatBlock', false, '
') // mock fn 被调用 }) + +// test('引用末尾回车跳出引用', () => { +// editor = createEditor(document, 'div1') // 赋值给全局变量 + +// // 找到 quote 菜单 +// quoteMenu = getMenuInstance(editor, Quote) as Quote + +// // 执行点击事件,模拟引用 +// mockCmdFn(document) +// ;(quoteMenu as Quote).clickHandler() + +// // const keEvent = document.createEvent('Events') +// // keEvent.initKeyboardEvent('keydown', true, false, null, false, false, false, false, 13, 0) +// // keEvent.dispatchEvent(evt) + +// var event = document.createEvent('Events'); + +// // 定义事件名为'build'. +// event.initEvent('keydown', true, true); + +// // evt.document.createEvent('KeyboardEvent') +// // evt.initKeyEvent('keydown', true, false, null, false, false, false, false, 13, 0) +// // $(editor.$textElem.elems[0])?.dispatchEvent(evt) + +// const result = editor.txt.getJSON() +// expect(Array.isArray(result)).toBe(true) // 是一个数组 + +// const $node = result[result.length - 1] as NodeType + +// expect($node.tag).not.toBe('blockquote') + +// // expect(document.execCommand).toBeCalledWith('formatBlock', false, '') // mock fn 被调用 +// })