Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0f607c9

Browse files
committed
KeyDownHandlers: Improve test coverage
Change-Id: Iddabfa16ef418abcfda0ad50cef8cfb79367d1f2
1 parenta497e4a commit0f607c9

10 files changed

+73
-3
lines changed

‎karma.conf.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ module.exports = function ( config ) {
6464
'src/ce/nodes/ve.ce.CheckListItemNode.js',
6565
'src/ce/nodes/ve.ce.GeneratedContentNode.js',
6666
'src/ce/nodes/ve.ce.InternalItemNode.js',
67-
'src/ce/keydownhandlers/ve.ce.TableDeleteKeyDownHandler.js',
6867
// UI
6968
'src/ui/*.js',
7069
'!src/ui/ve.ui.Action.js',

‎tests/ce/keydownhandlers/ve.ce.LinearArrowKeyDownHandler.test.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ QUnit.module( 've.ce.LinearArrowKeyDownHandler', {
1616
QUnit.test('special key down: linear arrow keys',(assert)=>{
1717
constdone=assert.async(),
1818
supportsSelectionExtend=ve.supportsSelectionExtend,
19+
// Docs can be reused because they are never modified
1920
complexTableDoc=ve.dm.example.createExampleDocument('complexTable'),
2021
slugDoc=ve.dm.example.createExampleDocumentFromData([
2122
{type:'alienBlock'},{type:'/alienBlock'},

‎tests/ce/keydownhandlers/ve.ce.LinearDeleteKeyDownHandler.test.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ QUnit.test( 'special key down: linear backspace/delete', ( assert ) => {
3434
expectedDefaultPrevented:[false],
3535
msg:'Character deleted by backspace'
3636
},
37+
{
38+
rangeOrSelection:newve.Range(4),
39+
keys:['BACKSPACE'],
40+
readOnly:true,
41+
expectedData:noChange,
42+
expectedRangeOrSelection:newve.Range(4),
43+
expectedDefaultPrevented:[true],
44+
msg:'No change when surface is read-only'
45+
},
3746
{
3847
rangeOrSelection:newve.Range(3),
3948
keys:['DELETE'],

‎tests/ce/keydownhandlers/ve.ce.LinearEnterKeyDownHandler.test.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ QUnit.test( 'special key down: linear enter', ( assert ) => {
1717
constdone=assert.async(),
1818
noChange=()=>{},
1919
emptyList='<ul><li><p></p></li></ul>',
20+
// Doc can be reused because it is never modified
2021
alienDoc=ve.dm.example.createExampleDocument('alienData'),
2122
cases=[
2223
{
@@ -32,6 +33,14 @@ QUnit.test( 'special key down: linear enter', ( assert ) => {
3233
expectedRangeOrSelection:newve.Range(59),
3334
msg:'End of paragraph split by enter'
3435
},
36+
{
37+
rangeOrSelection:newve.Range(57),
38+
keys:['ENTER'],
39+
readOnly:true,
40+
expectedData:noChange,
41+
expectedRangeOrSelection:newve.Range(57),
42+
msg:'No change when surface is read-only'
43+
},
3544
{
3645
rangeOrSelection:newve.Range(57),
3746
keys:['CTRL+ENTER'],

‎tests/ce/keydownhandlers/ve.ce.LinearEscapeKeyDownHandler.test.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ QUnit.module( 've.ce.LinearEscapeKeyDownHandler', {
1616
QUnit.test('special key down: linear escape',(assert)=>{
1717
constdone=assert.async(),
1818
noChange=()=>{},
19+
// Doc can be reused because it is never modified
1920
mergedCellsDoc=ve.dm.example.createExampleDocument('mergedCells'),
2021
cases=[
2122
{

‎tests/ce/keydownhandlers/ve.ce.TableArrowKeyDownHandler.test.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ QUnit.module( 've.ce.TableArrowKeyDownHandler', {
1515

1616
QUnit.test('special key down: table arrow keys (complex movements)',(assert)=>{
1717
constdone=assert.async(),
18+
// Docs can be reused because they are never modified
1819
mergedCellsDoc=ve.dm.example.createExampleDocument('mergedCells'),
1920
complexTableDoc=ve.dm.example.createExampleDocument('complexTable'),
2021
cases=[

‎tests/ce/keydownhandlers/ve.ce.TableDeleteKeyDownHandler.test.js‎

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ QUnit.module( 've.ce.TableDeleteKeyDownHandler', {
1515

1616
QUnit.test('special key down: table backspace/delete',(assert)=>{
1717
constdone=assert.async(),
18-
mergedCellsDoc=ve.dm.example.createExampleDocument('mergedCells'),
18+
noChange=()=>{},
1919
cases=[
2020
{
21-
htmlOrDoc:mergedCellsDoc,
21+
htmlOrDoc:ve.dm.example.createExampleDocument('mergedCells'),
2222
rangeOrSelection:{
2323
type:'table',
2424
tableRange:newve.Range(0,171),
@@ -59,6 +59,52 @@ QUnit.test( 'special key down: table backspace/delete', ( assert ) => {
5959
toRow:1
6060
},
6161
msg:'Table cells emptied by backspace'
62+
},
63+
{
64+
htmlOrDoc:ve.dm.example.createExampleDocument('mergedCells'),
65+
rangeOrSelection:{
66+
type:'table',
67+
tableRange:newve.Range(0,171),
68+
fromCol:0,
69+
fromRow:0,
70+
toCol:2,
71+
toRow:1
72+
},
73+
keys:['BACKSPACE'],
74+
readOnly:true,
75+
expectedData:noChange,
76+
expectedRangeOrSelection:{
77+
type:'table',
78+
tableRange:newve.Range(0,171),
79+
fromCol:0,
80+
fromRow:0,
81+
toCol:2,
82+
toRow:1
83+
},
84+
msg:'No change when surface is read-only'
85+
},
86+
{
87+
htmlOrDoc:'<table><tbody><tr><td>Foo</td><td rel="ve:Alien">Alien</td></tr></tbody></table>',
88+
rangeOrSelection:{
89+
type:'table',
90+
tableRange:newve.Range(0,15),
91+
fromCol:0,
92+
fromRow:0,
93+
toCol:1,
94+
toRow:0
95+
},
96+
keys:['BACKSPACE'],
97+
expectedData:(data)=>{
98+
data.splice(5,3);
99+
},
100+
expectedRangeOrSelection:{
101+
type:'table',
102+
tableRange:newve.Range(0,12),
103+
fromCol:0,
104+
fromRow:0,
105+
toCol:1,
106+
toRow:0
107+
}
62108
}
63109
];
64110

‎tests/ce/keydownhandlers/ve.ce.TableEnterKeyDownHandler.test.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ QUnit.module( 've.ce.TableEnterKeyDownHandler', {
1717

1818
QUnit.test('special key down: table enter',(assert)=>{
1919
constdone=assert.async(),
20+
// Doc can be reused because it is never modified
2021
mergedCellsDoc=ve.dm.example.createExampleDocument('mergedCells'),
2122
cases=[
2223
{

‎tests/ce/keydownhandlers/ve.ce.TableF2KeyDownHandler.test.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ QUnit.module( 've.ce.TableF2KeyDownHandler', {
1717

1818
QUnit.test('special key down: table f2',(assert)=>{
1919
constdone=assert.async(),
20+
// Doc can be reused because it is never modified
2021
mergedCellsDoc=ve.dm.example.createExampleDocument('mergedCells'),
2122
cases=[
2223
{

‎tests/ce/ve.ce.Surface.test.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ ve.test.utils.runSurfaceHandleSpecialKeyTest = function ( assert, caseItem ) {
5858
'SHIFT+ENTER':'insertParagraph'
5959
};
6060

61+
view.isReadOnly=()=>!!caseItem.readOnly;
62+
6163
// Platform-variant
6264
execCommands[(ve.getSystemPlatform()==='mac' ?'CMD' :'CTRL')+'+ENTER']='insertParagraph';
6365

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp