Esanders has uploaded a new change for review.
https://gerrit.wikimedia.org/r/63421
Change subject: A basic ListAction test
......................................................................
A basic ListAction test
Just tests a simple wrap case.
Change-Id: If4df07eae1d70347dc55b57dc117f2ff5c7385df
---
M VisualEditor.hooks.php
A modules/ve/test/actions/ve.ListAction.test.js
M modules/ve/test/index.php
3 files changed, 58 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor
refs/changes/21/63421/1
diff --git a/VisualEditor.hooks.php b/VisualEditor.hooks.php
index 6ecbcd0..a9ce778 100644
--- a/VisualEditor.hooks.php
+++ b/VisualEditor.hooks.php
@@ -98,6 +98,7 @@
// VisualEditor Actions Tests
'actions/ve.FormatAction.test.js',
'actions/ve.IndentationAction.test.js',
+ 'actions/ve.ListAction.test.js',
// VisualEditor DataModel Tests
'dm/ve.dm.example.js',
'dm/ve.dm.AnnotationSet.test.js',
diff --git a/modules/ve/test/actions/ve.ListAction.test.js
b/modules/ve/test/actions/ve.ListAction.test.js
new file mode 100644
index 0000000..270c02f
--- /dev/null
+++ b/modules/ve/test/actions/ve.ListAction.test.js
@@ -0,0 +1,56 @@
+/*!
+ * VisualEditor Actions ListAction tests.
+ *
+ * @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
+ * @license The MIT License (MIT); see LICENSE.txt
+ */
+
+QUnit.module( 've.ListAction' );
+
+/* Tests */
+
+function runListConverterTest( assert, method, style, range,
expectedSelection, expectedData, msg ) {
+ var selection,
+ dom = ve.createDocumentFromHTML( ve.dm.example.html ),
+ surface = new ve.Surface( new ve.init.Target( $( '<div>' ) ),
dom ),
+ listAction = new ve.ListAction( surface ),
+ data = ve.copyArray(
surface.getModel().getDocument().getFullData() ),
+ originalData = ve.copyArray( data );
+
+ expectedData( data );
+
+ surface.getModel().change( null, range );
+ listAction[method]( style );
+
+ assert.deepEqual( surface.getModel().getDocument().getFullData(), data,
msg + ': data models match' );
+ assert.deepEqual( surface.getModel().getSelection(), expectedSelection,
msg + ': selections match' );
+
+ selection = surface.getModel().undo();
+
+ assert.deepEqual( surface.getModel().getDocument().getFullData(),
originalData, msg + ' (undo): data models match' );
+ assert.deepEqual( selection, range, msg + ' (undo): selections match' );
+
+ surface.destroy();
+}
+
+QUnit.test( 'wrap', function ( assert ) {
+ var i,
+ cases = [
+ {
+ 'range': new ve.Range( 55, 61 ),
+ 'style': 'bullet',
+ 'expectedSelection': new ve.Range( 55, 67 ),
+ 'expectedData': function ( data ) {
+ data.splice( 55, 0, { 'type': 'list',
'attributes': { 'style': 'bullet' } }, { 'type': 'listItem' } );
+ data.splice( 60, 0, { 'type':
'/listItem' }, { 'type': 'listItem' } );
+ data.splice( 65, 0, { 'type':
'/listItem' }, { 'type': '/list' } );
+ },
+ 'msg': 'wrapping two paragraphs in a list'
+ }
+ ];
+
+ QUnit.expect( cases.length * 4 );
+ for ( i = 0; i < cases.length; i++ ) {
+ runListConverterTest( assert, 'wrap', cases[i].style,
cases[i].range, cases[i].expectedSelection, cases[i].expectedData, cases[i].msg
);
+ }
+} );
diff --git a/modules/ve/test/index.php b/modules/ve/test/index.php
index bb17163..f6e240f 100644
--- a/modules/ve/test/index.php
+++ b/modules/ve/test/index.php
@@ -272,6 +272,7 @@
<script src="ve.Factory.test.js"></script>
<script src="actions/ve.FormatAction.test.js"></script>
<script src="actions/ve.IndentationAction.test.js"></script>
+ <script src="actions/ve.ListAction.test.js"></script>
<script src="dm/ve.dm.example.js"></script>
<script src="dm/ve.dm.AnnotationSet.test.js"></script>
<script src="dm/ve.dm.NodeFactory.test.js"></script>
--
To view, visit https://gerrit.wikimedia.org/r/63421
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If4df07eae1d70347dc55b57dc117f2ff5c7385df
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits