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

Commitb70ee4a

Browse files
edg2sjenkins-bot
authored and
jenkins-bot
committed
Tests: Make getImportedAnnotation utility shared
Change-Id: I711a135befbac40a3ecd3994ca3fb204d9fce9a1
1 parent3ec9cff commitb70ee4a

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,6 @@ QUnit.test( 'beforePaste/afterPaste', ( assert ) => {
308308
bold=ve.dm.example.bold,
309309
italic=ve.dm.example.italic,
310310
link=ve.dm.example.link('Foo'),
311-
// generateUniqueId is deterministic on the DummyPlatform
312-
imported=(source)=>({type:'meta/importedData',attributes:{source:source,eventId:ve.init.platform.generateUniqueId()}}),
313311
cases=[
314312
{
315313
rangeOrSelection:newve.Range(1),
@@ -2035,7 +2033,7 @@ QUnit.test( 'beforePaste/afterPaste', ( assert ) => {
20352033
{
20362034
type:'replace',
20372035
insert:[
2038-
...ve.dm.example.annotateText('Foo',imported(null))
2036+
...ve.dm.example.annotateText('Foo',ve.dm.example.getImportedAnnotation())
20392037
],
20402038
remove:[]
20412039
},
@@ -2064,7 +2062,7 @@ QUnit.test( 'beforePaste/afterPaste', ( assert ) => {
20642062
{
20652063
type:'replace',
20662064
insert:[
2067-
...ve.dm.example.annotateText('Foo',imported(null))
2065+
...ve.dm.example.annotateText('Foo',ve.dm.example.getImportedAnnotation())
20682066
],
20692067
remove:[]
20702068
},
@@ -2095,7 +2093,7 @@ QUnit.test( 'beforePaste/afterPaste', ( assert ) => {
20952093
{
20962094
type:'replace',
20972095
insert:[
2098-
...ve.dm.example.annotateText('Foo',[bold,imported(null)])
2096+
...ve.dm.example.annotateText('Foo',[bold,ve.dm.example.getImportedAnnotation()])
20992097
],
21002098
remove:[]
21012099
},
@@ -2115,7 +2113,7 @@ QUnit.test( 'beforePaste/afterPaste', ( assert ) => {
21152113
{
21162114
type:'replace',
21172115
insert:[
2118-
...ve.dm.example.annotateText('Foo',imported('googleDocs'))
2116+
...ve.dm.example.annotateText('Foo',ve.dm.example.getImportedAnnotation('googleDocs'))
21192117
],
21202118
remove:[]
21212119
},
@@ -2136,7 +2134,7 @@ QUnit.test( 'beforePaste/afterPaste', ( assert ) => {
21362134
{
21372135
type:'replace',
21382136
insert:[
2139-
...ve.dm.example.annotateText('Foo',imported('visualEditor'))
2137+
...ve.dm.example.annotateText('Foo',ve.dm.example.getImportedAnnotation('visualEditor'))
21402138
],
21412139
remove:[]
21422140
},
@@ -2156,7 +2154,7 @@ QUnit.test( 'beforePaste/afterPaste', ( assert ) => {
21562154
{
21572155
type:'replace',
21582156
insert:[
2159-
...ve.dm.example.annotateText('Foo',imported('libreOffice'))
2157+
...ve.dm.example.annotateText('Foo',ve.dm.example.getImportedAnnotation('libreOffice'))
21602158
],
21612159
remove:[]
21622160
},
@@ -2176,7 +2174,7 @@ QUnit.test( 'beforePaste/afterPaste', ( assert ) => {
21762174
{
21772175
type:'replace',
21782176
insert:[
2179-
...ve.dm.example.annotateText('Foo',imported('microsoftOffice'))
2177+
...ve.dm.example.annotateText('Foo',ve.dm.example.getImportedAnnotation('microsoftOffice'))
21802178
],
21812179
remove:[]
21822180
},
@@ -2196,7 +2194,7 @@ QUnit.test( 'beforePaste/afterPaste', ( assert ) => {
21962194
{
21972195
type:'replace',
21982196
insert:[
2199-
...ve.dm.example.annotateText('Foo',imported('plainText'))
2197+
...ve.dm.example.annotateText('Foo',ve.dm.example.getImportedAnnotation('plainText'))
22002198
],
22012199
remove:[]
22022200
},

‎tests/dm/ve.dm.example.js‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,22 @@ ve.dm.example.annHash = function ( tagName ) {
171171
returnve.dm.HashValueStore.prototype.hashOfValue(ann);
172172
};
173173

174+
/**
175+
* Get an importedData annotation for a given source.
176+
*
177+
* Tests using this should mock ve.init.platform.generateUniqueId to return a stable value.
178+
*
179+
*@param {string|null} [source=null]
180+
*@return {Object}
181+
*/
182+
ve.dm.example.getImportedAnnotation=(source=null)=>({
183+
type:'meta/importedData',
184+
attributes:{
185+
source:source,
186+
eventId:ve.init.platform.generateUniqueId()
187+
}
188+
});
189+
174190
// hash = store.hashOfValue( ve.dm.example.bold )
175191
ve.dm.example.boldHash='h49981eab0f8056ff';
176192
ve.dm.example.italicHash='hefd27ef3bf2041dd';

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp