Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7419354
ve.dm.SourceConverter.test.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
ve.dm.SourceConverter.test.js
View Options
/*!
* VisualEditor DataModel SourceConverter tests.
*
* @copyright See AUTHORS.txt
*/
QUnit
.
module
(
've.dm.SourceConverter'
);
/* Tests */
QUnit
.
test
(
'conversion'
,
(
assert
)
=>
{
const
cases
=
[
{
msg
:
'Simple text with language options'
,
text
:
'foo'
,
textFromDataRange
:
'foo\n'
,
data
:
[
{
type
:
'paragraph'
},
...
'foo'
,
{
type
:
'/paragraph'
}
],
options
:
{
lang
:
'he'
,
dir
:
'rtl'
}
},
{
msg
:
'Multiple lines and whitespace'
,
text
:
'foo \n\n\tbar\n'
,
textFromDataRange
:
'foo \n\n\tbar\n\n'
,
data
:
[
{
type
:
'paragraph'
},
...
'foo '
,
{
type
:
'/paragraph'
},
{
type
:
'paragraph'
},
{
type
:
'/paragraph'
},
{
type
:
'paragraph'
},
...
'\tbar'
,
{
type
:
'/paragraph'
},
{
type
:
'paragraph'
},
{
type
:
'/paragraph'
}
]
},
{
msg
:
'Different newlines are all converted to paragraphs (CR/LF/CRLF)'
,
text
:
'asd\nasd\rasd\r\nasd'
,
textFromDataRange
:
'asd\nasd\nasd\nasd\n'
,
data
:
[
{
type
:
'paragraph'
},
...
'asd'
,
{
type
:
'/paragraph'
},
{
type
:
'paragraph'
},
...
'asd'
,
{
type
:
'/paragraph'
},
{
type
:
'paragraph'
},
...
'asd'
,
{
type
:
'/paragraph'
},
{
type
:
'paragraph'
},
...
'asd'
,
{
type
:
'/paragraph'
}
],
textRoundtrip
:
'asd\nasd\nasd\nasd'
}
];
cases
.
forEach
(
(
caseItem
)
=>
{
const
doc
=
ve
.
dm
.
sourceConverter
.
getModelFromSourceText
(
caseItem
.
text
,
caseItem
.
options
);
assert
.
deepEqual
(
doc
.
data
.
data
,
[
...
caseItem
.
data
,
{
type
:
'internalList'
},
{
type
:
'/internalList'
}
],
caseItem
.
msg
+
': getModelFromSourceText (data)'
);
if
(
caseItem
.
options
)
{
assert
.
deepEqual
(
{
lang
:
doc
.
getLang
(),
dir
:
doc
.
getDir
()
},
caseItem
.
options
,
caseItem
.
msg
+
': getModelFromSourceText (language options)'
);
}
assert
.
deepEqual
(
ve
.
dm
.
sourceConverter
.
getSourceTextFromModel
(
doc
),
caseItem
.
textRoundtrip
||
caseItem
.
text
,
caseItem
.
msg
+
': getSourceTextFromModel'
);
assert
.
deepEqual
(
ve
.
dm
.
sourceConverter
.
getDataFromSourceText
(
caseItem
.
text
),
caseItem
.
data
,
caseItem
.
msg
+
': getDataFromSourceText'
);
assert
.
deepEqual
(
ve
.
dm
.
sourceConverter
.
getDataFromSourceText
(
caseItem
.
text
,
true
),
caseItem
.
data
.
slice
(
1
,
-
1
),
caseItem
.
msg
+
': getDataFromSourceText (inline)'
);
assert
.
strictEqual
(
ve
.
dm
.
sourceConverter
.
getSourceTextFromDataRange
(
caseItem
.
data
),
caseItem
.
textFromDataRange
||
caseItem
.
textRoundtrip
||
caseItem
.
text
,
caseItem
.
msg
+
': getSourceTextFromDataRange'
);
// getSourceTextFromDataRange with a range argument is currently tested by ElementLinearData#getSourceText tests
}
);
}
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 22, 04:25 (1 d, 5 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
8e/83/7db8cea803041d2c0afff987a232
Default Alt Text
ve.dm.SourceConverter.test.js (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment