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

Commit386e030

Browse files
edg2sjenkins-bot
authored and
jenkins-bot
committed
Assert return value from action tests
Change-Id: I9803b8dc625ea73f3f8609e07ae2439e837ceb3b
1 parentbb646a4 commit386e030

File tree

4 files changed

+31
-15
lines changed

4 files changed

+31
-15
lines changed

‎tests/ui/actions/ve.ui.IndentationAction.test.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ QUnit.module( 've.ui.IndentationAction' );
99
/* Tests */
1010

1111
QUnit.test('increase/decrease',(assert)=>{
12+
constnoChange=()=>{};
1213
constcases=[
1314
{
1415
rangeOrSelection:newve.Range(13,14),
@@ -115,7 +116,8 @@ QUnit.test( 'increase/decrease', ( assert ) => {
115116
toCol:0,
116117
toRow:0
117118
},
118-
expectedData:()=>{},
119+
expectedData:noChange,
120+
expectedReturn:false,
119121
msg:'no-op on a table selection'
120122
}
121123
];

‎tests/ui/actions/ve.ui.LinkAction.test.js‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ QUnit.module( 've.ui.LinkAction' );
99
/* Tests */
1010

1111
QUnit.test('autolink',(assert)=>{
12+
constnoChange=()=>{};
1213
constcases=[
1314
{
1415
html:'<p>http://example.com xyz</p>',
@@ -90,19 +91,17 @@ QUnit.test( 'autolink', ( assert ) => {
9091
rangeOrSelection:newve.Range(1,19),
9192
method:'autolinkUrl',
9293
expectedRangeOrSelection:newve.Range(1,19),
93-
expectedData:()=>{
94-
// No change, no link
95-
},
94+
expectedData:noChange,
95+
expectedReturn:false,
9696
msg:'Don\'t link if followed by word characters'
9797
},
9898
{
9999
html:'<p>http://.) xyz</p>',
100100
rangeOrSelection:newve.Range(1,10),
101101
method:'autolinkUrl',
102102
expectedRangeOrSelection:newve.Range(1,10),
103-
expectedData:()=>{
104-
// No change, no link
105-
},
103+
expectedData:noChange,
104+
expectedReturn:false,
106105
msg:'Don\'t link if stripping leaves bare protocol'
107106
}
108107
];

‎tests/ui/actions/ve.ui.TableAction.test.js‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ QUnit.module( 've.ui.TableAction' );
99
/* Tests */
1010

1111
QUnit.test('create / insert / mergeCells / delete / changeCellStyle / moveRelative',(assert)=>{
12+
constnoChange=()=>{};
1213
consttableCellTail=[
1314
{type:'paragraph',internal:{generated:'wrapper'}},
1415
{type:'/paragraph'},
@@ -109,7 +110,8 @@ QUnit.test( 'create / insert / mergeCells / delete / changeCellStyle / moveRelat
109110
toRow:0
110111
},
111112
method:'create',
112-
expectedData:()=>{},
113+
expectedData:noChange,
114+
expectedReturn:false,
113115
expectedRangeOrSelection:{
114116
type:'table',
115117
tableRange:newve.Range(5,37),
@@ -124,46 +126,52 @@ QUnit.test( 'create / insert / mergeCells / delete / changeCellStyle / moveRelat
124126
rangeOrSelection:newve.Range(1),
125127
method:'insert',
126128
args:['col','after'],
127-
expectedData:()=>{},
129+
expectedData:noChange,
130+
expectedReturn:false,
128131
expectedRangeOrSelection:newve.Range(1),
129132
msg:'insert with linear selection is no-op'
130133
},
131134
{
132135
rangeOrSelection:newve.Range(1),
133136
method:'moveRelative',
134137
args:['col','after'],
135-
expectedData:()=>{},
138+
expectedData:noChange,
139+
expectedReturn:false,
136140
expectedRangeOrSelection:newve.Range(1),
137141
msg:'moveRelative with linear selection is no-op'
138142
},
139143
{
140144
rangeOrSelection:newve.Range(1),
141145
method:'move',
142146
args:['col',0],
143-
expectedData:()=>{},
147+
expectedData:noChange,
148+
expectedReturn:false,
144149
expectedRangeOrSelection:newve.Range(1),
145150
msg:'move with linear selection is no-op'
146151
},
147152
{
148153
rangeOrSelection:newve.Range(1),
149154
method:'delete',
150155
args:['table'],
151-
expectedData:()=>{},
156+
expectedData:noChange,
157+
expectedReturn:false,
152158
expectedRangeOrSelection:newve.Range(1),
153159
msg:'delete with linear selection is no-op'
154160
},
155161
{
156162
rangeOrSelection:newve.Range(1),
157163
method:'delete',
158164
args:['header'],
159-
expectedData:()=>{},
165+
expectedData:noChange,
166+
expectedReturn:false,
160167
expectedRangeOrSelection:newve.Range(1),
161168
msg:'changeCellStyle with linear selection is no-op'
162169
},
163170
{
164171
rangeOrSelection:newve.Range(1),
165172
method:'mergeCells',
166-
expectedData:()=>{},
173+
expectedData:noChange,
174+
expectedReturn:false,
167175
expectedRangeOrSelection:newve.Range(1),
168176
msg:'mergeCells with linear selection is no-op'
169177
},

‎tests/ve.test.utils.js‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@
371371
*@param {boolean} [caseItem.undo] Test that the action undoes cleanly
372372
*@param {Function} [caseItem.expectedData] Function to mutate linear data into expected data
373373
*@param {Function} [caseItem.expectedOriginalData] Function to mutate linear data into expected data after undo
374+
*@param {Function} [caseItem.expectedReturn=true] Expected return value from action method
374375
*/
375376
ve.test.utils.runActionTest=function(assert,caseItem){
376377
if(arguments.length>2){
@@ -418,7 +419,13 @@
418419
});
419420
}
420421

421-
action[caseItem.method]( ...(caseItem.args||[]));
422+
constexecuted=action[caseItem.method]( ...(caseItem.args||[]));
423+
424+
assert.strictEqual(
425+
executed,
426+
caseItem.expectedReturn!==undefined ?caseItem.expectedReturn :true,
427+
caseItem.msg+': action return value'
428+
);
422429

423430
constafterApply=()=>{
424431
constactualData=getSerializableData(surface.getModel().getDocument());

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp