2012-07-19 00:11:26 +00:00
|
|
|
/**
|
|
|
|
* VisualEditor data model Document 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.Document' );
|
2012-04-27 21:59:52 +00:00
|
|
|
|
|
|
|
/* Tests */
|
|
|
|
|
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( 'constructor', 4, function ( assert ) {
|
2012-05-17 18:23:56 +00:00
|
|
|
var doc = new ve.dm.Document( ve.dm.example.data );
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.equalNodeTree( doc.getDocumentNode(), ve.dm.example.tree, 'node tree matches example data' );
|
|
|
|
assert.throws(
|
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 () {
|
2012-05-17 18:23:56 +00:00
|
|
|
doc = new ve.dm.Document( [
|
|
|
|
{ 'type': '/paragraph' },
|
|
|
|
{ 'type': 'paragraph' }
|
|
|
|
] );
|
|
|
|
},
|
2012-08-08 17:48:53 +00:00
|
|
|
Error,
|
2012-05-17 18:23:56 +00:00
|
|
|
'unbalanced input causes exception'
|
|
|
|
);
|
2012-05-31 13:17:23 +00:00
|
|
|
|
|
|
|
// TODO data provider?
|
|
|
|
doc = new ve.dm.Document( [ 'a', 'b', 'c', 'd' ] );
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.equalNodeTree(
|
|
|
|
doc.getDocumentNode(),
|
|
|
|
new ve.dm.DocumentNode( [ new ve.dm.TextNode( 4 ) ] ),
|
2012-05-31 13:17:23 +00:00
|
|
|
'plain text input is handled correctly'
|
|
|
|
);
|
2012-06-06 22:33:42 +00:00
|
|
|
|
|
|
|
doc = new ve.dm.Document( [ { 'type': 'paragraph' }, { 'type': '/paragraph' } ] );
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.equalNodeTree(
|
|
|
|
doc.getDocumentNode(),
|
2012-10-12 18:04:15 +00:00
|
|
|
new ve.dm.DocumentNode( [ new ve.dm.ParagraphNode( [ new ve.dm.TextNode( 0 ) ] ) ] ),
|
|
|
|
'empty paragraph gets a zero-length text node'
|
2012-06-06 22:33:42 +00:00
|
|
|
);
|
2012-05-17 18:23:56 +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( 'getData', 1, function ( assert ) {
|
2012-05-17 18:23:56 +00:00
|
|
|
var doc = new ve.dm.Document( ve.dm.example.data );
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.deepEqual( doc.getData(), ve.dm.example.data );
|
2012-05-17 18:23:56 +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( 'getNodeFromOffset', function ( assert ) {
|
2012-08-02 18:46:13 +00:00
|
|
|
var i, j, node,
|
|
|
|
doc = new ve.dm.Document( ve.dm.example.data ),
|
2012-05-17 18:23:56 +00:00
|
|
|
root = doc.getDocumentNode().getRoot(),
|
|
|
|
expected = [
|
|
|
|
[], // 0 - document
|
|
|
|
[0], // 1 - heading
|
|
|
|
[0], // 2 - heading
|
|
|
|
[0], // 3 - heading
|
|
|
|
[0], // 4 - heading
|
|
|
|
[], // 5 - document
|
|
|
|
[1], // 6 - table
|
2012-06-08 05:08:49 +00:00
|
|
|
[1, 0], // 7 - tableSection
|
|
|
|
[1, 0, 0], // 7 - tableRow
|
|
|
|
[1, 0, 0, 0], // 8 - tableCell
|
|
|
|
[1, 0, 0, 0, 0], // 9 - paragraph
|
|
|
|
[1, 0, 0, 0, 0], // 10 - paragraph
|
|
|
|
[1, 0, 0, 0], // 11 - tableCell
|
|
|
|
[1, 0, 0, 0, 1], // 12 - list
|
|
|
|
[1, 0, 0, 0, 1, 0], // 13 - listItem
|
|
|
|
[1, 0, 0, 0, 1, 0, 0], // 14 - paragraph
|
|
|
|
[1, 0, 0, 0, 1, 0, 0], // 15 - paragraph
|
|
|
|
[1, 0, 0, 0, 1, 0], // 16 - listItem
|
|
|
|
[1, 0, 0, 0, 1, 0, 1], // 17 - list
|
|
|
|
[1, 0, 0, 0, 1, 0, 1, 0], // 18 - listItem
|
|
|
|
[1, 0, 0, 0, 1, 0, 1, 0, 0], // 19 - paragraph
|
|
|
|
[1, 0, 0, 0, 1, 0, 1, 0, 0], // 20 - paragraph
|
|
|
|
[1, 0, 0, 0, 1, 0, 1, 0], // 21 - listItem
|
|
|
|
[1, 0, 0, 0, 1, 0, 1], // 22 - list
|
|
|
|
[1, 0, 0, 0, 1, 0], // 23 - listItem
|
|
|
|
[1, 0, 0, 0, 1], // 24 - list
|
|
|
|
[1, 0, 0, 0], // 25 - tableCell
|
|
|
|
[1, 0, 0, 0, 2], // 26 - list
|
|
|
|
[1, 0, 0, 0, 2, 0], // 27 - listItem
|
|
|
|
[1, 0, 0, 0, 2, 0, 0], // 28 - paragraph
|
|
|
|
[1, 0, 0, 0, 2, 0, 0], // 29 - paragraph
|
|
|
|
[1, 0, 0, 0, 2, 0], // 30 - listItem
|
|
|
|
[1, 0, 0, 0, 2], // 31 - list
|
|
|
|
[1, 0, 0, 0], // 32 - tableCell
|
|
|
|
[1, 0, 0], // 33 - tableRow
|
|
|
|
[1, 0], // 33 - tableSection
|
2012-05-17 18:23:56 +00:00
|
|
|
[1], // 34 - table
|
|
|
|
[], // 35- document
|
|
|
|
[2], // 36 - preformatted
|
|
|
|
[2], // 37 - preformatted
|
|
|
|
[2], // 38 - preformatted
|
|
|
|
[2], // 39 - preformatted
|
|
|
|
[2], // 40 - preformatted
|
|
|
|
[], // 41 - document
|
|
|
|
[3], // 42 - definitionList
|
|
|
|
[3, 0], // 43 - definitionListItem
|
|
|
|
[3, 0, 0], // 44 - paragraph
|
|
|
|
[3, 0, 0], // 45 - paragraph
|
|
|
|
[3, 0], // 46 - definitionListItem
|
|
|
|
[3], // 47 - definitionList
|
|
|
|
[3, 1], // 48 - definitionListItem
|
|
|
|
[3, 1, 0], // 49 - paragraph
|
|
|
|
[3, 1, 0], // 50 - paragraph
|
|
|
|
[3, 1], // 51 - definitionListItem
|
|
|
|
[3], // 52 - definitionList
|
|
|
|
[], // 53 - document
|
|
|
|
[4], // 54 - paragraph
|
|
|
|
[4], // 55 - paragraph
|
|
|
|
[], // 56 - document
|
|
|
|
[5], // 57 - paragraph
|
|
|
|
[5], // 58 - paragraph
|
|
|
|
[] // 59 - document
|
|
|
|
];
|
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.expect( expected.length );
|
2012-08-02 18:46:13 +00:00
|
|
|
for ( i = 0; i < expected.length; i++ ) {
|
2012-05-17 18:23:56 +00:00
|
|
|
node = root;
|
2012-08-02 18:46:13 +00:00
|
|
|
for ( j = 0; j < expected[i].length; j++ ) {
|
2012-05-17 18:23:56 +00:00
|
|
|
node = node.children[expected[i][j]];
|
|
|
|
}
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.ok( node === doc.getNodeFromOffset( i ), 'reference at offset ' + i );
|
2012-05-17 18:23:56 +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( 'getDataFromNode', 3, function ( assert ) {
|
2012-05-17 18:23:56 +00:00
|
|
|
var doc = new ve.dm.Document( ve.dm.example.data );
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.deepEqual(
|
2012-05-17 18:23:56 +00:00
|
|
|
doc.getDataFromNode( doc.getDocumentNode().getChildren()[0] ),
|
|
|
|
ve.dm.example.data.slice( 1, 4 ),
|
|
|
|
'branch with leaf children'
|
|
|
|
);
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.deepEqual(
|
2012-05-17 18:23:56 +00:00
|
|
|
doc.getDataFromNode( doc.getDocumentNode().getChildren()[1] ),
|
2012-06-08 05:08:49 +00:00
|
|
|
ve.dm.example.data.slice( 6, 36 ),
|
2012-05-17 18:23:56 +00:00
|
|
|
'branch with branch children'
|
|
|
|
);
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.deepEqual(
|
2012-05-17 18:23:56 +00:00
|
|
|
doc.getDataFromNode( doc.getDocumentNode().getChildren()[2].getChildren()[1] ),
|
|
|
|
[],
|
|
|
|
'leaf without children'
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
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( 'getAnnotationsFromOffset', 1, function ( assert ) {
|
|
|
|
var c, i, j,
|
|
|
|
doc,
|
2012-05-17 18:23:56 +00:00
|
|
|
annotations,
|
|
|
|
expectCount = 0,
|
|
|
|
cases = [
|
|
|
|
{
|
|
|
|
'msg': ['bold #1', 'bold #2'],
|
|
|
|
'data': [
|
2012-08-24 02:06:36 +00:00
|
|
|
['a', [ { 'type': 'textStyle/bold' } ]],
|
|
|
|
['b', [ { 'type': 'textStyle/bold' } ]]
|
2012-05-17 18:23:56 +00:00
|
|
|
],
|
|
|
|
'expected': [
|
2012-08-24 02:06:36 +00:00
|
|
|
[ { 'type': 'textStyle/bold' } ],
|
|
|
|
[ { 'type': 'textStyle/bold' } ]
|
2012-05-17 18:23:56 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': ['bold #3', 'italic #1'],
|
|
|
|
'data': [
|
2012-08-24 02:06:36 +00:00
|
|
|
['a', [ { 'type': 'textStyle/bold' } ]],
|
|
|
|
['b', [ { 'type': 'textStyle/italic' } ]]
|
2012-05-17 18:23:56 +00:00
|
|
|
],
|
|
|
|
'expected': [
|
2012-08-24 02:06:36 +00:00
|
|
|
[ { 'type': 'textStyle/bold' } ],
|
|
|
|
[ { 'type': 'textStyle/italic' } ]
|
2012-05-17 18:23:56 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': ['bold, italic & underline'],
|
|
|
|
'data': [
|
2012-08-24 02:06:36 +00:00
|
|
|
[
|
|
|
|
'a',
|
|
|
|
[
|
|
|
|
{ 'type': 'textStyle/bold' },
|
|
|
|
{ 'type': 'textStyle/italic'},
|
|
|
|
{ 'type': 'textStyle/underline'}
|
|
|
|
]
|
|
|
|
]
|
2012-05-17 18:23:56 +00:00
|
|
|
],
|
2012-06-12 18:10:29 +00:00
|
|
|
'expected':
|
|
|
|
[
|
2012-08-24 02:06:36 +00:00
|
|
|
[
|
|
|
|
{ 'type': 'textStyle/bold' },
|
|
|
|
{ 'type': 'textStyle/italic'},
|
|
|
|
{ 'type': 'textStyle/underline'}
|
|
|
|
]
|
2012-06-12 18:10:29 +00:00
|
|
|
]
|
2012-05-17 18:23:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
// Calculate expected assertion count
|
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 ( c = 0; c < cases.length; c++ ) {
|
2012-05-17 18:23:56 +00:00
|
|
|
expectCount += cases[c].data.length;
|
|
|
|
}
|
2012-08-24 02:06:36 +00:00
|
|
|
QUnit.expect( expectCount );
|
2012-05-17 18:23:56 +00:00
|
|
|
|
|
|
|
// Run tests
|
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 ( i = 0; i < cases.length; i++ ) {
|
2012-08-24 02:06:36 +00:00
|
|
|
ve.dm.example.preprocessAnnotations( cases[i].data );
|
|
|
|
doc = new ve.dm.Document( cases[i].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
|
|
|
for ( j = 0; j < doc.getData().length; j++ ) {
|
2012-05-17 18:23:56 +00:00
|
|
|
annotations = doc.getAnnotationsFromOffset( j );
|
2012-08-24 02:06:36 +00:00
|
|
|
assert.deepEqual( annotations,
|
|
|
|
new ve.AnnotationSet( cases[i].expected[j] ),
|
|
|
|
cases[i].msg[j]
|
|
|
|
);
|
2012-05-17 18:23:56 +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( 'getAnnotationsFromRange', 1, function ( assert ) {
|
|
|
|
var i, doc,
|
|
|
|
cases = [
|
2012-05-17 18:23:56 +00:00
|
|
|
{
|
2012-06-13 21:31:33 +00:00
|
|
|
'msg': 'single annotations',
|
2012-05-17 18:23:56 +00:00
|
|
|
'data': [
|
2012-08-24 02:06:36 +00:00
|
|
|
['a', [ { 'type': 'textStyle/bold' } ] ],
|
|
|
|
['b', [ { 'type': 'textStyle/bold' } ] ]
|
2012-05-17 18:23:56 +00:00
|
|
|
],
|
2012-08-24 02:06:36 +00:00
|
|
|
'expected': [ { 'type': 'textStyle/bold' } ]
|
2012-05-17 18:23:56 +00:00
|
|
|
},
|
|
|
|
{
|
2012-08-24 02:06:36 +00:00
|
|
|
'msg': 'multiple annotations',
|
2012-05-17 18:23:56 +00:00
|
|
|
'data': [
|
2012-06-13 21:31:33 +00:00
|
|
|
[
|
|
|
|
'a',
|
2012-08-24 02:06:36 +00:00
|
|
|
[
|
|
|
|
{ 'type': 'textStyle/bold' },
|
|
|
|
{ 'type': 'textStyle/italic'}
|
|
|
|
]
|
2012-05-17 18:23:56 +00:00
|
|
|
],
|
2012-06-13 21:31:33 +00:00
|
|
|
[
|
|
|
|
'b',
|
2012-08-24 02:06:36 +00:00
|
|
|
[
|
|
|
|
{ 'type': 'textStyle/bold' },
|
|
|
|
{ 'type': 'textStyle/italic' }
|
|
|
|
]
|
2012-05-17 18:23:56 +00:00
|
|
|
]
|
|
|
|
],
|
2012-08-24 02:06:36 +00:00
|
|
|
'expected': [
|
|
|
|
{ 'type': 'textStyle/bold' },
|
|
|
|
{ 'type': 'textStyle/italic' }
|
|
|
|
]
|
2012-05-17 18:23:56 +00:00
|
|
|
},
|
|
|
|
{
|
2012-06-13 21:31:33 +00:00
|
|
|
'msg': 'lowest common coverage',
|
2012-05-17 18:23:56 +00:00
|
|
|
'data': [
|
2012-06-13 21:31:33 +00:00
|
|
|
[
|
|
|
|
'a',
|
2012-08-24 02:06:36 +00:00
|
|
|
[
|
|
|
|
{ 'type': 'textStyle/bold' },
|
|
|
|
{ 'type': 'textStyle/italic' }
|
|
|
|
]
|
2012-05-17 18:23:56 +00:00
|
|
|
],
|
2012-06-13 21:31:33 +00:00
|
|
|
[
|
|
|
|
'b',
|
2012-08-24 02:06:36 +00:00
|
|
|
[
|
|
|
|
{ 'type': 'textStyle/bold' },
|
|
|
|
{ 'type': 'textStyle/italic' },
|
|
|
|
{ 'type': 'textStyle/underline' }
|
|
|
|
]
|
2012-05-17 18:23:56 +00:00
|
|
|
]
|
|
|
|
],
|
2012-08-24 02:06:36 +00:00
|
|
|
'expected': [
|
|
|
|
{ 'type': 'textStyle/bold' },
|
|
|
|
{ 'type': 'textStyle/italic' }
|
|
|
|
]
|
2012-05-17 18:23:56 +00:00
|
|
|
},
|
|
|
|
{
|
2012-06-13 21:31:33 +00:00
|
|
|
'msg': 'no common coverage due to plain character at the start',
|
2012-05-17 18:23:56 +00:00
|
|
|
'data': [
|
2012-06-13 21:31:33 +00:00
|
|
|
['a'],
|
|
|
|
[
|
|
|
|
'b',
|
2012-08-24 02:06:36 +00:00
|
|
|
[
|
|
|
|
{ 'type': 'textStyle/bold' },
|
|
|
|
{ 'type': 'textStyle/italic' },
|
|
|
|
{ 'type': 'textStyle/underline' }
|
|
|
|
]
|
2012-05-17 18:23:56 +00:00
|
|
|
],
|
2012-06-13 21:31:33 +00:00
|
|
|
[
|
|
|
|
'c',
|
2012-08-24 02:06:36 +00:00
|
|
|
[
|
|
|
|
{ 'type': 'textStyle/bold' },
|
|
|
|
{ 'type': 'textStyle/italic' }
|
|
|
|
]
|
|
|
|
]
|
2012-05-17 18:23:56 +00:00
|
|
|
],
|
2012-08-24 02:06:36 +00:00
|
|
|
'expected': []
|
2012-05-17 18:23:56 +00:00
|
|
|
},
|
|
|
|
{
|
2012-06-13 21:31:33 +00:00
|
|
|
'msg': 'no common coverage due to plain character in the middle',
|
2012-05-17 18:23:56 +00:00
|
|
|
'data': [
|
2012-06-13 21:31:33 +00:00
|
|
|
[
|
|
|
|
'a',
|
2012-08-24 02:06:36 +00:00
|
|
|
[
|
|
|
|
{ 'type': 'textStyle/bold' },
|
|
|
|
{ 'type': 'textStyle/italic' },
|
|
|
|
{ 'type': 'textStyle/underline' }
|
|
|
|
]
|
2012-05-17 18:23:56 +00:00
|
|
|
],
|
2012-06-13 21:31:33 +00:00
|
|
|
['b'],
|
|
|
|
[
|
|
|
|
'c',
|
2012-08-24 02:06:36 +00:00
|
|
|
[
|
|
|
|
{ 'type': 'textStyle/bold' },
|
|
|
|
{ 'type': 'textStyle/italic' }
|
|
|
|
]
|
2012-05-17 18:23:56 +00:00
|
|
|
]
|
|
|
|
],
|
2012-08-24 02:06:36 +00:00
|
|
|
'expected': []
|
2012-05-17 18:23:56 +00:00
|
|
|
},
|
|
|
|
{
|
2012-06-13 21:31:33 +00:00
|
|
|
'msg': 'no common coverage due to plain character at the end',
|
|
|
|
'data': [
|
|
|
|
[
|
|
|
|
'a',
|
2012-08-24 02:06:36 +00:00
|
|
|
[
|
|
|
|
{ 'type': 'textStyle/bold' },
|
|
|
|
{ 'type': 'textStyle/italic' }
|
|
|
|
]
|
2012-06-13 21:31:33 +00:00
|
|
|
],
|
|
|
|
[
|
|
|
|
'b',
|
2012-08-24 02:06:36 +00:00
|
|
|
[
|
|
|
|
{ 'type': 'textStyle/bold' },
|
|
|
|
{ 'type': 'textStyle/italic' },
|
|
|
|
{ 'type': 'textStyle/underline' }
|
|
|
|
]
|
2012-06-13 21:31:33 +00:00
|
|
|
],
|
|
|
|
['c']
|
|
|
|
],
|
2012-08-24 02:06:36 +00:00
|
|
|
'expected': []
|
2012-06-13 21:31:33 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'no common coverage due to mismatched annotations',
|
2012-05-17 18:23:56 +00:00
|
|
|
'data': [
|
2012-08-24 02:06:36 +00:00
|
|
|
['a', [ { 'type': 'textStyle/bold' } ] ],
|
|
|
|
['b', [ { 'type': 'textStyle/italic' } ] ]
|
2012-05-17 18:23:56 +00:00
|
|
|
],
|
2012-08-24 02:06:36 +00:00
|
|
|
'expected': []
|
2012-05-17 18:23:56 +00:00
|
|
|
},
|
|
|
|
{
|
2012-06-13 21:31:33 +00:00
|
|
|
'msg': 'annotations are collected using all with mismatched annotations',
|
|
|
|
'data': [
|
2012-08-24 02:06:36 +00:00
|
|
|
['a', [ { 'type': 'textStyle/bold' } ] ],
|
|
|
|
['b', [ { 'type': 'textStyle/italic' } ] ]
|
2012-06-13 21:31:33 +00:00
|
|
|
],
|
|
|
|
'all': true,
|
2012-08-24 02:06:36 +00:00
|
|
|
'expected': [
|
|
|
|
{ 'type': 'textStyle/bold' },
|
|
|
|
{ 'type': 'textStyle/italic' }
|
|
|
|
]
|
2012-06-13 21:31:33 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'annotations are collected using all, even with a plain character at the start',
|
|
|
|
'data': [
|
2012-08-24 02:06:36 +00:00
|
|
|
['a', [ { 'type': 'textStyle/bold' } ] ],
|
|
|
|
['b', [ { 'type': 'textStyle/italic' } ] ],
|
2012-06-13 21:31:33 +00:00
|
|
|
['c']
|
|
|
|
],
|
|
|
|
'all': true,
|
2012-08-24 02:06:36 +00:00
|
|
|
'expected': [
|
|
|
|
{ 'type': 'textStyle/bold' },
|
|
|
|
{ 'type': 'textStyle/italic' }
|
|
|
|
]
|
2012-06-13 21:31:33 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'annotations are collected using all, even with a plain character at the middle',
|
|
|
|
'data': [
|
2012-08-24 02:06:36 +00:00
|
|
|
['a', [ { 'type': 'textStyle/bold' } ] ],
|
|
|
|
['b', [ { 'type': 'textStyle/italic' } ] ],
|
2012-06-13 21:31:33 +00:00
|
|
|
['c']
|
|
|
|
],
|
|
|
|
'all': true,
|
2012-08-24 02:06:36 +00:00
|
|
|
'expected': [
|
|
|
|
{ 'type': 'textStyle/bold' },
|
|
|
|
{ 'type': 'textStyle/italic' }
|
|
|
|
]
|
2012-06-13 21:31:33 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'annotations are collected using all, even with a plain character at the end',
|
|
|
|
'data': [
|
2012-08-24 02:06:36 +00:00
|
|
|
['a', [ { 'type': 'textStyle/bold' } ] ],
|
|
|
|
['b', [ { 'type': 'textStyle/italic' } ] ],
|
2012-06-13 21:31:33 +00:00
|
|
|
['c']
|
|
|
|
],
|
|
|
|
'all': true,
|
2012-08-24 02:06:36 +00:00
|
|
|
'expected': [
|
|
|
|
{ 'type': 'textStyle/bold' },
|
|
|
|
{ 'type': 'textStyle/italic' }
|
|
|
|
]
|
2012-06-13 21:31:33 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'no common coverage from all plain characters',
|
|
|
|
'data': ['a', 'b'],
|
|
|
|
'expected': {}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'no common coverage using all from all plain characters',
|
2012-05-17 18:23:56 +00:00
|
|
|
'data': ['a', 'b'],
|
2012-06-13 21:31:33 +00:00
|
|
|
'all': true,
|
2012-06-12 18:10:29 +00:00
|
|
|
'expected': {}
|
2012-05-17 18:23:56 +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.expect( cases.length );
|
2012-05-17 18:23:56 +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
|
|
|
for ( i = 0; i < cases.length; i++ ) {
|
2012-08-24 02:06:36 +00:00
|
|
|
ve.dm.example.preprocessAnnotations( cases[i].data );
|
|
|
|
doc = new ve.dm.Document( cases[i].data );
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.deepEqual(
|
2012-06-13 21:31:33 +00:00
|
|
|
doc.getAnnotationsFromRange( new ve.Range( 0, cases[i].data.length ), cases[i].all ),
|
2012-08-24 02:06:36 +00:00
|
|
|
new ve.AnnotationSet( cases[i].expected ),
|
2012-06-13 21:31:33 +00:00
|
|
|
cases[i].msg
|
2012-05-17 18:23:56 +00:00
|
|
|
);
|
|
|
|
}
|
2012-05-17 21:37:05 +00:00
|
|
|
} );
|
2012-05-17 18:23:56 +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( 'offsetContainsAnnotation', 1, function ( assert ) {
|
|
|
|
var i, doc,
|
2012-05-17 18:23:56 +00:00
|
|
|
cases = [
|
|
|
|
{
|
|
|
|
msg: 'contains no annotations',
|
|
|
|
data: [
|
2012-05-21 19:02:04 +00:00
|
|
|
'a'
|
2012-05-17 18:23:56 +00:00
|
|
|
],
|
2012-05-21 19:02:04 +00:00
|
|
|
lookFor: {'type': 'textStyle/bold'},
|
2012-05-17 18:23:56 +00:00
|
|
|
expected: false
|
|
|
|
},
|
|
|
|
{
|
|
|
|
msg: 'contains bold',
|
|
|
|
data: [
|
2012-08-24 02:06:36 +00:00
|
|
|
['a', [ { 'type': 'textStyle/bold' } ] ]
|
2012-05-17 18:23:56 +00:00
|
|
|
],
|
2012-05-21 19:02:04 +00:00
|
|
|
lookFor: {'type': 'textStyle/bold'},
|
2012-05-17 18:23:56 +00:00
|
|
|
expected: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
msg: 'contains bold',
|
|
|
|
data: [
|
2012-08-24 02:06:36 +00:00
|
|
|
['a', [
|
|
|
|
{ 'type': 'textStyle/bold' },
|
|
|
|
{ 'type': 'textStyle/italic'}
|
|
|
|
]
|
2012-05-17 18:23:56 +00:00
|
|
|
]
|
|
|
|
],
|
2012-05-21 19:02:04 +00:00
|
|
|
lookFor: {'type': 'textStyle/bold'},
|
2012-05-17 18:23:56 +00:00
|
|
|
expected: true
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
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.expect( cases.length );
|
2012-05-17 18:23:56 +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
|
|
|
for ( i = 0;i < cases.length; i++ ) {
|
2012-08-24 02:06:36 +00:00
|
|
|
ve.dm.example.preprocessAnnotations( cases[i].data );
|
2012-05-17 18:23:56 +00:00
|
|
|
doc = new ve.dm.Document( cases[i].data );
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.deepEqual(
|
2012-05-17 18:23:56 +00:00
|
|
|
doc.offsetContainsAnnotation( 0, cases[i].lookFor ),
|
|
|
|
cases[i].expected,
|
|
|
|
cases[i].msg
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
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
|
|
|
QUnit.test( 'getAnnotatedRangeFromOffset', 1, function ( assert ) {
|
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
|
|
|
var i, doc,
|
2012-05-17 18:23:56 +00:00
|
|
|
cases = [
|
|
|
|
{
|
|
|
|
'msg': 'a bold word',
|
|
|
|
'data': [
|
|
|
|
// 0
|
2012-05-21 19:02:04 +00:00
|
|
|
'a',
|
2012-05-17 18:23:56 +00:00
|
|
|
// 1
|
2012-08-24 02:06:36 +00:00
|
|
|
['b', [ { 'type': 'textStyle/bold' } ]],
|
2012-05-17 18:23:56 +00:00
|
|
|
// 2
|
2012-08-24 02:06:36 +00:00
|
|
|
['o', [ { 'type': 'textStyle/bold' } ]],
|
2012-05-17 18:23:56 +00:00
|
|
|
// 3
|
2012-08-24 02:06:36 +00:00
|
|
|
['l', [ { 'type': 'textStyle/bold' } ]],
|
2012-05-17 18:23:56 +00:00
|
|
|
// 4
|
2012-08-24 02:06:36 +00:00
|
|
|
['d', [ { 'type': 'textStyle/bold' } ]],
|
2012-05-17 18:23:56 +00:00
|
|
|
// 5
|
2012-05-21 19:02:04 +00:00
|
|
|
'w',
|
2012-05-17 18:23:56 +00:00
|
|
|
// 6
|
2012-05-21 19:02:04 +00:00
|
|
|
'o',
|
2012-05-17 18:23:56 +00:00
|
|
|
// 7
|
2012-05-21 19:02:04 +00:00
|
|
|
'r',
|
2012-05-17 18:23:56 +00:00
|
|
|
// 8
|
2012-05-21 19:02:04 +00:00
|
|
|
'd'
|
2012-05-17 18:23:56 +00:00
|
|
|
],
|
2012-05-21 19:02:04 +00:00
|
|
|
'annotation': { 'type': 'textStyle/bold' },
|
2012-05-17 18:23:56 +00:00
|
|
|
'offset': 3,
|
2012-05-17 20:17:18 +00:00
|
|
|
'expected': new ve.Range( 1, 5 )
|
2012-05-17 18:23:56 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'a linked',
|
|
|
|
'data': [
|
|
|
|
// 0
|
2012-05-21 19:02:04 +00:00
|
|
|
'x',
|
2012-05-17 18:23:56 +00:00
|
|
|
// 1
|
2012-05-21 19:02:04 +00:00
|
|
|
'x',
|
2012-05-17 18:23:56 +00:00
|
|
|
// 2
|
2012-05-21 19:02:04 +00:00
|
|
|
'x',
|
2012-05-17 18:23:56 +00:00
|
|
|
// 3
|
2012-08-24 02:06:36 +00:00
|
|
|
['l', [ { 'type': 'link/internal' } ]],
|
2012-05-17 18:23:56 +00:00
|
|
|
// 4
|
2012-08-24 02:06:36 +00:00
|
|
|
['i', [ { 'type': 'link/internal' } ]],
|
2012-05-17 18:23:56 +00:00
|
|
|
// 5
|
2012-08-24 02:06:36 +00:00
|
|
|
['n', [ { 'type': 'link/internal' } ]],
|
2012-05-17 18:23:56 +00:00
|
|
|
// 6
|
2012-08-24 02:06:36 +00:00
|
|
|
['k', [ { 'type': 'link/internal' } ]],
|
2012-05-17 18:23:56 +00:00
|
|
|
// 7
|
2012-05-21 19:02:04 +00:00
|
|
|
'x',
|
2012-05-17 18:23:56 +00:00
|
|
|
// 8
|
2012-05-21 19:02:04 +00:00
|
|
|
'x',
|
2012-05-17 18:23:56 +00:00
|
|
|
// 9
|
2012-05-21 19:02:04 +00:00
|
|
|
'x'
|
2012-05-17 18:23:56 +00:00
|
|
|
],
|
|
|
|
'annotation': { 'type': 'link/internal' },
|
|
|
|
'offset': 3,
|
2012-05-17 20:17:18 +00:00
|
|
|
'expected': new ve.Range( 3, 7 )
|
2012-05-21 19:02:04 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'bold over an annotated leaf node',
|
|
|
|
'data': [
|
|
|
|
// 0
|
|
|
|
'h',
|
|
|
|
// 1
|
2012-08-24 02:06:36 +00:00
|
|
|
['b', [ { 'type': 'textStyle/bold' } ]],
|
2012-05-21 19:02:04 +00:00
|
|
|
// 2
|
2012-08-24 02:06:36 +00:00
|
|
|
['o', [ { 'type': 'textStyle/bold' } ]],
|
2012-05-21 19:02:04 +00:00
|
|
|
// 3
|
|
|
|
{
|
|
|
|
'type': 'image',
|
|
|
|
'attributes': { 'html/src': 'image.png' },
|
2012-08-24 02:06:36 +00:00
|
|
|
'annotations': [ { 'type': 'textStyle/bold' }]
|
2012-05-21 19:02:04 +00:00
|
|
|
},
|
|
|
|
// 4
|
|
|
|
{ 'type': '/image' },
|
|
|
|
// 5
|
2012-08-24 02:06:36 +00:00
|
|
|
['l', [ { 'type': 'textStyle/bold' } ]],
|
2012-05-21 19:02:04 +00:00
|
|
|
// 6
|
2012-08-24 02:06:36 +00:00
|
|
|
['d', [ { 'type': 'textStyle/bold' } ]],
|
2012-05-21 19:02:04 +00:00
|
|
|
// 7
|
|
|
|
'i'
|
|
|
|
],
|
|
|
|
'annotation': { 'type': 'textStyle/bold' },
|
|
|
|
'offset': 3,
|
|
|
|
'expected': new ve.Range ( 1, 7 )
|
2012-05-17 18:23:56 +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.expect( cases.length );
|
2012-05-17 18:23:56 +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
|
|
|
for ( i = 0; i < cases.length; i++ ) {
|
2012-08-24 02:06:36 +00:00
|
|
|
ve.dm.example.preprocessAnnotations( cases[i].data );
|
2012-05-17 18:23:56 +00:00
|
|
|
doc = new ve.dm.Document( cases[i].data );
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.deepEqual(
|
2012-05-17 18:23:56 +00:00
|
|
|
doc.getAnnotatedRangeFromOffset(cases[i].offset, cases[i].annotation),
|
|
|
|
cases[i].expected,
|
|
|
|
cases[i].msg
|
|
|
|
);
|
|
|
|
}
|
2012-05-17 21:37:05 +00:00
|
|
|
} );
|
2012-05-17 18:23:56 +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( 'getOuterLength', 1, function ( assert ) {
|
2012-05-09 22:30:18 +00:00
|
|
|
var doc = new ve.dm.Document( ve.dm.example.data );
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.strictEqual(
|
2012-05-09 22:30:18 +00:00
|
|
|
doc.getDocumentNode().getOuterLength(),
|
2012-04-30 20:48:20 +00:00
|
|
|
ve.dm.example.data.length,
|
|
|
|
'document does not have elements around it'
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
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( 'isContentOffset', function ( assert ) {
|
2012-08-02 18:46:13 +00:00
|
|
|
var i, left, right,
|
|
|
|
data = [
|
2012-05-25 20:19:56 +00:00
|
|
|
{ 'type': 'heading' },
|
|
|
|
'a',
|
|
|
|
{ 'type': 'image' },
|
|
|
|
{ 'type': '/image' },
|
|
|
|
'b',
|
|
|
|
'c',
|
|
|
|
{ 'type': '/heading' },
|
|
|
|
{ 'type': 'paragraph' },
|
|
|
|
{ 'type': '/paragraph' },
|
|
|
|
{ 'type': 'preformatted' },
|
|
|
|
{ 'type': 'image' },
|
|
|
|
{ 'type': '/image' },
|
|
|
|
{ 'type': '/preformatted' },
|
|
|
|
{ 'type': 'list' },
|
|
|
|
{ 'type': 'listItem' },
|
|
|
|
{ 'type': '/listItem' },
|
|
|
|
{ 'type': '/list' },
|
|
|
|
{ 'type': 'alienBlock' },
|
|
|
|
{ 'type': '/alienBlock' },
|
|
|
|
{ 'type': 'table' },
|
|
|
|
{ 'type': 'tableRow' },
|
|
|
|
{ 'type': 'tableCell' },
|
|
|
|
{ 'type': 'alienBlock' },
|
|
|
|
{ 'type': '/alienBlock' },
|
|
|
|
{ 'type': '/tableCell' },
|
|
|
|
{ 'type': '/tableRow' },
|
|
|
|
{ 'type': '/table' }
|
|
|
|
],
|
|
|
|
cases = [
|
|
|
|
{ 'msg': 'left of document', 'expected': false },
|
|
|
|
{ 'msg': 'begining of content branch', 'expected': true },
|
|
|
|
{ 'msg': 'left of non-text inline leaf', 'expected': true },
|
|
|
|
{ 'msg': 'inside non-text inline leaf', 'expected': false },
|
|
|
|
{ 'msg': 'right of non-text inline leaf', 'expected': true },
|
|
|
|
{ 'msg': 'between characters', 'expected': true },
|
|
|
|
{ 'msg': 'end of content branch', 'expected': true },
|
|
|
|
{ 'msg': 'between content branches', 'expected': false },
|
|
|
|
{ 'msg': 'inside emtpy content branch', 'expected': true },
|
|
|
|
{ 'msg': 'between content branches', 'expected': false },
|
|
|
|
{ 'msg': 'begining of content branch, left of inline leaf', 'expected': true },
|
|
|
|
{ 'msg': 'inside content branch with non-text inline leaf', 'expected': false },
|
|
|
|
{ 'msg': 'end of content branch, right of non-content leaf', 'expected': true },
|
|
|
|
{ 'msg': 'between content, non-content branches', 'expected': false },
|
|
|
|
{ 'msg': 'between parent, child branches, descending', 'expected': false },
|
|
|
|
{ 'msg': 'inside empty non-content branch', 'expected': false },
|
|
|
|
{ 'msg': 'between parent, child branches, ascending', 'expected': false },
|
|
|
|
{ 'msg': 'between non-content branch, non-content leaf', 'expected': false },
|
|
|
|
{ 'msg': 'inside non-content leaf', 'expected': false },
|
|
|
|
{ 'msg': 'between non-content branches', 'expected': false },
|
|
|
|
{ 'msg': 'between non-content branches', 'expected': false },
|
|
|
|
{ 'msg': 'between non-content branches', 'expected': false },
|
|
|
|
{ 'msg': 'inside non-content branch before non-content leaf', 'expected': false },
|
|
|
|
{ 'msg': 'inside non-content leaf', 'expected': false },
|
|
|
|
{ 'msg': 'inside non-content branch after non-content leaf', 'expected': false },
|
|
|
|
{ 'msg': 'between non-content branches', 'expected': false },
|
|
|
|
{ 'msg': 'between non-content branches', 'expected': false },
|
|
|
|
{ 'msg': 'right of document', 'expected': false }
|
|
|
|
];
|
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.expect( data.length + 1 );
|
2012-08-02 18:46:13 +00:00
|
|
|
for ( i = 0; i < cases.length; i++ ) {
|
|
|
|
left = data[i - 1] ? ( data[i - 1].type || data[i - 1][0] ) : '[start]';
|
|
|
|
right = data[i] ? ( data[i].type || data[i][0] ) : '[end]';
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.strictEqual(
|
2012-05-25 20:19:56 +00:00
|
|
|
ve.dm.Document.isContentOffset( data, i ),
|
|
|
|
cases[i].expected,
|
|
|
|
cases[i].msg + ' (' + left + '|' + right + ' @ ' + i + ')'
|
|
|
|
);
|
2012-05-11 00:20:57 +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( 'isStructuralOffset', function ( assert ) {
|
2012-08-02 18:46:13 +00:00
|
|
|
var i, left, right,
|
|
|
|
data = [
|
2012-05-17 18:23:56 +00:00
|
|
|
{ 'type': 'heading' },
|
|
|
|
'a',
|
|
|
|
{ 'type': 'image' },
|
|
|
|
{ 'type': '/image' },
|
|
|
|
'b',
|
|
|
|
'c',
|
|
|
|
{ 'type': '/heading' },
|
|
|
|
{ 'type': 'paragraph' },
|
|
|
|
{ 'type': '/paragraph' },
|
|
|
|
{ 'type': 'preformatted' },
|
|
|
|
{ 'type': 'image' },
|
|
|
|
{ 'type': '/image' },
|
|
|
|
{ 'type': '/preformatted' },
|
|
|
|
{ 'type': 'list' },
|
|
|
|
{ 'type': 'listItem' },
|
|
|
|
{ 'type': '/listItem' },
|
2012-05-22 00:39:03 +00:00
|
|
|
{ 'type': '/list' },
|
|
|
|
{ 'type': 'alienBlock' },
|
2012-05-25 20:19:56 +00:00
|
|
|
{ 'type': '/alienBlock' },
|
|
|
|
{ 'type': 'table' },
|
|
|
|
{ 'type': 'tableRow' },
|
|
|
|
{ 'type': 'tableCell' },
|
|
|
|
{ 'type': 'alienBlock' },
|
|
|
|
{ 'type': '/alienBlock' },
|
|
|
|
{ 'type': '/tableCell' },
|
|
|
|
{ 'type': '/tableRow' },
|
|
|
|
{ 'type': '/table' }
|
2012-05-17 18:23:56 +00:00
|
|
|
],
|
|
|
|
cases = [
|
2012-05-23 21:56:33 +00:00
|
|
|
{ 'msg': 'left of document', 'expected': [true, true] },
|
|
|
|
{ 'msg': 'begining of content branch', 'expected': [false, false] },
|
|
|
|
{ 'msg': 'left of non-text inline leaf', 'expected': [false, false] },
|
|
|
|
{ 'msg': 'inside non-text inline leaf', 'expected': [false, false] },
|
|
|
|
{ 'msg': 'right of non-text inline leaf', 'expected': [false, false] },
|
|
|
|
{ 'msg': 'between characters', 'expected': [false, false] },
|
|
|
|
{ 'msg': 'end of content branch', 'expected': [false, false] },
|
|
|
|
{ 'msg': 'between content branches', 'expected': [true, true] },
|
|
|
|
{ 'msg': 'inside emtpy content branch', 'expected': [false, false] },
|
|
|
|
{ 'msg': 'between content branches', 'expected': [true, true] },
|
|
|
|
{ 'msg': 'begining of content branch, left of inline leaf', 'expected': [false, false] },
|
|
|
|
{ 'msg': 'inside content branch with non-text inline leaf', 'expected': [false, false] },
|
|
|
|
{ 'msg': 'end of content branch, right of inline leaf', 'expected': [false, false] },
|
|
|
|
{ 'msg': 'between content, non-content branches', 'expected': [true, true] },
|
|
|
|
{ 'msg': 'between parent, child branches, descending', 'expected': [true, false] },
|
|
|
|
{ 'msg': 'inside empty non-content branch', 'expected': [true, true] },
|
|
|
|
{ 'msg': 'between parent, child branches, ascending', 'expected': [true, false] },
|
2012-05-25 20:19:56 +00:00
|
|
|
{ 'msg': 'between non-content branch, non-content leaf', 'expected': [true, true] },
|
|
|
|
{ 'msg': 'inside non-content leaf', 'expected': [false, false] },
|
|
|
|
{ 'msg': 'between non-content branches', 'expected': [true, true] },
|
|
|
|
{ 'msg': 'between non-content branches', 'expected': [true, false] },
|
|
|
|
{ 'msg': 'between non-content branches', 'expected': [true, false] },
|
|
|
|
{ 'msg': 'inside non-content branch before non-content leaf', 'expected': [true, true] },
|
|
|
|
{ 'msg': 'inside non-content leaf', 'expected': [false, false] },
|
|
|
|
{ 'msg': 'inside non-content branch after non-content leaf', 'expected': [true, true] },
|
|
|
|
{ 'msg': 'between non-content branches', 'expected': [true, false] },
|
|
|
|
{ 'msg': 'between non-content branches', 'expected': [true, false] },
|
2012-05-23 21:56:33 +00:00
|
|
|
{ 'msg': 'right of document', 'expected': [true, true] }
|
2012-05-17 18:23:56 +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.expect( ( data.length + 1 ) * 2 );
|
2012-08-02 18:46:13 +00:00
|
|
|
for ( i = 0; i < cases.length; i++ ) {
|
2012-08-10 23:49:14 +00:00
|
|
|
left = data[i - 1] ? ( data[i - 1].type || data[i - 1][0] ) : '[start]';
|
2012-08-02 18:46:13 +00:00
|
|
|
right = data[i] ? ( data[i].type || data[i][0] ) : '[end]';
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.strictEqual(
|
2012-05-23 21:56:33 +00:00
|
|
|
ve.dm.Document.isStructuralOffset( data, i ),
|
|
|
|
cases[i].expected[0],
|
|
|
|
cases[i].msg + ' (' + left + '|' + right + ' @ ' + i + ')'
|
|
|
|
);
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.strictEqual(
|
2012-05-23 21:56:33 +00:00
|
|
|
ve.dm.Document.isStructuralOffset( data, i, true ),
|
|
|
|
cases[i].expected[1],
|
|
|
|
cases[i].msg + ', unrestricted (' + left + '|' + right + ' @ ' + i + ')'
|
|
|
|
);
|
2012-05-11 00:20:57 +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( 'isElementData', 1, function ( assert ) {
|
|
|
|
var i,
|
|
|
|
data = [
|
2012-05-17 18:23:56 +00:00
|
|
|
{ 'type': 'heading' },
|
|
|
|
'a',
|
|
|
|
{ 'type': 'image' },
|
|
|
|
{ 'type': '/image' },
|
|
|
|
'b',
|
|
|
|
'c',
|
|
|
|
{ 'type': '/heading' },
|
|
|
|
{ 'type': 'paragraph' },
|
|
|
|
{ 'type': '/paragraph' },
|
|
|
|
{ 'type': 'preformatted' },
|
|
|
|
{ 'type': 'image' },
|
|
|
|
{ 'type': '/image' },
|
|
|
|
{ 'type': '/preformatted' },
|
|
|
|
{ 'type': 'list' },
|
|
|
|
{ 'type': 'listItem' },
|
|
|
|
{ 'type': '/listItem' },
|
2012-05-22 00:39:03 +00:00
|
|
|
{ 'type': '/list' },
|
|
|
|
{ 'type': 'alienBlock' },
|
|
|
|
{ 'type': '/alienBlock' }
|
2012-05-17 18:23:56 +00:00
|
|
|
],
|
|
|
|
cases = [
|
|
|
|
{ 'msg': 'left of document', 'expected': true },
|
|
|
|
{ 'msg': 'begining of content branch', 'expected': false },
|
2012-05-22 00:39:03 +00:00
|
|
|
{ 'msg': 'left of non-text inline leaf', 'expected': true },
|
|
|
|
{ 'msg': 'inside non-text inline leaf', 'expected': true },
|
|
|
|
{ 'msg': 'right of non-text inline leaf', 'expected': false },
|
2012-05-17 18:23:56 +00:00
|
|
|
{ 'msg': 'between characters', 'expected': false },
|
|
|
|
{ 'msg': 'end of content branch', 'expected': true },
|
|
|
|
{ 'msg': 'between content branches', 'expected': true },
|
|
|
|
{ 'msg': 'inside emtpy content branch', 'expected': true },
|
|
|
|
{ 'msg': 'between content branches', 'expected': true },
|
2012-05-23 21:56:33 +00:00
|
|
|
{ 'msg': 'begining of content branch, left of inline leaf', 'expected': true },
|
|
|
|
{ 'msg': 'inside content branch with non-text leaf', 'expected': true },
|
|
|
|
{ 'msg': 'end of content branch, right of inline leaf', 'expected': true },
|
|
|
|
{ 'msg': 'between content, non-content branches', 'expected': true },
|
|
|
|
{ 'msg': 'between parent, child branches, descending', 'expected': true },
|
2012-05-17 18:23:56 +00:00
|
|
|
{ 'msg': 'inside empty non-content branch', 'expected': true },
|
2012-05-23 21:56:33 +00:00
|
|
|
{ 'msg': 'between parent, child branches, ascending', 'expected': true },
|
2012-05-25 20:19:56 +00:00
|
|
|
{ 'msg': 'between non-content branch, non-content leaf', 'expected': true },
|
|
|
|
{ 'msg': 'inside non-content leaf', 'expected': true },
|
2012-05-17 18:23:56 +00:00
|
|
|
{ 'msg': 'right of document', 'expected': false }
|
|
|
|
];
|
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.expect( data.length + 1 );
|
|
|
|
for ( i = 0; i < cases.length; i++ ) {
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.strictEqual( ve.dm.Document.isElementData( data, i ), cases[i].expected, cases[i].msg );
|
2012-05-11 00:20:57 +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( 'containsElementData', 1, function ( assert ) {
|
|
|
|
var i,
|
|
|
|
cases = [
|
2012-05-11 00:20:57 +00:00
|
|
|
{
|
|
|
|
'msg': 'simple paragraph',
|
|
|
|
'data': [{ 'type': 'paragraph' }, 'a', { 'type': '/paragraph' }],
|
|
|
|
'expected': true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'plain text',
|
|
|
|
'data': ['a', 'b', 'c'],
|
|
|
|
'expected': false
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'annotated text',
|
|
|
|
'data': [['a', { '{"type:"bold"}': { 'type': 'bold' } } ]],
|
|
|
|
'expected': false
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'non-text leaf',
|
|
|
|
'data': ['a', { 'type': 'image' }, { 'type': '/image' }, 'c'],
|
|
|
|
'expected': true
|
|
|
|
}
|
|
|
|
];
|
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.expect( cases.length );
|
|
|
|
for ( i = 0; i < cases.length; i++ ) {
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.strictEqual(
|
2012-05-11 00:20:57 +00:00
|
|
|
ve.dm.Document.containsElementData( cases[i].data ), cases[i].expected, cases[i].msg
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
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( 'isContentData', 1, function ( assert ) {
|
2012-08-02 18:46:13 +00:00
|
|
|
var i,
|
|
|
|
cases = [
|
2012-05-31 13:19:34 +00:00
|
|
|
{
|
|
|
|
'msg': 'simple paragraph',
|
|
|
|
'data': [{ 'type': 'paragraph' }, 'a', { 'type': '/paragraph' }],
|
|
|
|
'expected': false
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'plain text',
|
|
|
|
'data': ['a', 'b', 'c'],
|
|
|
|
'expected': true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'annotated text',
|
|
|
|
'data': [['a', { '{"type:"bold"}': { 'type': 'bold' } } ]],
|
|
|
|
'expected': true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'non-text leaf',
|
|
|
|
'data': ['a', { 'type': 'image' }, { 'type': '/image' }, 'c'],
|
|
|
|
'expected': true
|
|
|
|
}
|
|
|
|
];
|
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.expect( cases.length );
|
2012-08-02 18:46:13 +00:00
|
|
|
for ( i = 0; i < cases.length; i++ ) {
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.strictEqual(
|
2012-05-31 13:19:34 +00:00
|
|
|
ve.dm.Document.isContentData( cases[i].data ), cases[i].expected, cases[i].msg
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
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( 'rebuildNodes', function ( assert ) {
|
2012-08-02 18:46:13 +00:00
|
|
|
var tree,
|
2012-08-16 21:18:50 +00:00
|
|
|
doc = new ve.dm.Document( ve.dm.example.data ),
|
2012-04-30 20:42:32 +00:00
|
|
|
documentNode = doc.getDocumentNode();
|
2012-06-08 05:08:49 +00:00
|
|
|
// Rebuild table without changes
|
|
|
|
doc.rebuildNodes( documentNode, 1, 1, 5, 32 );
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.equalNodeTree(
|
|
|
|
documentNode,
|
|
|
|
ve.dm.example.tree,
|
2012-05-15 07:25:27 +00:00
|
|
|
'rebuild without changes'
|
|
|
|
);
|
2012-05-07 23:25:39 +00:00
|
|
|
|
2012-05-09 22:28:06 +00:00
|
|
|
// XXX: Create a new document node tree from the old one
|
2012-08-02 18:46:13 +00:00
|
|
|
tree = new ve.dm.DocumentNode( ve.dm.example.tree.getChildren() );
|
2012-05-10 01:31:09 +00:00
|
|
|
// Replace table with paragraph
|
2012-06-08 05:08:49 +00:00
|
|
|
doc.data.splice( 5, 32, { 'type': 'paragraph' }, 'a', 'b', 'c', { 'type': '/paragraph' } );
|
2012-05-07 23:25:39 +00:00
|
|
|
tree.splice( 1, 1, new ve.dm.ParagraphNode( [new ve.dm.TextNode( 3 )] ) );
|
|
|
|
// Rebuild with changes
|
|
|
|
doc.rebuildNodes( documentNode, 1, 1, 5, 5 );
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.equalNodeTree(
|
|
|
|
documentNode,
|
|
|
|
tree,
|
2012-05-15 07:25:27 +00:00
|
|
|
'replace table with paragraph'
|
|
|
|
);
|
2012-04-27 21:59:52 +00:00
|
|
|
} );
|
2012-05-07 22:14:37 +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( 'getRelativeOffset', function ( assert ) {
|
|
|
|
var i, doc, cases = [
|
2012-05-24 18:43:25 +00:00
|
|
|
{
|
|
|
|
'msg': 'document without any valid offsets returns -1',
|
|
|
|
'offset': 0,
|
|
|
|
'distance': 1,
|
|
|
|
'data': [],
|
2012-09-17 13:30:50 +00:00
|
|
|
'callback': function () {
|
2012-05-24 18:43:25 +00:00
|
|
|
return false;
|
|
|
|
},
|
|
|
|
'expected': -1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'document with all valid offsets returns offset + distance',
|
|
|
|
'offset': 0,
|
|
|
|
'distance': 2,
|
|
|
|
'data': ['a', 'b'],
|
2012-09-17 13:30:50 +00:00
|
|
|
'callback': function () {
|
2012-05-24 18:43:25 +00:00
|
|
|
return true;
|
|
|
|
},
|
|
|
|
'expected': 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
|
|
|
QUnit.expect( cases.length );
|
|
|
|
for ( i = 0; i < cases.length; i++ ) {
|
|
|
|
doc = new ve.dm.Document( cases[i].data );
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.strictEqual(
|
2012-05-24 18:43:25 +00:00
|
|
|
doc.getRelativeOffset.apply(
|
|
|
|
doc,
|
|
|
|
[
|
|
|
|
cases[i].offset,
|
|
|
|
cases[i].distance,
|
|
|
|
cases[i].callback
|
|
|
|
].concat( cases[i].args || [] )
|
|
|
|
),
|
|
|
|
cases[i].expected,
|
|
|
|
cases[i].msg
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
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( 'getRelativeContentOffset', function ( assert ) {
|
|
|
|
var i,
|
|
|
|
doc = new ve.dm.Document( ve.dm.example.data ),
|
2012-05-17 18:23:56 +00:00
|
|
|
cases = [
|
2012-05-24 00:43:10 +00:00
|
|
|
{
|
|
|
|
'msg': 'invalid starting offset with zero distance gets corrected',
|
|
|
|
'offset': 0,
|
|
|
|
'distance': 0,
|
|
|
|
'expected': 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'invalid starting offset with zero distance gets corrected',
|
2012-06-08 05:08:49 +00:00
|
|
|
'offset': 61,
|
2012-05-24 00:43:10 +00:00
|
|
|
'distance': 0,
|
2012-06-08 05:08:49 +00:00
|
|
|
'expected': 60
|
2012-05-24 00:43:10 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'valid offset with zero distance returns same offset',
|
|
|
|
'offset': 2,
|
|
|
|
'distance': 0,
|
|
|
|
'expected': 2
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'invalid starting offset gets corrected',
|
|
|
|
'offset': 0,
|
|
|
|
'distance': -1,
|
|
|
|
'expected': 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'invalid starting offset gets corrected',
|
2012-06-08 05:08:49 +00:00
|
|
|
'offset': 61,
|
2012-05-24 00:43:10 +00:00
|
|
|
'distance': 1,
|
2012-06-08 05:08:49 +00:00
|
|
|
'expected': 60
|
2012-05-24 00:43:10 +00:00
|
|
|
},
|
2012-05-11 19:14:29 +00:00
|
|
|
{
|
|
|
|
'msg': 'first content offset is farthest left',
|
|
|
|
'offset': 2,
|
|
|
|
'distance': -2,
|
|
|
|
'expected': 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'last content offset is farthest right',
|
2012-06-08 05:08:49 +00:00
|
|
|
'offset': 59,
|
2012-05-11 19:14:29 +00:00
|
|
|
'distance': 2,
|
2012-06-08 05:08:49 +00:00
|
|
|
'expected': 60
|
2012-05-11 19:14:29 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': '1 right within text',
|
|
|
|
'offset': 1,
|
|
|
|
'distance': 1,
|
|
|
|
'expected': 2
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': '2 right within text',
|
|
|
|
'offset': 1,
|
|
|
|
'distance': 2,
|
|
|
|
'expected': 3
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': '1 left within text',
|
|
|
|
'offset': 2,
|
|
|
|
'distance': -1,
|
|
|
|
'expected': 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': '2 left within text',
|
|
|
|
'offset': 3,
|
|
|
|
'distance': -2,
|
|
|
|
'expected': 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': '1 right over elements',
|
|
|
|
'offset': 4,
|
|
|
|
'distance': 1,
|
2012-06-08 05:08:49 +00:00
|
|
|
'expected': 10
|
2012-05-11 19:14:29 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': '2 right over elements',
|
|
|
|
'offset': 4,
|
|
|
|
'distance': 2,
|
2012-06-08 05:08:49 +00:00
|
|
|
'expected': 11
|
2012-05-11 19:14:29 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': '1 left over elements',
|
2012-06-08 05:08:49 +00:00
|
|
|
'offset': 10,
|
2012-05-11 19:14:29 +00:00
|
|
|
'distance': -1,
|
|
|
|
'expected': 4
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': '2 left over elements',
|
2012-06-08 05:08:49 +00:00
|
|
|
'offset': 10,
|
2012-05-11 19:14:29 +00:00
|
|
|
'distance': -2,
|
|
|
|
'expected': 3
|
|
|
|
}
|
|
|
|
];
|
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.expect( cases.length );
|
|
|
|
for ( i = 0; i < cases.length; i++ ) {
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.strictEqual(
|
2012-05-11 19:14:29 +00:00
|
|
|
doc.getRelativeContentOffset( cases[i].offset, cases[i].distance ),
|
|
|
|
cases[i].expected,
|
|
|
|
cases[i].msg
|
|
|
|
);
|
|
|
|
}
|
2012-05-11 00:20:57 +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( 'getNearestContentOffset', function ( assert ) {
|
2012-08-02 18:46:13 +00:00
|
|
|
var i,
|
|
|
|
doc = new ve.dm.Document( ve.dm.example.data ),
|
2012-05-24 00:43:10 +00:00
|
|
|
cases = [
|
|
|
|
{
|
|
|
|
'msg': 'unspecified direction results in shortest distance',
|
|
|
|
'offset': 0,
|
|
|
|
'direction': 0,
|
|
|
|
'expected': 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'unspecified direction results in shortest distance',
|
|
|
|
'offset': 5,
|
|
|
|
'direction': 0,
|
|
|
|
'expected': 4
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'positive direction results in next valid offset to the right',
|
|
|
|
'offset': 5,
|
|
|
|
'direction': 1,
|
2012-06-08 05:08:49 +00:00
|
|
|
'expected': 10
|
2012-05-24 00:43:10 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'negative direction results in next valid offset to the left',
|
|
|
|
'offset': 5,
|
|
|
|
'direction': -1,
|
|
|
|
'expected': 4
|
2012-05-25 03:53:50 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'valid offset without direction returns same offset',
|
|
|
|
'offset': 1,
|
|
|
|
'expected': 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'valid offset with positive direction returns same offset',
|
|
|
|
'offset': 1,
|
|
|
|
'direction': 1,
|
|
|
|
'expected': 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'valid offset with negative direction returns same offset',
|
|
|
|
'offset': 1,
|
|
|
|
'direction': -1,
|
|
|
|
'expected': 1
|
2012-05-24 00:43:10 +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.expect( cases.length );
|
2012-08-02 18:46:13 +00:00
|
|
|
for ( i = 0; i < cases.length; i++ ) {
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.strictEqual(
|
2012-05-24 00:43:10 +00:00
|
|
|
doc.getNearestContentOffset( cases[i].offset, cases[i].direction ),
|
|
|
|
cases[i].expected,
|
|
|
|
cases[i].msg
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
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( 'getRelativeStructuralOffset', function ( assert ) {
|
2012-08-02 18:46:13 +00:00
|
|
|
var i,
|
|
|
|
doc = new ve.dm.Document( ve.dm.example.data ),
|
2012-05-24 00:43:10 +00:00
|
|
|
cases = [
|
|
|
|
{
|
|
|
|
'msg': 'invalid starting offset with zero distance gets corrected',
|
|
|
|
'offset': 1,
|
|
|
|
'distance': 0,
|
|
|
|
'expected': 5
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'invalid starting offset with zero distance gets corrected',
|
2012-06-08 05:08:49 +00:00
|
|
|
'offset': 60,
|
2012-05-24 00:43:10 +00:00
|
|
|
'distance': 0,
|
2012-06-08 05:08:49 +00:00
|
|
|
'expected': 61
|
2012-05-24 00:43:10 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'valid offset with zero distance returns same offset',
|
|
|
|
'offset': 0,
|
|
|
|
'distance': 0,
|
|
|
|
'expected': 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'invalid starting offset gets corrected',
|
|
|
|
'offset': 2,
|
|
|
|
'distance': -1,
|
|
|
|
'expected': 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'invalid starting offset gets corrected',
|
2012-06-08 05:08:49 +00:00
|
|
|
'offset': 59,
|
2012-05-24 00:43:10 +00:00
|
|
|
'distance': 1,
|
2012-06-08 05:08:49 +00:00
|
|
|
'expected': 61
|
2012-05-24 00:43:10 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'first structural offset is farthest left',
|
|
|
|
'offset': 5,
|
|
|
|
'distance': -2,
|
|
|
|
'expected': 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'last structural offset is farthest right',
|
2012-06-08 05:08:49 +00:00
|
|
|
'offset': 58,
|
2012-05-24 00:43:10 +00:00
|
|
|
'distance': 2,
|
2012-06-08 05:08:49 +00:00
|
|
|
'expected': 61
|
2012-05-24 00:43:10 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': '1 right',
|
|
|
|
'offset': 0,
|
|
|
|
'distance': 1,
|
|
|
|
'expected': 5
|
|
|
|
},
|
2012-05-24 17:45:52 +00:00
|
|
|
{
|
|
|
|
'msg': '1 right, unrestricted',
|
|
|
|
'offset': 5,
|
|
|
|
'distance': 1,
|
|
|
|
'unrestricted': true,
|
2012-06-08 05:08:49 +00:00
|
|
|
'expected': 9
|
2012-05-24 17:45:52 +00:00
|
|
|
},
|
2012-05-24 00:43:10 +00:00
|
|
|
{
|
|
|
|
'msg': '2 right',
|
|
|
|
'offset': 0,
|
|
|
|
'distance': 2,
|
|
|
|
'expected': 6
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': '2 right, unrestricted',
|
|
|
|
'offset': 0,
|
|
|
|
'distance': 2,
|
|
|
|
'unrestricted': true,
|
2012-06-08 05:08:49 +00:00
|
|
|
'expected': 9
|
2012-05-24 00:43:10 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': '1 left',
|
2012-06-08 05:08:49 +00:00
|
|
|
'offset': 61,
|
2012-05-24 00:43:10 +00:00
|
|
|
'distance': -1,
|
2012-06-08 05:08:49 +00:00
|
|
|
'expected': 58
|
2012-05-24 00:43:10 +00:00
|
|
|
},
|
2012-05-24 17:45:52 +00:00
|
|
|
{
|
|
|
|
'msg': '1 left, unrestricted',
|
2012-06-08 05:08:49 +00:00
|
|
|
'offset': 9,
|
2012-05-24 17:45:52 +00:00
|
|
|
'distance': -1,
|
|
|
|
'unrestricted': true,
|
|
|
|
'expected': 5
|
|
|
|
},
|
2012-05-24 00:43:10 +00:00
|
|
|
{
|
|
|
|
'msg': '2 left',
|
2012-06-08 05:08:49 +00:00
|
|
|
'offset': 61,
|
2012-05-24 00:43:10 +00:00
|
|
|
'distance': -2,
|
2012-06-08 05:08:49 +00:00
|
|
|
'expected': 55
|
2012-05-24 17:45:52 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': '2 left, unrestricted',
|
2012-06-08 05:08:49 +00:00
|
|
|
'offset': 9,
|
2012-05-24 17:45:52 +00:00
|
|
|
'distance': -2,
|
|
|
|
'unrestricted': true,
|
|
|
|
'expected': 0
|
2012-05-24 00:43:10 +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.expect( cases.length );
|
2012-08-02 18:46:13 +00:00
|
|
|
for ( i = 0; i < cases.length; i++ ) {
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.strictEqual(
|
2012-05-24 00:43:10 +00:00
|
|
|
doc.getRelativeStructuralOffset(
|
|
|
|
cases[i].offset, cases[i].distance, cases[i].unrestricted
|
|
|
|
),
|
|
|
|
cases[i].expected,
|
|
|
|
cases[i].msg
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
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( 'getNearestStructuralOffset', function ( assert ) {
|
|
|
|
var i,
|
|
|
|
doc = new ve.dm.Document( ve.dm.example.data ),
|
2012-05-24 00:43:10 +00:00
|
|
|
cases = [
|
|
|
|
{
|
|
|
|
'msg': 'unspecified direction results in shortest distance',
|
|
|
|
'offset': 1,
|
|
|
|
'direction': 0,
|
|
|
|
'expected': 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'unspecified direction results in shortest distance',
|
|
|
|
'offset': 4,
|
|
|
|
'direction': 0,
|
|
|
|
'expected': 5
|
|
|
|
},
|
2012-05-24 17:45:52 +00:00
|
|
|
{
|
|
|
|
'msg': 'unspecified direction results in shortest distance, unrestricted',
|
2012-06-08 05:08:49 +00:00
|
|
|
'offset': 8,
|
2012-05-24 17:45:52 +00:00
|
|
|
'direction': 0,
|
|
|
|
'unrestricted': true,
|
2012-06-08 05:08:49 +00:00
|
|
|
'expected': 9
|
2012-05-24 17:45:52 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'unspecified direction results in shortest distance, unrestricted',
|
|
|
|
'offset': 6,
|
|
|
|
'direction': 0,
|
|
|
|
'unrestricted': true,
|
|
|
|
'expected': 5
|
|
|
|
},
|
2012-05-24 00:43:10 +00:00
|
|
|
{
|
|
|
|
'msg': 'positive direction results in next valid offset to the right',
|
|
|
|
'offset': 1,
|
|
|
|
'direction': 1,
|
|
|
|
'expected': 5
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'positive direction results in next valid offset to the right',
|
|
|
|
'offset': 4,
|
|
|
|
'direction': 1,
|
|
|
|
'expected': 5
|
|
|
|
},
|
2012-05-24 17:45:52 +00:00
|
|
|
{
|
|
|
|
'msg': 'positive direction results in next valid offset to the right, unrestricted',
|
2012-06-08 05:08:49 +00:00
|
|
|
'offset': 7,
|
2012-05-24 17:45:52 +00:00
|
|
|
'direction': 1,
|
|
|
|
'unrestricted': true,
|
2012-06-08 05:08:49 +00:00
|
|
|
'expected': 9
|
2012-05-24 17:45:52 +00:00
|
|
|
},
|
2012-05-24 00:43:10 +00:00
|
|
|
{
|
|
|
|
'msg': 'negative direction results in next valid offset to the left',
|
|
|
|
'offset': 1,
|
|
|
|
'direction': -1,
|
|
|
|
'expected': 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'negative direction results in next valid offset to the left',
|
|
|
|
'offset': 4,
|
|
|
|
'direction': -1,
|
|
|
|
'expected': 0
|
2012-05-24 17:45:52 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'negative direction results in next valid offset to the left, unrestricted',
|
2012-06-08 05:08:49 +00:00
|
|
|
'offset': 6,
|
2012-05-24 17:45:52 +00:00
|
|
|
'direction': -1,
|
|
|
|
'unrestricted': true,
|
|
|
|
'expected': 5
|
2012-05-25 03:53:50 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'valid offset without direction returns same offset',
|
|
|
|
'offset': 0,
|
|
|
|
'expected': 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'valid offset with positive direction returns same offset',
|
|
|
|
'offset': 0,
|
|
|
|
'direction': 1,
|
|
|
|
'expected': 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'valid offset with negative direction returns same offset',
|
|
|
|
'offset': 0,
|
|
|
|
'direction': -1,
|
|
|
|
'expected': 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'valid offset without direction returns same offset, unrestricted',
|
|
|
|
'offset': 0,
|
|
|
|
'unrestricted': true,
|
|
|
|
'expected': 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'valid offset with positive direction returns same offset, unrestricted',
|
|
|
|
'offset': 0,
|
|
|
|
'direction': 1,
|
|
|
|
'unrestricted': true,
|
|
|
|
'expected': 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'valid offset with negative direction returns same offset, unrestricted',
|
|
|
|
'offset': 0,
|
|
|
|
'direction': -1,
|
|
|
|
'unrestricted': true,
|
|
|
|
'expected': 0
|
2012-05-24 00:43:10 +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.expect( cases.length );
|
|
|
|
for ( i = 0; i < cases.length; i++ ) {
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.strictEqual(
|
2012-05-24 00:43:10 +00:00
|
|
|
doc.getNearestStructuralOffset(
|
|
|
|
cases[i].offset, cases[i].direction, cases[i].unrestricted
|
|
|
|
),
|
|
|
|
cases[i].expected,
|
|
|
|
cases[i].msg
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
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( 'selectNodes', function ( assert ) {
|
|
|
|
var i,
|
|
|
|
doc = new ve.dm.Document( ve.dm.example.data ),
|
2012-05-10 04:11:09 +00:00
|
|
|
cases = ve.example.getSelectNodesCases( doc );
|
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 ( i = 0; i < cases.length; i++ ) {
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.equalNodeSelection( cases[i].actual, cases[i].expected, cases[i].msg );
|
2012-05-09 22:28:06 +00:00
|
|
|
}
|
2012-05-07 22:14:37 +00:00
|
|
|
} );
|
2012-06-07 20:17:46 +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( 'getBalancedData', function ( assert ) {
|
|
|
|
var i,
|
|
|
|
doc = new ve.dm.Document( ve.dm.example.data ),
|
2012-06-07 20:17:46 +00:00
|
|
|
cases = [
|
|
|
|
{
|
|
|
|
'msg': 'empty range',
|
|
|
|
'range': new ve.Range( 2, 2 ),
|
|
|
|
'expected': []
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'range with one character',
|
|
|
|
'range': new ve.Range( 2, 3 ),
|
|
|
|
'expected': [
|
2012-08-24 02:06:36 +00:00
|
|
|
['b', [ { 'type': 'textStyle/bold' } ]]
|
2012-06-07 20:17:46 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'range with two characters',
|
|
|
|
'range': new ve.Range( 2, 4 ),
|
|
|
|
'expected': [
|
2012-08-24 02:06:36 +00:00
|
|
|
['b', [ { 'type': 'textStyle/bold' } ]],
|
|
|
|
['c', [ { 'type': 'textStyle/italic' } ]]
|
2012-06-07 20:17:46 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'range with two characters and a header closing',
|
|
|
|
'range': new ve.Range( 2, 5 ),
|
|
|
|
'expected': [
|
|
|
|
{ 'type': 'heading', 'attributes': { 'level': 1 } },
|
2012-08-24 02:06:36 +00:00
|
|
|
['b', [ { 'type': 'textStyle/bold' } ]],
|
|
|
|
['c', [ { 'type': 'textStyle/italic' } ]],
|
2012-06-07 20:17:46 +00:00
|
|
|
{ 'type': '/heading' }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'range with one character, a header closing and a table opening',
|
|
|
|
'range': new ve.Range( 3, 6 ),
|
|
|
|
'expected': [
|
|
|
|
{ 'type': 'heading', 'attributes': { 'level': 1 } },
|
2012-08-24 02:06:36 +00:00
|
|
|
['c', [ { 'type': 'textStyle/italic' } ]],
|
2012-06-07 20:17:46 +00:00
|
|
|
{ 'type': '/heading' },
|
|
|
|
{ 'type': 'table' },
|
|
|
|
{ 'type': '/table' }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'range from a paragraph into a list',
|
2012-06-08 05:08:49 +00:00
|
|
|
'range': new ve.Range( 15, 21 ),
|
2012-06-07 20:17:46 +00:00
|
|
|
'expected': [
|
|
|
|
{ 'type': 'paragraph' },
|
|
|
|
'e',
|
|
|
|
{ 'type': '/paragraph' },
|
|
|
|
{ 'type': 'list', 'attributes': { 'style': 'bullet' } },
|
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
|
|
|
{ 'type': 'listItem' },
|
2012-06-07 20:17:46 +00:00
|
|
|
{ 'type': 'paragraph' },
|
|
|
|
'f',
|
|
|
|
{ 'type': '/paragraph' },
|
|
|
|
{ 'type': '/listItem' },
|
|
|
|
{ 'type': '/list' }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'range from a paragraph inside a nested list into the next list',
|
2012-06-08 05:08:49 +00:00
|
|
|
'range': new ve.Range( 20, 27 ),
|
2012-06-07 20:17:46 +00:00
|
|
|
'expected': [
|
|
|
|
{ 'type': 'list', 'attributes': { 'style': 'bullet' } },
|
|
|
|
{ 'type': 'listItem' },
|
|
|
|
{ 'type': 'list', 'attributes': { 'style': 'bullet' } },
|
|
|
|
{ 'type': 'listItem' },
|
|
|
|
{ 'type': 'paragraph' },
|
|
|
|
'f',
|
|
|
|
{ 'type': '/paragraph' },
|
|
|
|
{ 'type': '/listItem' },
|
|
|
|
{ 'type': '/list' },
|
|
|
|
{ 'type': '/listItem' },
|
|
|
|
{ 'type': '/list' },
|
|
|
|
{ 'type': 'list', 'attributes': { 'style': 'number' } },
|
|
|
|
{ 'type': '/list' }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'range from a paragraph inside a nested list out of both lists',
|
2012-06-08 05:08:49 +00:00
|
|
|
'range': new ve.Range( 20, 26 ),
|
2012-06-07 20:17:46 +00:00
|
|
|
'expected': [
|
|
|
|
{ 'type': 'list', 'attributes': { 'style': 'bullet' } },
|
|
|
|
{ 'type': 'listItem' },
|
|
|
|
{ 'type': 'list', 'attributes': { 'style': 'bullet' } },
|
|
|
|
{ 'type': 'listItem' },
|
|
|
|
{ 'type': 'paragraph' },
|
|
|
|
'f',
|
|
|
|
{ 'type': '/paragraph' },
|
|
|
|
{ 'type': '/listItem' },
|
|
|
|
{ 'type': '/list' },
|
|
|
|
{ 'type': '/listItem' },
|
|
|
|
{ 'type': '/list' }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'range from a paragraph inside a nested list out of the outer listItem',
|
2012-06-08 05:08:49 +00:00
|
|
|
'range': new ve.Range( 20, 25 ),
|
2012-06-07 20:17:46 +00:00
|
|
|
'expected': [
|
|
|
|
{ 'type': 'listItem' },
|
|
|
|
{ 'type': 'list', 'attributes': { 'style': 'bullet' } },
|
|
|
|
{ 'type': 'listItem' },
|
|
|
|
{ 'type': 'paragraph' },
|
|
|
|
'f',
|
|
|
|
{ 'type': '/paragraph' },
|
|
|
|
{ 'type': '/listItem' },
|
|
|
|
{ 'type': '/list' },
|
|
|
|
{ 'type': '/listItem' }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
];
|
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.expect( cases.length );
|
|
|
|
for ( i = 0; i < cases.length; i++ ) {
|
2012-08-24 02:06:36 +00:00
|
|
|
ve.dm.example.preprocessAnnotations( cases[i].expected );
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.deepEqual(
|
2012-06-07 20:17:46 +00:00
|
|
|
doc.getBalancedData( cases[i].range ),
|
|
|
|
cases[i].expected,
|
|
|
|
cases[i].msg
|
|
|
|
);
|
|
|
|
}
|
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
|
|
|
} );
|