2012-07-19 00:11:26 +00:00
|
|
|
/**
|
|
|
|
* VisualEditor data model Transaction tests.
|
2012-07-19 21:25:16 +00:00
|
|
|
*
|
2012-07-19 00:11:26 +00:00
|
|
|
* @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt
|
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
QUnit.module( 've.dm.Transaction' );
|
2012-04-20 01:11:08 +00:00
|
|
|
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
/* Helper methods */
|
2012-05-31 21:39:34 +00:00
|
|
|
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
function runBuilderTests( assert, cases ) {
|
|
|
|
var msg, tx, i;
|
|
|
|
for ( msg in cases ) {
|
|
|
|
tx = new ve.dm.Transaction();
|
|
|
|
for ( i = 0; i < cases[msg].calls.length; i++ ) {
|
2012-05-31 21:39:34 +00:00
|
|
|
tx[cases[msg].calls[i][0]].apply( tx, cases[msg].calls[i].slice( 1 ) );
|
|
|
|
}
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.deepEqual( tx.getOperations(), cases[msg].ops, msg + ': operations match' );
|
|
|
|
assert.deepEqual( tx.getLengthDifference(), cases[msg].diff, msg + ': length differences match' );
|
2012-05-31 21:39:34 +00:00
|
|
|
}
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
}
|
2012-05-31 21:39:34 +00:00
|
|
|
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
function runConstructorTests( assert, constructor, cases ) {
|
|
|
|
var msg, tx;
|
|
|
|
for ( msg in cases ) {
|
2012-05-31 21:39:34 +00:00
|
|
|
if ( cases[msg].ops ) {
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
tx = constructor.apply(
|
2012-05-31 21:39:34 +00:00
|
|
|
ve.dm.Transaction, cases[msg].args
|
|
|
|
);
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.deepEqual( tx.getOperations(), cases[msg].ops, msg + ': operations match' );
|
2012-05-31 21:39:34 +00:00
|
|
|
} else if ( cases[msg].exception ) {
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
/*jshint loopfunc:true */
|
|
|
|
assert.throws( function () {
|
Make use of new jshint options
* Restricting "camelcase":
No changes, we were passing all of these already
* Explicitly unrestricting "forin" and "plusplus"
These are off by default in node-jshint, but some distro of jshint
and editors that use their own wrapper around jshint instead of
node-jshint (Eclipse?) may have different defaults. Therefor
setting them to false explicitly. This also serves as a reminder
for the future so we'll always know we don't pass that, in case
we would want to change that.
* Fix order ("quotemark" before "regexp")
* Restricting "unused"
We're not passing all of this, which is why I've set it to false
for now. But I did put it in .jshintrc as placeholder.
I've fixed most of them, there's some left where there is no clean
solution.
* While at it fix a few issues:
- Unused variables ($target, $window)
- Bad practices (using jQuery context for find instead of creation)
- Redundant /*global */ comments
- Parameters that are not used and don't have documentation either
- Lines longer than 100 chars @ 4 spaces/tab
* Note:
- ve.ce.Surface.prototype.onChange takes two arguments but never
uses the former. And even the second one can be null/undefined.
Aside from that, the .change() function emits
another event for the transaction already. Looks like this
should be refactored a bit, two more separated events probably
or one that is actually used better.
- Also cleaned up a lot of comments, some of which were missing,
others were incorrect
- Reworked the contentChange event so we are no longer using the
word new as an object key; expanded a complex object into multiple
arguments being passed through the event to make it easier to work
with and document
Change-Id: I8490815a508c6c379d5f9a743bb4aefd14576aa6
2012-08-07 06:02:18 +00:00
|
|
|
constructor.apply(
|
2012-05-31 21:39:34 +00:00
|
|
|
ve.dm.Transaction, cases[msg].args
|
|
|
|
);
|
|
|
|
}, cases[msg].exception, msg + ': throw exception' );
|
|
|
|
}
|
|
|
|
}
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
}
|
2012-05-31 21:39:34 +00:00
|
|
|
|
2012-05-11 23:49:31 +00:00
|
|
|
/* Tests */
|
2012-05-07 18:45:31 +00:00
|
|
|
|
2012-10-25 20:06:07 +00:00
|
|
|
QUnit.test( 'newFromInsertion', 13, function ( assert ) {
|
|
|
|
var i, key,
|
|
|
|
doc = new ve.dm.Document( ve.copyArray( ve.dm.example.data ) ),
|
2012-07-05 19:55:52 +00:00
|
|
|
doc2 = new ve.dm.Document( [ { 'type': 'paragraph' }, { 'type': '/paragraph' } ] ),
|
2012-05-31 21:39:34 +00:00
|
|
|
cases = {
|
2012-06-04 13:41:32 +00:00
|
|
|
'paragraph before first element': {
|
2012-05-31 21:39:34 +00:00
|
|
|
'args': [doc, 0, [{ 'type': 'paragraph' }, '1', { 'type': '/paragraph' }]],
|
|
|
|
'ops': [
|
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': [],
|
|
|
|
'insert': [{ 'type': 'paragraph' }, '1', { 'type': '/paragraph' }]
|
|
|
|
},
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 61 }
|
2012-05-31 21:39:34 +00:00
|
|
|
]
|
|
|
|
},
|
2012-06-04 13:41:32 +00:00
|
|
|
'paragraph after last element': {
|
2012-06-08 05:08:49 +00:00
|
|
|
'args': [doc, 61, [{ 'type': 'paragraph' }, '1', { 'type': '/paragraph' }]],
|
2012-05-31 21:39:34 +00:00
|
|
|
'ops': [
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 61 },
|
2012-05-31 21:39:34 +00:00
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': [],
|
|
|
|
'insert': [{ 'type': 'paragraph' }, '1', { 'type': '/paragraph' }]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
'split paragraph': {
|
2012-06-08 05:08:49 +00:00
|
|
|
'args': [doc, 10, ['1', { 'type': '/paragraph' }, { 'type': 'paragraph' }]],
|
2012-05-31 21:39:34 +00:00
|
|
|
'ops': [
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 10 },
|
2012-05-31 21:39:34 +00:00
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': [],
|
|
|
|
'insert': ['1', { 'type': '/paragraph' }, { 'type': 'paragraph' }]
|
|
|
|
},
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 51 }
|
2012-05-31 21:39:34 +00:00
|
|
|
]
|
2012-06-04 13:41:32 +00:00
|
|
|
},
|
|
|
|
'paragraph inside a heading closes and reopens heading': {
|
|
|
|
'args': [doc, 2, [{ 'type': 'paragraph' }, 'F', 'O', 'O', { 'type': '/paragraph' }]],
|
|
|
|
'ops': [
|
|
|
|
{ 'type': 'retain', 'length': 2 },
|
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': [],
|
2012-06-04 14:55:31 +00:00
|
|
|
'insert': [{'type': '/heading' }, { 'type': 'paragraph' } , 'F', 'O', 'O', { 'type': '/paragraph' }, { 'type': 'heading', 'attributes': { 'level': 1 } }]
|
2012-06-04 13:41:32 +00:00
|
|
|
},
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 59 }
|
2012-06-04 13:41:32 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
'paragraph inside a list closes and reopens list': {
|
2012-06-08 05:08:49 +00:00
|
|
|
'args': [doc, 13, [{ 'type': 'paragraph' }, 'F', 'O', 'O', { 'type': '/paragraph' }]],
|
2012-06-04 13:41:32 +00:00
|
|
|
'ops': [
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 13 },
|
2012-06-04 13:41:32 +00:00
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': [],
|
2012-06-04 14:55:31 +00:00
|
|
|
'insert': [{'type': '/list' }, { 'type': 'paragraph' } , 'F', 'O', 'O', { 'type': '/paragraph' }, { 'type': 'list', 'attributes': { 'style': 'bullet' } }]
|
2012-06-04 13:41:32 +00:00
|
|
|
},
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 48 }
|
2012-06-04 13:41:32 +00:00
|
|
|
]
|
|
|
|
},
|
2012-06-08 05:08:49 +00:00
|
|
|
'tableCell inside the document is wrapped in a table, tableSection and tableRow': {
|
|
|
|
'args': [doc, 43, [{ 'type': 'tableCell', 'attributes': { 'style': 'data' } }, { 'type': 'paragraph' }, 'F', 'O', 'O', { 'type': '/paragraph' }, { 'type': '/tableCell' }]],
|
2012-06-04 13:41:32 +00:00
|
|
|
'ops': [
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 43 },
|
2012-06-04 13:41:32 +00:00
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': [],
|
2012-06-08 05:08:49 +00:00
|
|
|
// FIXME tableSection should have type=body
|
|
|
|
'insert': [{ 'type': 'table' }, { 'type': 'tableSection' }, { 'type': 'tableRow' }, { 'type': 'tableCell', 'attributes': { 'style': 'data' } }, { 'type': 'paragraph' }, 'F', 'O', 'O', { 'type': '/paragraph' }, { 'type': '/tableCell' }, { 'type': '/tableRow' }, { 'type': '/tableSection' }, { 'type': '/table' }]
|
2012-06-04 13:41:32 +00:00
|
|
|
},
|
|
|
|
{ 'type': 'retain', 'length': 18 }
|
|
|
|
]
|
|
|
|
},
|
2012-06-08 05:08:49 +00:00
|
|
|
'tableCell inside a paragraph is wrapped in a table, tableSection and tableRow and closes and reopens the paragraph': {
|
|
|
|
'args': [doc, 52, [{ 'type': 'tableCell', 'attributes': { 'style': 'data' } }, { 'type': 'paragraph' }, 'F', 'O', 'O', { 'type': '/paragraph' }, { 'type': '/tableCell' }]],
|
2012-06-04 13:41:32 +00:00
|
|
|
'ops': [
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 52 },
|
2012-06-04 13:41:32 +00:00
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': [],
|
2012-06-08 05:08:49 +00:00
|
|
|
// FIXME tableSection should have type=body
|
|
|
|
'insert': [{ 'type': '/paragraph' }, { 'type': 'table' }, { 'type': 'tableSection' }, { 'type': 'tableRow' }, { 'type': 'tableCell', 'attributes': { 'style': 'data' } }, { 'type': 'paragraph' }, 'F', 'O', 'O', { 'type': '/paragraph' }, { 'type': '/tableCell' }, { 'type': '/tableRow' }, { 'type': '/tableSection' }, { 'type': '/table' }, { 'type': 'paragraph' }]
|
2012-06-04 13:41:32 +00:00
|
|
|
},
|
|
|
|
{ 'type': 'retain', 'length': 9 }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
'text at a structural location in the document is wrapped in a paragraph': {
|
|
|
|
'args': [doc, 0, ['F', 'O', 'O']],
|
|
|
|
'ops': [
|
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': [],
|
|
|
|
'insert': [{ 'type': 'paragraph' }, 'F', 'O', 'O', { 'type': '/paragraph' }]
|
|
|
|
},
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 61 }
|
2012-06-04 13:41:32 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
'text inside a paragraph is not wrapped in a paragraph': {
|
2012-06-08 05:08:49 +00:00
|
|
|
'args': [doc, 16, ['F', 'O', 'O']],
|
2012-06-04 13:41:32 +00:00
|
|
|
'ops': [
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 16 },
|
2012-06-04 13:41:32 +00:00
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': [],
|
|
|
|
'insert': ['F', 'O', 'O']
|
|
|
|
},
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 45 }
|
2012-06-04 13:41:32 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
'text inside a heading is not wrapped in a paragraph': {
|
|
|
|
'args': [doc, 2, ['F', 'O', 'O']],
|
|
|
|
'ops': [
|
|
|
|
{ 'type': 'retain', 'length': 2 },
|
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': [],
|
|
|
|
'insert': ['F', 'O', 'O']
|
|
|
|
},
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 59 }
|
2012-06-04 13:41:32 +00:00
|
|
|
]
|
|
|
|
},
|
2012-06-08 05:08:49 +00:00
|
|
|
'text inside a tableSection is wrapped in a paragraph and closes and reopens the tableSection, tableRow and table': {
|
|
|
|
'args': [doc, 34, ['F', 'O', 'O']],
|
2012-06-04 13:41:32 +00:00
|
|
|
'ops': [
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 34 },
|
2012-06-04 13:41:32 +00:00
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': [],
|
2012-06-08 05:08:49 +00:00
|
|
|
'insert': [{ 'type': '/tableRow' }, { 'type': '/tableSection' }, { 'type': '/table' }, { 'type': 'paragraph' }, 'F', 'O', 'O', { 'type': '/paragraph' }, { 'type': 'table' }, { 'type': 'tableSection', 'attributes': { 'style': 'body' } }, { 'type': 'tableRow' } ]
|
2012-06-04 13:41:32 +00:00
|
|
|
},
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 27 }
|
2012-06-04 13:41:32 +00:00
|
|
|
]
|
2012-07-05 19:55:52 +00:00
|
|
|
},
|
|
|
|
'inserting two paragraphs into a document with just an empty paragraph': {
|
|
|
|
'args': [doc2, 1, ['F', 'O', 'O', { 'type': '/paragraph' }, { 'type': 'paragraph' }, 'B', 'A', 'R']],
|
|
|
|
'ops': [
|
|
|
|
{ 'type': 'retain', 'length': 1 },
|
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': [],
|
|
|
|
'insert': ['F', 'O', 'O', { 'type': '/paragraph' }, { 'type': 'paragraph' }, 'B', 'A', 'R']
|
|
|
|
},
|
|
|
|
{ 'type': 'retain', 'length': 1 }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
'inserting three paragraphs into a document with just an empty paragraph': {
|
|
|
|
'args': [doc2, 1, ['F', 'O', 'O', { 'type': '/paragraph' }, { 'type': 'paragraph' }, 'B', 'A', 'R', { 'type': '/paragraph' }, { 'type': 'paragraph' }, 'B', 'A', 'Z']],
|
|
|
|
'ops': [
|
|
|
|
{ 'type': 'retain', 'length': 1 },
|
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': [],
|
|
|
|
'insert': ['F', 'O', 'O', { 'type': '/paragraph' }, { 'type': 'paragraph' }, 'B', 'A', 'R', { 'type': '/paragraph' }, { 'type': 'paragraph' }, 'B', 'A', 'Z']
|
|
|
|
},
|
|
|
|
{ 'type': 'retain', 'length': 1 }
|
|
|
|
]
|
2012-05-31 21:39:34 +00:00
|
|
|
}
|
2012-06-04 13:41:32 +00:00
|
|
|
// TODO test cases for unclosed openings
|
|
|
|
// TODO test cases for (currently failing) unopened closings use case
|
|
|
|
// TODO analyze other possible cases (substrings of linmod data)
|
2012-05-31 21:39:34 +00:00
|
|
|
};
|
2012-08-24 02:06:36 +00:00
|
|
|
for ( key in cases ) {
|
|
|
|
for ( i = 0; i < cases[key].ops.length; i++ ) {
|
|
|
|
if ( cases[key].ops[i].remove ) {
|
|
|
|
ve.dm.example.preprocessAnnotations( cases[key].ops[i].remove );
|
|
|
|
}
|
|
|
|
if ( cases[key].ops[i].insert ) {
|
|
|
|
ve.dm.example.preprocessAnnotations( cases[key].ops[i].insert );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
runConstructorTests( assert, ve.dm.Transaction.newFromInsertion, cases );
|
2012-05-31 21:39:34 +00:00
|
|
|
} );
|
|
|
|
|
2012-10-25 20:06:07 +00:00
|
|
|
QUnit.test( 'newFromRemoval', 15, function ( assert ) {
|
|
|
|
var i, key,
|
|
|
|
alienDoc = new ve.dm.Document( ve.copyArray( ve.dm.example.alienData ) ),
|
2012-10-22 23:26:39 +00:00
|
|
|
doc = new ve.dm.Document( ve.copyArray( ve.dm.example.data ) ),
|
2012-05-31 21:39:34 +00:00
|
|
|
cases = {
|
|
|
|
'content in first element': {
|
|
|
|
'args': [doc, new ve.Range( 1, 3 )],
|
|
|
|
'ops': [
|
|
|
|
{ 'type': 'retain', 'length': 1 },
|
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': [
|
|
|
|
'a',
|
2012-10-06 00:34:12 +00:00
|
|
|
['b', [ ve.dm.example.bold ]]
|
2012-05-31 21:39:34 +00:00
|
|
|
],
|
|
|
|
'insert': []
|
|
|
|
},
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 58 }
|
2012-05-31 21:39:34 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
'content in last element': {
|
2012-06-08 05:08:49 +00:00
|
|
|
'args': [doc, new ve.Range( 59, 60 )],
|
2012-05-31 21:39:34 +00:00
|
|
|
'ops': [
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 59 },
|
2012-05-31 21:39:34 +00:00
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': ['m'],
|
|
|
|
'insert': []
|
|
|
|
},
|
|
|
|
{ 'type': 'retain', 'length': 1 }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
'first element': {
|
|
|
|
'args': [doc, new ve.Range( 0, 5 )],
|
|
|
|
'ops': [
|
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': [
|
|
|
|
{ 'type': 'heading', 'attributes': { 'level': 1 } },
|
|
|
|
'a',
|
2012-10-06 00:34:12 +00:00
|
|
|
['b', [ ve.dm.example.bold ]],
|
|
|
|
['c', [ ve.dm.example.italic ]],
|
2012-05-31 21:39:34 +00:00
|
|
|
{ 'type': '/heading' }
|
|
|
|
],
|
|
|
|
'insert': []
|
|
|
|
},
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 56 }
|
2012-05-31 21:39:34 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
'middle element with image': {
|
2012-06-08 05:08:49 +00:00
|
|
|
'args': [doc, new ve.Range( 38, 42 )],
|
2012-05-31 21:39:34 +00:00
|
|
|
'ops': [
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 38 },
|
2012-05-31 21:39:34 +00:00
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': [
|
|
|
|
'h',
|
|
|
|
{ 'type': 'image', 'attributes': { 'html/src': 'image.png' } },
|
|
|
|
{ 'type': '/image' },
|
|
|
|
'i'
|
|
|
|
],
|
|
|
|
'insert': []
|
|
|
|
},
|
|
|
|
{ 'type': 'retain', 'length': 19 }
|
|
|
|
]
|
|
|
|
},
|
2012-06-01 21:34:59 +00:00
|
|
|
'extra openings': {
|
|
|
|
'args': [doc, new ve.Range( 0, 7 )],
|
|
|
|
'ops': [
|
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': [
|
|
|
|
{ 'type': 'heading', 'attributes': { 'level': 1 } },
|
|
|
|
'a',
|
2012-10-06 00:34:12 +00:00
|
|
|
['b', [ ve.dm.example.bold ]],
|
|
|
|
['c', [ ve.dm.example.italic ]],
|
2012-06-01 21:34:59 +00:00
|
|
|
{ 'type': '/heading' }
|
|
|
|
],
|
|
|
|
'insert': []
|
|
|
|
},
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 56 }
|
2012-06-01 21:34:59 +00:00
|
|
|
]
|
|
|
|
},
|
2012-05-31 21:39:34 +00:00
|
|
|
'last element': {
|
2012-06-08 05:08:49 +00:00
|
|
|
'args': [doc, new ve.Range( 58, 61 )],
|
2012-05-31 21:39:34 +00:00
|
|
|
'ops': [
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 58 },
|
2012-05-31 21:39:34 +00:00
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': [{ 'type': 'paragraph' }, 'm', { 'type': '/paragraph' }],
|
|
|
|
'insert': []
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2012-06-01 21:34:59 +00:00
|
|
|
'extra closings': {
|
2012-06-08 05:08:49 +00:00
|
|
|
'args': [doc, new ve.Range( 31, 39 )],
|
2012-06-01 21:34:59 +00:00
|
|
|
'ops': [
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 38 },
|
2012-06-01 21:34:59 +00:00
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': ['h'],
|
|
|
|
'insert': []
|
|
|
|
},
|
|
|
|
{ 'type': 'retain', 'length': 22 }
|
|
|
|
]
|
|
|
|
},
|
2012-05-31 21:39:34 +00:00
|
|
|
'merge last two elements': {
|
2012-06-08 05:08:49 +00:00
|
|
|
'args': [doc, new ve.Range( 57, 59 )],
|
2012-05-31 21:39:34 +00:00
|
|
|
'ops': [
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 57 },
|
2012-05-31 21:39:34 +00:00
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': [{ 'type': '/paragraph' }, { 'type': 'paragraph' }],
|
|
|
|
'insert': []
|
|
|
|
},
|
|
|
|
{ 'type': 'retain', 'length': 2 }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
'strip out of paragraph in tableCell and paragraph in listItem': {
|
2012-06-08 05:08:49 +00:00
|
|
|
'args': [doc, new ve.Range( 10, 16 )],
|
2012-05-31 21:39:34 +00:00
|
|
|
'ops': [
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 10 },
|
2012-05-31 21:39:34 +00:00
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': ['d'],
|
|
|
|
'insert': []
|
|
|
|
},
|
|
|
|
{ 'type': 'retain', 'length': 4 },
|
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': ['e'],
|
|
|
|
'insert': []
|
|
|
|
},
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 45 }
|
2012-05-31 21:39:34 +00:00
|
|
|
]
|
2012-06-04 22:59:04 +00:00
|
|
|
},
|
|
|
|
'over first alien into paragraph': {
|
|
|
|
'args': [alienDoc, new ve.Range( 0, 4 )],
|
|
|
|
'ops': [
|
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': [{ 'type': 'alienBlock' }, { 'type': '/alienBlock' }],
|
|
|
|
'insert': []
|
|
|
|
},
|
|
|
|
{ 'type': 'retain', 'length': 1 },
|
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': ['a'],
|
|
|
|
'insert': []
|
|
|
|
},
|
|
|
|
{ 'type': 'retain', 'length': 6 }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
'out of paragraph over last alien': {
|
|
|
|
'args': [alienDoc, new ve.Range( 6, 10 )],
|
|
|
|
'ops': [
|
|
|
|
{ 'type': 'retain', 'length': 6 },
|
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': ['b'],
|
|
|
|
'insert': []
|
|
|
|
},
|
|
|
|
{ 'type': 'retain', 'length': 1 },
|
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': [{ 'type': 'alienBlock' }, { 'type': '/alienBlock' }],
|
|
|
|
'insert': []
|
|
|
|
}
|
|
|
|
]
|
2012-06-06 18:30:43 +00:00
|
|
|
},
|
|
|
|
'merging two paragraphs inside definitionListItems': {
|
2012-06-08 05:08:49 +00:00
|
|
|
'args': [doc, new ve.Range( 47, 51 )],
|
2012-06-06 18:30:43 +00:00
|
|
|
'ops': [
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 47 },
|
2012-06-06 18:30:43 +00:00
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': [{ 'type': '/paragraph' }, { 'type': '/definitionListItem' }, { 'type': 'definitionListItem', 'attributes': { 'style': 'definition' } }, { 'type': 'paragraph' }],
|
|
|
|
'insert': []
|
|
|
|
},
|
|
|
|
{ 'type': 'retain', 'length': 10 }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
'merging two paragraphs while also deleting some content': {
|
2012-06-08 05:08:49 +00:00
|
|
|
'args': [doc, new ve.Range( 56, 59 )],
|
2012-06-06 18:30:43 +00:00
|
|
|
'ops': [
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 56 },
|
2012-06-06 18:30:43 +00:00
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': ['l', { 'type': '/paragraph' }, { 'type': 'paragraph' } ],
|
|
|
|
'insert': []
|
|
|
|
},
|
|
|
|
{ 'type': 'retain', 'length': 2 }
|
|
|
|
]
|
2012-06-06 22:36:08 +00:00
|
|
|
},
|
|
|
|
'removing from a heading into a paragraph': {
|
2012-06-08 05:08:49 +00:00
|
|
|
'args': [doc, new ve.Range( 2, 57 )],
|
2012-06-06 22:36:08 +00:00
|
|
|
'ops': [
|
|
|
|
{ 'type': 'retain', 'length': 2 },
|
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': doc.getData().slice( 2, 4 ),
|
|
|
|
'insert': []
|
|
|
|
},
|
|
|
|
{ 'type': 'retain', 'length': 1 },
|
|
|
|
{
|
|
|
|
'type': 'replace',
|
2012-06-08 05:08:49 +00:00
|
|
|
'remove': doc.getData().slice( 5, 55 ),
|
2012-06-06 22:36:08 +00:00
|
|
|
'insert': []
|
|
|
|
},
|
|
|
|
{ 'type': 'retain', 'length': 1 },
|
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': ['l'],
|
|
|
|
'insert': []
|
|
|
|
},
|
|
|
|
{ 'type': 'retain', 'length': 4 }
|
|
|
|
]
|
2012-06-07 17:57:03 +00:00
|
|
|
},
|
|
|
|
'removing content from a paragraph in the middle': {
|
2012-06-08 05:08:49 +00:00
|
|
|
'args': [doc, new ve.Range( 56, 57 )],
|
2012-06-07 17:57:03 +00:00
|
|
|
'ops': [
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 56 },
|
2012-06-07 17:57:03 +00:00
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': ['l'],
|
|
|
|
'insert': []
|
|
|
|
},
|
|
|
|
{ 'type': 'retain', 'length': 4 }
|
|
|
|
]
|
2012-05-31 21:39:34 +00:00
|
|
|
}
|
|
|
|
};
|
2012-08-24 02:06:36 +00:00
|
|
|
for ( key in cases ) {
|
|
|
|
for ( i = 0; i < cases[key].ops.length; i++ ) {
|
|
|
|
if ( cases[key].ops[i].remove ) {
|
|
|
|
ve.dm.example.preprocessAnnotations( cases[key].ops[i].remove );
|
|
|
|
}
|
|
|
|
if ( cases[key].ops[i].insert ) {
|
|
|
|
ve.dm.example.preprocessAnnotations( cases[key].ops[i].insert );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
runConstructorTests( assert, ve.dm.Transaction.newFromRemoval, cases );
|
2012-05-31 21:39:34 +00:00
|
|
|
} );
|
|
|
|
|
2012-10-25 20:06:07 +00:00
|
|
|
QUnit.test( 'newFromAttributeChange', 4, function ( assert ) {
|
2012-10-22 23:26:39 +00:00
|
|
|
var doc = new ve.dm.Document( ve.copyArray( ve.dm.example.data ) ),
|
2012-05-21 19:20:51 +00:00
|
|
|
cases = {
|
|
|
|
'first element': {
|
|
|
|
'args': [doc, 0, 'level', 2],
|
|
|
|
'ops': [
|
|
|
|
{
|
|
|
|
'type': 'attribute',
|
|
|
|
'key': 'level',
|
|
|
|
'from': 1,
|
|
|
|
'to': 2
|
|
|
|
},
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 61 }
|
2012-05-21 19:20:51 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
'middle element': {
|
2012-06-08 05:08:49 +00:00
|
|
|
'args': [doc, 17, 'style', 'number'],
|
2012-05-21 19:20:51 +00:00
|
|
|
'ops': [
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 17 },
|
2012-05-21 19:20:51 +00:00
|
|
|
{
|
|
|
|
'type': 'attribute',
|
|
|
|
'key': 'style',
|
|
|
|
'from': 'bullet',
|
|
|
|
'to': 'number'
|
|
|
|
},
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 44 }
|
2012-05-21 19:20:51 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
'non-element': {
|
|
|
|
'args': [doc, 1, 'level', 2],
|
2012-08-08 17:48:53 +00:00
|
|
|
'exception': Error
|
2012-05-21 19:20:51 +00:00
|
|
|
},
|
|
|
|
'closing element': {
|
|
|
|
'args': [doc, 4, 'level', 2],
|
2012-08-08 17:48:53 +00:00
|
|
|
'exception': Error
|
2012-05-21 19:20:51 +00:00
|
|
|
}
|
|
|
|
};
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
runConstructorTests( assert, ve.dm.Transaction.newFromAttributeChange, cases );
|
2012-05-21 19:20:51 +00:00
|
|
|
} );
|
|
|
|
|
2012-10-25 20:06:07 +00:00
|
|
|
QUnit.test( 'newFromAnnotation', 4, function ( assert ) {
|
2012-10-06 00:34:12 +00:00
|
|
|
var bold = ve.dm.example.createAnnotation( ve.dm.example.bold ),
|
2012-10-22 23:26:39 +00:00
|
|
|
doc = new ve.dm.Document( ve.copyArray( ve.dm.example.data ) ),
|
2012-05-21 19:20:51 +00:00
|
|
|
cases = {
|
|
|
|
'over plain text': {
|
2012-10-06 00:34:12 +00:00
|
|
|
'args': [doc, new ve.Range( 1, 2 ), 'set', bold],
|
2012-05-21 19:20:51 +00:00
|
|
|
'ops': [
|
|
|
|
{ 'type': 'retain', 'length': 1 },
|
|
|
|
{
|
|
|
|
'type': 'annotate',
|
|
|
|
'method': 'set',
|
|
|
|
'bias': 'start',
|
2012-10-06 00:34:12 +00:00
|
|
|
'annotation': bold
|
2012-05-21 19:20:51 +00:00
|
|
|
},
|
|
|
|
{ 'type': 'retain', 'length': 1 },
|
|
|
|
{
|
|
|
|
'type': 'annotate',
|
|
|
|
'method': 'set',
|
|
|
|
'bias': 'stop',
|
2012-10-06 00:34:12 +00:00
|
|
|
'annotation': bold
|
2012-05-21 19:20:51 +00:00
|
|
|
},
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 59 }
|
2012-05-21 19:20:51 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
'over annotated text': {
|
2012-10-06 00:34:12 +00:00
|
|
|
'args': [doc, new ve.Range( 1, 4 ), 'set', bold],
|
2012-05-21 19:20:51 +00:00
|
|
|
'ops': [
|
|
|
|
{ 'type': 'retain', 'length': 1 },
|
|
|
|
{
|
|
|
|
'type': 'annotate',
|
|
|
|
'method': 'set',
|
|
|
|
'bias': 'start',
|
2012-10-06 00:34:12 +00:00
|
|
|
'annotation': bold
|
2012-05-21 19:20:51 +00:00
|
|
|
},
|
|
|
|
{ 'type': 'retain', 'length': 1 },
|
|
|
|
{
|
|
|
|
'type': 'annotate',
|
|
|
|
'method': 'set',
|
|
|
|
'bias': 'stop',
|
2012-10-06 00:34:12 +00:00
|
|
|
'annotation': bold
|
2012-05-21 19:20:51 +00:00
|
|
|
},
|
|
|
|
{ 'type': 'retain', 'length': 1 },
|
|
|
|
{
|
|
|
|
'type': 'annotate',
|
|
|
|
'method': 'set',
|
|
|
|
'bias': 'start',
|
2012-10-06 00:34:12 +00:00
|
|
|
'annotation': bold
|
2012-05-21 19:20:51 +00:00
|
|
|
},
|
|
|
|
{ 'type': 'retain', 'length': 1 },
|
|
|
|
{
|
|
|
|
'type': 'annotate',
|
|
|
|
'method': 'set',
|
|
|
|
'bias': 'stop',
|
2012-10-06 00:34:12 +00:00
|
|
|
'annotation': bold
|
2012-05-21 19:20:51 +00:00
|
|
|
},
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 57 }
|
2012-05-21 19:20:51 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
'over elements': {
|
2012-10-06 00:34:12 +00:00
|
|
|
'args': [doc, new ve.Range( 4, 9 ), 'set', bold],
|
2012-05-21 19:20:51 +00:00
|
|
|
'ops': [
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 61 }
|
2012-05-21 19:20:51 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
'over elements and content': {
|
2012-10-06 00:34:12 +00:00
|
|
|
'args': [doc, new ve.Range( 3, 11 ), 'set', bold],
|
2012-05-21 19:20:51 +00:00
|
|
|
'ops': [
|
|
|
|
{ 'type': 'retain', 'length': 3 },
|
|
|
|
{
|
|
|
|
'type': 'annotate',
|
|
|
|
'method': 'set',
|
|
|
|
'bias': 'start',
|
2012-10-06 00:34:12 +00:00
|
|
|
'annotation': bold
|
2012-05-21 19:20:51 +00:00
|
|
|
},
|
|
|
|
{ 'type': 'retain', 'length': 1 },
|
|
|
|
{
|
|
|
|
'type': 'annotate',
|
|
|
|
'method': 'set',
|
|
|
|
'bias': 'stop',
|
2012-10-06 00:34:12 +00:00
|
|
|
'annotation': bold
|
2012-05-21 19:20:51 +00:00
|
|
|
},
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 6 },
|
2012-05-21 19:20:51 +00:00
|
|
|
{
|
|
|
|
'type': 'annotate',
|
|
|
|
'method': 'set',
|
|
|
|
'bias': 'start',
|
2012-10-06 00:34:12 +00:00
|
|
|
'annotation': bold
|
2012-05-21 19:20:51 +00:00
|
|
|
},
|
|
|
|
{ 'type': 'retain', 'length': 1 },
|
|
|
|
{
|
|
|
|
'type': 'annotate',
|
|
|
|
'method': 'set',
|
|
|
|
'bias': 'stop',
|
2012-10-06 00:34:12 +00:00
|
|
|
'annotation': bold
|
2012-05-21 19:20:51 +00:00
|
|
|
},
|
2012-06-08 05:08:49 +00:00
|
|
|
{ 'type': 'retain', 'length': 50 }
|
2012-05-21 19:20:51 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
};
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
runConstructorTests( assert, ve.dm.Transaction.newFromAnnotation, cases );
|
2012-05-21 19:20:51 +00:00
|
|
|
} );
|
|
|
|
|
2012-10-25 20:06:07 +00:00
|
|
|
QUnit.test( 'newFromContentBranchConversion', 2, function ( assert ) {
|
2012-10-22 23:26:39 +00:00
|
|
|
var doc = new ve.dm.Document( ve.copyArray( ve.dm.example.data ) ),
|
2012-08-24 02:06:36 +00:00
|
|
|
i, key,
|
2012-06-11 22:58:29 +00:00
|
|
|
cases = {
|
|
|
|
'range inside a heading, convert to paragraph': {
|
|
|
|
'args': [doc, new ve.Range( 1, 2 ), 'paragraph'],
|
|
|
|
'ops': [
|
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': [{ 'type': 'heading', 'attributes': { 'level': 1 } }],
|
|
|
|
'insert': [{ 'type': 'paragraph' }]
|
|
|
|
},
|
|
|
|
{ 'type': 'retain', 'length': 3 },
|
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': [{ 'type': '/heading' }],
|
|
|
|
'insert': [{ 'type': '/paragraph' }]
|
|
|
|
},
|
|
|
|
{ 'type': 'retain', 'length': 56 }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
'range around 2 paragraphs, convert to preformatted': {
|
|
|
|
'args': [doc, new ve.Range( 50, 58 ), 'preformatted'],
|
|
|
|
'ops': [
|
|
|
|
{ 'type': 'retain', 'length': 50 },
|
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': [{ 'type': 'paragraph' }],
|
|
|
|
'insert': [{ 'type': 'preformatted' }]
|
|
|
|
},
|
|
|
|
{ 'type': 'retain', 'length': 1 },
|
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': [{ 'type': '/paragraph' }],
|
|
|
|
'insert': [{ 'type': '/preformatted' }]
|
|
|
|
},
|
|
|
|
{ 'type': 'retain', 'length': 2 },
|
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': [{ 'type': 'paragraph' }],
|
|
|
|
'insert': [{ 'type': 'preformatted' }]
|
|
|
|
},
|
|
|
|
{ 'type': 'retain', 'length': 1 },
|
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': [{ 'type': '/paragraph' }],
|
|
|
|
'insert': [{ 'type': '/preformatted' }]
|
|
|
|
},
|
|
|
|
{ 'type': 'retain', 'length': 3 }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
};
|
2012-08-24 02:06:36 +00:00
|
|
|
for ( key in cases ) {
|
|
|
|
for ( i = 0; i < cases[key].ops.length; i++ ) {
|
|
|
|
if ( cases[key].ops[i].remove ) {
|
|
|
|
ve.dm.example.preprocessAnnotations( cases[key].ops[i].remove );
|
|
|
|
}
|
|
|
|
if ( cases[key].ops[i].insert ) {
|
|
|
|
ve.dm.example.preprocessAnnotations( cases[key].ops[i].insert );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
runConstructorTests(
|
|
|
|
assert,
|
|
|
|
ve.dm.Transaction.newFromContentBranchConversion,
|
|
|
|
cases
|
2012-06-11 22:58:29 +00:00
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
2012-10-25 20:06:07 +00:00
|
|
|
QUnit.test( 'newFromWrap', 8, function ( assert ) {
|
|
|
|
var i, key,
|
|
|
|
doc = new ve.dm.Document( ve.copyArray( ve.dm.example.data ) ),
|
2012-06-13 23:17:23 +00:00
|
|
|
cases = {
|
|
|
|
'changes a heading to a paragraph': {
|
Remainder JSHint fixes on modules/ve/*
[jshint]
ce/ve.ce.Surface.js: line 670, col 9, Too many var statements.
ce/ve.ce.Surface.js: line 695, col 6, Missing semicolon.
ce/ve.ce.Surface.js: line 726, col 22, Expected '===' and instead saw '=='.
ce/ve.ce.Surface.js: line 726, col 41, Expected '===' and instead saw '=='.
ce/ve.ce.Surface.js: line 733, col 13, Too many var statements.
ce/ve.ce.Surface.js: line 734, col 24, Expected '===' and instead saw '=='.
ce/ve.ce.Surface.js: line 1013, col 13, Too many var statements.
ce/ve.ce.Surface.js: line 1019, col 17, Too many var statements.
ce/ve.ce.Surface.js: line 1023, col 18, Too many ar statements.
ce/ve.ce.Surface.js: line 1027, col 13, Too many var statements.
dm/annotations/ve.dm.LinkAnnotation.js: line 70, col 52, Insecure '.'.
dm/ve.dm.Converter.js: line 383, col 29, Empty block.
dm/ve.dm.Converter.js: line 423, col 33, Empty block.
Commands:
* jshint .
* ack '(if|else|function|switch|for|while)\('
* Sublime Text 2:
Find(*): (if|else|function|switch|for|while)\(
Replace: $1 (
* ack ' ' -Q # double spaces, except in certain comments
Change-Id: I8e34bf2924bc8688fdf8acef08bbc4f6707e93be
2012-09-02 21:45:01 +00:00
|
|
|
'args': [doc, new ve.Range( 1, 4 ), [ { 'type': 'heading', 'attributes': { 'level': 1 } } ], [ { 'type': 'paragraph' } ], [], []],
|
2012-06-13 23:17:23 +00:00
|
|
|
'ops': [
|
|
|
|
{ 'type': 'replace', 'remove': [ { 'type': 'heading', 'attributes': { 'level': 1 } } ], 'insert': [ { 'type': 'paragraph' } ] },
|
|
|
|
{ 'type': 'retain', 'length': 3 },
|
|
|
|
{ 'type': 'replace', 'remove': [ { 'type': '/heading' } ], 'insert': [ { 'type': '/paragraph' } ] },
|
|
|
|
{ 'type': 'retain', 'length': 56 }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
'unwraps a list': {
|
|
|
|
'args': [doc, new ve.Range( 13, 25 ), [ { 'type': 'list' } ], [], [ { 'type': 'listItem' } ], []],
|
|
|
|
'ops': [
|
|
|
|
{ 'type': 'retain', 'length': 12 },
|
|
|
|
{ 'type': 'replace', 'remove': [ { 'type': 'list', 'attributes': { 'style': 'bullet' } } ], 'insert': [] },
|
|
|
|
{ 'type': 'replace', 'remove': [ { 'type': 'listItem' } ], 'insert': [] },
|
|
|
|
{ 'type': 'retain', 'length': 10 },
|
|
|
|
{ 'type': 'replace', 'remove': [ { 'type': '/listItem' } ], 'insert': [] },
|
|
|
|
{ 'type': 'replace', 'remove': [ { 'type': '/list' } ], 'insert': [] },
|
|
|
|
{ 'type': 'retain', 'length': 35 }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
'replaces a table with a list': {
|
|
|
|
'args': [doc, new ve.Range( 9, 33 ), [ { 'type': 'table' }, { 'type': 'tableSection' }, { 'type': 'tableRow' }, { 'type': 'tableCell' } ], [ { 'type': 'list' }, { 'type': 'listItem' } ], [], []],
|
|
|
|
'ops': [
|
|
|
|
{ 'type': 'retain', 'length': 5 },
|
|
|
|
{ 'type': 'replace', 'remove': [ { 'type': 'table' }, { 'type': 'tableSection', 'attributes': { 'style': 'body' } }, { 'type': 'tableRow' }, { 'type': 'tableCell', 'attributes': { 'style': 'data' } } ], 'insert': [ { 'type': 'list' }, { 'type': 'listItem' } ] },
|
|
|
|
{ 'type': 'retain', 'length': 24 },
|
|
|
|
{ 'type': 'replace', 'remove': [ { 'type': '/tableCell' }, { 'type': '/tableRow' }, { 'type': '/tableSection' }, { 'type': '/table' } ], 'insert': [ { 'type': '/listItem' }, { 'type': '/list' } ] },
|
|
|
|
{ 'type': 'retain', 'length': 24 }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
'wraps two adjacent paragraphs in a list': {
|
|
|
|
'args': [doc, new ve.Range( 55, 61 ), [], [ { 'type': 'list', 'attributes': { 'style': 'number' } } ], [], [ { 'type': 'listItem' } ]],
|
|
|
|
'ops': [
|
|
|
|
{ 'type': 'retain', 'length': 55 },
|
|
|
|
{ 'type': 'replace', 'remove': [], 'insert': [ { 'type': 'list', 'attributes': { 'style': 'number' } } ] },
|
|
|
|
{ 'type': 'replace', 'remove': [], 'insert': [ { 'type': 'listItem' } ] },
|
|
|
|
{ 'type': 'retain', 'length': 3 },
|
|
|
|
{ 'type': 'replace', 'remove': [], 'insert': [ { 'type': '/listItem' } ] },
|
|
|
|
{ 'type': 'replace', 'remove': [], 'insert': [ { 'type': 'listItem' } ] },
|
|
|
|
{ 'type': 'retain', 'length': 3 },
|
|
|
|
{ 'type': 'replace', 'remove': [], 'insert': [ { 'type': '/listItem' } ] },
|
|
|
|
{ 'type': 'replace', 'remove': [], 'insert': [ { 'type': '/list' } ] }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
'wraps two adjacent paragraphs in a definitionList': {
|
|
|
|
'args': [doc, new ve.Range( 55, 61 ), [], [ { 'type': 'definitionList' } ], [], [ { 'type': 'definitionListItem', 'attributes': { 'style': 'term' } } ]],
|
|
|
|
'ops': [
|
|
|
|
{ 'type': 'retain', 'length': 55 },
|
|
|
|
{ 'type': 'replace', 'remove': [], 'insert': [ { 'type': 'definitionList' } ] },
|
|
|
|
{ 'type': 'replace', 'remove': [], 'insert': [ { 'type': 'definitionListItem', 'attributes': { 'style': 'term' } } ] },
|
|
|
|
{ 'type': 'retain', 'length': 3 },
|
|
|
|
{ 'type': 'replace', 'remove': [], 'insert': [ { 'type': '/definitionListItem' } ] },
|
|
|
|
{ 'type': 'replace', 'remove': [], 'insert': [ { 'type': 'definitionListItem', 'attributes': { 'style': 'term' } } ] },
|
|
|
|
{ 'type': 'retain', 'length': 3 },
|
|
|
|
{ 'type': 'replace', 'remove': [], 'insert': [ { 'type': '/definitionListItem' } ] },
|
|
|
|
{ 'type': 'replace', 'remove': [], 'insert': [ { 'type': '/definitionList' } ] }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
'checks integrity of unwrapOuter parameter': {
|
|
|
|
'args': [doc, new ve.Range( 13, 32 ), [ { 'type': 'table' } ], [], [], []],
|
2012-08-08 17:48:53 +00:00
|
|
|
'exception': Error
|
2012-06-13 23:17:23 +00:00
|
|
|
},
|
|
|
|
'checks integrity of unwrapEach parameter': {
|
|
|
|
'args': [doc, new ve.Range( 13, 32 ), [ { 'type': 'list' } ], [], [ { 'type': 'paragraph' } ], []],
|
2012-08-08 17:48:53 +00:00
|
|
|
'exception': Error
|
2012-06-13 23:17:23 +00:00
|
|
|
},
|
|
|
|
'checks that unwrapOuter fits before the range': {
|
|
|
|
'args': [doc, new ve.Range( 1, 4 ), [ { 'type': 'listItem' }, { 'type': 'paragraph' } ], [], [], []],
|
2012-08-08 17:48:53 +00:00
|
|
|
'exception': Error
|
2012-06-13 23:17:23 +00:00
|
|
|
}
|
|
|
|
};
|
2012-08-24 02:06:36 +00:00
|
|
|
for ( key in cases ) {
|
|
|
|
for ( i = 0; cases[key].ops && i < cases[key].ops.length; i++ ) {
|
|
|
|
if ( cases[key].ops[i].remove ) {
|
|
|
|
ve.dm.example.preprocessAnnotations( cases[key].ops[i].remove );
|
|
|
|
}
|
|
|
|
if ( cases[key].ops[i].insert ) {
|
|
|
|
ve.dm.example.preprocessAnnotations( cases[key].ops[i].insert );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
runConstructorTests(
|
|
|
|
assert,
|
|
|
|
ve.dm.Transaction.newFromWrap,
|
|
|
|
cases
|
2012-06-13 23:17:23 +00:00
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
QUnit.test( 'translateOffset', function ( assert ) {
|
|
|
|
var tx, mapping, offset;
|
2012-06-20 21:37:13 +00:00
|
|
|
// Populate a transaction with bogus data
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
tx = new ve.dm.Transaction();
|
2012-06-20 21:37:13 +00:00
|
|
|
tx.pushReplace( [], ['a','b','c'] );
|
|
|
|
tx.pushRetain ( 5 );
|
|
|
|
tx.pushReplace( ['d', 'e', 'f', 'g'], [] );
|
|
|
|
tx.pushRetain( 2 );
|
|
|
|
tx.pushStartAnnotating( 'set', { 'type': 'textStyle/bold' } );
|
|
|
|
tx.pushRetain( 1 );
|
|
|
|
tx.pushReplace( ['h'], ['i', 'j', 'k', 'l', 'm'] );
|
2012-08-30 22:26:43 +00:00
|
|
|
tx.pushRetain( 2 );
|
|
|
|
tx.pushReplace( [], ['n', 'o', 'p'] );
|
2012-06-20 21:37:13 +00:00
|
|
|
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
mapping = {
|
2012-08-30 22:26:43 +00:00
|
|
|
0: 3,
|
2012-06-20 21:37:13 +00:00
|
|
|
1: 4,
|
|
|
|
2: 5,
|
|
|
|
3: 6,
|
|
|
|
4: 7,
|
|
|
|
5: 8,
|
2012-06-21 07:08:23 +00:00
|
|
|
6: 8,
|
|
|
|
7: 8,
|
|
|
|
8: 8,
|
2012-06-20 21:37:13 +00:00
|
|
|
9: 8,
|
|
|
|
10: 9,
|
|
|
|
11: 10,
|
2012-08-30 22:26:43 +00:00
|
|
|
12: 16,
|
|
|
|
13: 16,
|
|
|
|
14: 17,
|
|
|
|
15: 21,
|
|
|
|
16: 22
|
2012-06-20 21:37:13 +00:00
|
|
|
};
|
2012-08-30 22:26:43 +00:00
|
|
|
QUnit.expect( 17 );
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
for ( offset in mapping ) {
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.strictEqual( tx.translateOffset( Number( offset ) ), mapping[offset] );
|
2012-06-20 21:37:13 +00:00
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
2012-10-10 18:08:33 +00:00
|
|
|
QUnit.test( 'translateOffsetReversed', function ( assert ) {
|
|
|
|
var tx, mapping, offset;
|
|
|
|
// Populate a transaction with bogus data
|
|
|
|
tx = new ve.dm.Transaction();
|
|
|
|
tx.pushReplace( [], ['a','b','c'] );
|
|
|
|
tx.pushRetain ( 5 );
|
|
|
|
tx.pushReplace( ['d', 'e', 'f', 'g'], [] );
|
|
|
|
tx.pushRetain( 2 );
|
|
|
|
tx.pushStartAnnotating( 'set', { 'type': 'textStyle/bold' } );
|
|
|
|
tx.pushRetain( 1 );
|
|
|
|
tx.pushReplace( ['h'], ['i', 'j', 'k', 'l', 'm'] );
|
|
|
|
tx.pushRetain( 2 );
|
|
|
|
tx.pushReplace( [], ['n', 'o', 'p'] );
|
|
|
|
|
|
|
|
mapping = {
|
|
|
|
0: 0,
|
|
|
|
1: 0,
|
|
|
|
2: 0,
|
|
|
|
3: 0,
|
|
|
|
4: 1,
|
|
|
|
5: 2,
|
|
|
|
6: 3,
|
|
|
|
7: 4,
|
|
|
|
8: 9,
|
|
|
|
9: 10,
|
|
|
|
10: 11,
|
|
|
|
11: 13,
|
|
|
|
12: 13,
|
|
|
|
13: 13,
|
|
|
|
14: 13,
|
|
|
|
15: 13,
|
|
|
|
16: 13
|
|
|
|
};
|
|
|
|
QUnit.expect( 17 );
|
|
|
|
for ( offset in mapping ) {
|
|
|
|
assert.strictEqual( tx.translateOffset( Number( offset ), true ), mapping[offset] );
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
2012-10-25 20:06:07 +00:00
|
|
|
QUnit.test( 'pushRetain', 4, function ( assert ) {
|
2012-05-11 23:49:31 +00:00
|
|
|
var cases = {
|
|
|
|
'retain': {
|
|
|
|
'calls': [['pushRetain', 5]],
|
|
|
|
'ops': [{ 'type': 'retain', 'length': 5 }],
|
|
|
|
'diff': 0
|
|
|
|
},
|
|
|
|
'multiple retain': {
|
|
|
|
'calls': [['pushRetain', 5], ['pushRetain', 3]],
|
|
|
|
'ops': [{ 'type': 'retain', 'length': 8 }],
|
|
|
|
'diff': 0
|
2012-05-31 21:39:34 +00:00
|
|
|
}
|
|
|
|
};
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
runBuilderTests( assert, cases );
|
2012-05-31 21:39:34 +00:00
|
|
|
} );
|
|
|
|
|
2012-10-25 20:06:07 +00:00
|
|
|
QUnit.test( 'pushReplace', 16, function ( assert ) {
|
2012-09-06 22:47:33 +00:00
|
|
|
var i, key, cases = {
|
2012-05-11 23:49:31 +00:00
|
|
|
'insert': {
|
|
|
|
'calls': [
|
2012-05-31 21:39:34 +00:00
|
|
|
['pushReplace', [], [{ 'type': 'paragraph' }, 'a', 'b', 'c', { 'type': '/paragraph' }]]
|
2012-05-11 23:49:31 +00:00
|
|
|
],
|
|
|
|
'ops': [
|
|
|
|
{
|
2012-05-22 20:04:32 +00:00
|
|
|
'type': 'replace',
|
|
|
|
'remove': [],
|
|
|
|
'insert': [{ 'type': 'paragraph' }, 'a', 'b', 'c', { 'type': '/paragraph' }]
|
2012-05-11 23:49:31 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
'diff': 5
|
|
|
|
},
|
|
|
|
'multiple insert': {
|
|
|
|
'calls': [
|
2012-05-22 20:04:32 +00:00
|
|
|
['pushReplace', [], [{ 'type': 'paragraph' }, 'a', 'b']],
|
|
|
|
['pushReplace', [], ['c', { 'type': '/paragraph' }]]
|
2012-05-11 23:49:31 +00:00
|
|
|
],
|
|
|
|
'ops': [
|
|
|
|
{
|
2012-05-22 20:04:32 +00:00
|
|
|
'type': 'replace',
|
|
|
|
'remove': [],
|
|
|
|
'insert': [{ 'type': 'paragraph' }, 'a', 'b']
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': [],
|
|
|
|
'insert': ['c', { 'type': '/paragraph' }]
|
2012-05-11 23:49:31 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
'diff': 5
|
|
|
|
},
|
|
|
|
'insert and retain': {
|
|
|
|
'calls': [
|
|
|
|
['pushRetain', 1],
|
2012-05-22 20:04:32 +00:00
|
|
|
['pushReplace', [], ['a', 'b', 'c']]
|
2012-05-11 23:49:31 +00:00
|
|
|
],
|
|
|
|
'ops': [
|
|
|
|
{ 'type': 'retain', 'length': 1 },
|
2012-05-22 20:04:32 +00:00
|
|
|
{ 'type': 'replace', 'remove': [], 'insert': ['a', 'b', 'c'] }
|
2012-05-11 23:49:31 +00:00
|
|
|
],
|
|
|
|
'diff': 3
|
|
|
|
},
|
|
|
|
'remove': {
|
|
|
|
'calls': [
|
2012-05-22 20:04:32 +00:00
|
|
|
['pushReplace', [{ 'type': 'paragraph' }, 'a', 'b', 'c', { 'type': '/paragraph' }], []]
|
2012-05-11 23:49:31 +00:00
|
|
|
],
|
|
|
|
'ops': [
|
|
|
|
{
|
2012-05-22 20:04:32 +00:00
|
|
|
'type': 'replace',
|
|
|
|
'remove': [{ 'type': 'paragraph' }, 'a', 'b', 'c', { 'type': '/paragraph' }],
|
|
|
|
'insert': []
|
2012-05-11 23:49:31 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
'diff': -5
|
|
|
|
},
|
|
|
|
'multiple remove': {
|
|
|
|
'calls': [
|
2012-05-22 20:04:32 +00:00
|
|
|
['pushReplace', [{ 'type': 'paragraph' }, 'a', 'b'], []],
|
|
|
|
['pushReplace', ['c', { 'type': '/paragraph' }], []]
|
2012-05-11 23:49:31 +00:00
|
|
|
],
|
|
|
|
'ops': [
|
|
|
|
{
|
2012-05-22 20:04:32 +00:00
|
|
|
'type': 'replace',
|
|
|
|
'remove': [{ 'type': 'paragraph' }, 'a', 'b'],
|
|
|
|
'insert': []
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': ['c', { 'type': '/paragraph' }],
|
|
|
|
'insert': []
|
2012-05-11 23:49:31 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
'diff': -5
|
|
|
|
},
|
|
|
|
'remove and retain': {
|
|
|
|
'calls': [
|
|
|
|
['pushRetain', 1],
|
2012-05-22 20:04:32 +00:00
|
|
|
['pushReplace', ['a', 'b', 'c'], []]
|
2012-05-11 23:49:31 +00:00
|
|
|
],
|
|
|
|
'ops': [
|
|
|
|
{ 'type': 'retain', 'length': 1 },
|
2012-05-22 20:04:32 +00:00
|
|
|
{ 'type': 'replace', 'remove': ['a', 'b', 'c'], 'insert': [] }
|
2012-05-11 23:49:31 +00:00
|
|
|
],
|
|
|
|
'diff': -3
|
|
|
|
},
|
|
|
|
'replace': {
|
|
|
|
'calls': [
|
|
|
|
['pushReplace', ['a', 'b', 'c'], ['d', 'e', 'f']]
|
|
|
|
],
|
|
|
|
'ops': [
|
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': ['a', 'b', 'c'],
|
|
|
|
'insert': ['d', 'e', 'f']
|
|
|
|
}
|
|
|
|
],
|
|
|
|
'diff': 0
|
|
|
|
},
|
|
|
|
'multiple replace': {
|
|
|
|
'calls': [
|
|
|
|
['pushReplace', ['a', 'b', 'c'], ['d', 'e', 'f']],
|
|
|
|
['pushReplace', ['g', 'h', 'i'], ['j', 'k', 'l']]
|
|
|
|
],
|
|
|
|
'ops': [
|
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': ['a', 'b', 'c'],
|
|
|
|
'insert': ['d', 'e', 'f']
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'type': 'replace',
|
|
|
|
'remove': ['g', 'h', 'i'],
|
|
|
|
'insert': ['j', 'k', 'l']
|
|
|
|
}
|
|
|
|
],
|
|
|
|
'diff': 0
|
2012-05-31 21:39:34 +00:00
|
|
|
}
|
|
|
|
};
|
2012-08-24 02:06:36 +00:00
|
|
|
for ( key in cases ) {
|
|
|
|
for ( i = 0; i < cases[key].ops.length; i++ ) {
|
|
|
|
if ( cases[key].ops[i].remove ) {
|
|
|
|
ve.dm.example.preprocessAnnotations( cases[key].ops[i].remove );
|
|
|
|
}
|
|
|
|
if ( cases[key].ops[i].insert ) {
|
|
|
|
ve.dm.example.preprocessAnnotations( cases[key].ops[i].insert );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for ( i = 0; i < cases[key].calls.length; i++ ) {
|
|
|
|
if ( cases[key].calls[i][0] === 'pushReplace' ) {
|
|
|
|
ve.dm.example.preprocessAnnotations( cases[key].calls[i][1] );
|
|
|
|
ve.dm.example.preprocessAnnotations( cases[key].calls[i][2] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
runBuilderTests( assert, cases );
|
2012-05-31 21:39:34 +00:00
|
|
|
} );
|
|
|
|
|
2012-10-25 20:06:07 +00:00
|
|
|
QUnit.test( 'pushReplaceElementAttribute', 4, function ( assert ) {
|
2012-05-31 21:39:34 +00:00
|
|
|
var cases = {
|
2012-05-11 23:49:31 +00:00
|
|
|
'replace element attribute': {
|
|
|
|
'calls': [
|
|
|
|
['pushReplaceElementAttribute', 'style', 'bullet', 'number']
|
|
|
|
],
|
|
|
|
'ops': [
|
|
|
|
{
|
|
|
|
'type': 'attribute',
|
|
|
|
'key': 'style',
|
|
|
|
'from': 'bullet',
|
|
|
|
'to': 'number'
|
|
|
|
}
|
|
|
|
],
|
|
|
|
'diff': 0
|
|
|
|
},
|
|
|
|
'replace multiple element attributes': {
|
|
|
|
'calls': [
|
|
|
|
['pushReplaceElementAttribute', 'style', 'bullet', 'number'],
|
2012-05-21 19:20:51 +00:00
|
|
|
['pushReplaceElementAttribute', 'level', 1, 2]
|
2012-05-11 23:49:31 +00:00
|
|
|
],
|
|
|
|
'ops': [
|
|
|
|
{
|
|
|
|
'type': 'attribute',
|
|
|
|
'key': 'style',
|
|
|
|
'from': 'bullet',
|
|
|
|
'to': 'number'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'type': 'attribute',
|
|
|
|
'key': 'level',
|
2012-05-21 19:20:51 +00:00
|
|
|
'from': 1,
|
|
|
|
'to': 2
|
2012-05-11 23:49:31 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
'diff': 0
|
2012-05-31 21:39:34 +00:00
|
|
|
}
|
|
|
|
};
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
runBuilderTests( assert, cases );
|
2012-05-31 21:39:34 +00:00
|
|
|
} );
|
|
|
|
|
2012-10-25 20:06:07 +00:00
|
|
|
QUnit.test( 'push*Annotating', 8, function ( assert ) {
|
2012-05-31 21:39:34 +00:00
|
|
|
var cases = {
|
2012-05-11 23:49:31 +00:00
|
|
|
'start annotating': {
|
|
|
|
'calls': [
|
|
|
|
['pushStartAnnotating', 'set', { 'type': 'textStyle/bold' }]
|
|
|
|
],
|
|
|
|
'ops': [
|
|
|
|
{
|
|
|
|
'type': 'annotate',
|
|
|
|
'method': 'set',
|
|
|
|
'bias': 'start',
|
|
|
|
'annotation': { 'type': 'textStyle/bold' }
|
|
|
|
}
|
|
|
|
],
|
|
|
|
'diff': 0
|
|
|
|
},
|
|
|
|
'stop annotating': {
|
|
|
|
'calls': [
|
|
|
|
['pushStopAnnotating', 'set', { 'type': 'textStyle/bold' }]
|
|
|
|
],
|
|
|
|
'ops': [
|
|
|
|
{
|
|
|
|
'type': 'annotate',
|
|
|
|
'method': 'set',
|
|
|
|
'bias': 'stop',
|
|
|
|
'annotation': { 'type': 'textStyle/bold' }
|
|
|
|
}
|
|
|
|
],
|
|
|
|
'diff': 0
|
|
|
|
},
|
|
|
|
'start multiple annotations': {
|
|
|
|
'calls': [
|
|
|
|
['pushStartAnnotating', 'set', { 'type': 'textStyle/bold' }],
|
|
|
|
['pushStartAnnotating', 'set', { 'type': 'textStyle/italic' }]
|
|
|
|
],
|
|
|
|
'ops': [
|
|
|
|
{
|
|
|
|
'type': 'annotate',
|
|
|
|
'method': 'set',
|
|
|
|
'bias': 'start',
|
|
|
|
'annotation': { 'type': 'textStyle/bold' }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'type': 'annotate',
|
|
|
|
'method': 'set',
|
|
|
|
'bias': 'start',
|
|
|
|
'annotation': { 'type': 'textStyle/italic' }
|
|
|
|
}
|
|
|
|
],
|
|
|
|
'diff': 0
|
|
|
|
},
|
|
|
|
'stop multiple annotations': {
|
|
|
|
'calls': [
|
|
|
|
['pushStopAnnotating', 'set', { 'type': 'textStyle/bold' }],
|
|
|
|
['pushStopAnnotating', 'set', { 'type': 'textStyle/italic' }]
|
|
|
|
],
|
|
|
|
'ops': [
|
|
|
|
{
|
|
|
|
'type': 'annotate',
|
|
|
|
'method': 'set',
|
|
|
|
'bias': 'stop',
|
|
|
|
'annotation': { 'type': 'textStyle/bold' }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'type': 'annotate',
|
|
|
|
'method': 'set',
|
|
|
|
'bias': 'stop',
|
|
|
|
'annotation': { 'type': 'textStyle/italic' }
|
|
|
|
}
|
|
|
|
],
|
|
|
|
'diff': 0
|
|
|
|
}
|
|
|
|
};
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
runBuilderTests( assert, cases );
|
2012-04-20 01:11:08 +00:00
|
|
|
} );
|