JSDuck: Generated code documentation!
See CODING.md for how to run it.
Mistakes fixed:
* Warning: Unknown type function
-> Function
* Warning: Unknown type DOMElement
-> HTMLElement
* Warning: Unknown type DOM Node
-> HTMLElement
* Warning: Unknown type Integer
-> Mixed
* Warning: Unknown type Command
-> ve.Command
* Warning: Unknown type any
-> number
* Warning: Unknown type ve.Transaction
-> ve.dm.Transaction
* Warning: Unknown type ve.dm.AnnotationSet
-> ve.AnnotationSet
* Warning: Unknown type false
-> boolean
* Warning: Unknown type ve.dm.AlienNode
ve.dm doesn't have a generic AlienNode like ve.ce
-> Unknown type ve.dm.AlienInlineNode|ve.dm.AlienBlockNode
* Warning: Unknown type ve.ve.Surface
-> ve.ce.Surface
* ve.example.lookupNode:
-> Last @param should be @return
* ve.dm.Transaction.prototype.pushReplace:
-> @param {Array] should be @param {Array}
* Warning: ve.BranchNode.js:27: {@link ve.Node#hasChildren} links to non-existing member
-> (removed)
* Warning: ve.LeafNode.js:21: {@link ve.Node#hasChildren} links to non-existing member
-> (removed)
Differences fixed:
* Variadic arguments are like @param {Type...} [name]
instead of @param {Type} [name...]
* Convert all file headers from /** to /*! because JSDuck tries
to parse all /** blocks and fails to parse with all sorts of
errors for "Global property", "Unnamed property", and
"Duplicate property".
Find: \/\*\*([^@]+)(@copyright)
Replace: /*!$1$2
* Indented blocks are considered code examples.
A few methods had documentation with numbered lists that were
indented, which have now been updated to not be intended.
* The free-form text descriptions are parsed with Markdown,
which requires lists to be separated from paragraphs by an
empty line.
And we should use `backticks` instead of {braces} for inline
code in text paragraphs.
* Doc blocks for classes and their constructor have to be
in the correct order (@constructor, @param, @return must be
before @class, @abstract, @extends etc.)
* `@extends Class` must not have Class {wrapped}
* @throws must start with a {Type}
* @example means something else. It is used for an inline demo
iframe, not code block. For that simply indent with spaces.
* @member means something else.
Non-function properties are marked with @property, not @member.
* To create a link to a class or member, in most cases the name
is enough to create a link. E.g. Foo, Foo.bar, Foo.bar#quux,
where a hash stands for "instance member", so Foo.bar#quux,
links to Foo.bar.prototype.quux (the is not supported, as
"prototype" is considered an implementation detail, it only
indexes class name and method name).
If the magic linker doesn't work for some case, the
verbose syntax is {@link #target label}.
* @property can't have sub-properties (nested @param and @return
values are supported, only @static @property can't be nested).
We only have one case of this, which can be worked around by
moving those in a new virtual class. The code is unaltered
(only moved down so that it isn't with the scope of the main
@class block). ve.dm.TransactionProcessor.processors.
New:
* @mixins: Classes mixed into the current class.
* @event: Events that can be emitted by a class. These are also
inherited by subclasses. (+ @param, @return and @preventable).
So ve.Node#event-attach is inherited to ve.dm.BreakNode,
just like @method is.
* @singleton: Plain objects such as ve, ve.dm, ve.ce were missing
documentation causing a tree error. Documented those as a
JSDuck singleton, which they but just weren't documented yet.
NB: Members of @singleton don't need @static (if present,
triggers a compiler warning).
* @chainable: Shorthand for "@return this". We were using
"@return {classname}" which is ambiguous (returns the same
instance or another instance?), @chainable is specifically
for "@return this". Creates proper labels in the generated
HTML pages.
Removed:
* @mixin: (not to be confused with @mixins). Not supported by
JSDuck. Every class is standalone anyway. Where needed marked
them @class + @abstract instead.
Change-Id: I6a7c9e8ee8f995731bc205d666167874eb2ebe23
2013-01-04 08:54:17 +00:00
|
|
|
/*!
|
2013-01-15 23:38:49 +00:00
|
|
|
* VisualEditor DataModel Document tests.
|
2012-07-19 21:25:16 +00:00
|
|
|
*
|
2013-02-19 23:37:34 +00:00
|
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
2012-07-19 00:11:26 +00:00
|
|
|
* @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 */
|
|
|
|
|
2013-04-06 16:45:26 +00:00
|
|
|
QUnit.test( 'constructor', 8, function ( assert ) {
|
2013-03-20 22:35:05 +00:00
|
|
|
var doc = ve.dm.example.createExampleDocument();
|
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'
|
|
|
|
);
|
2013-06-05 17:22:01 +00:00
|
|
|
assert.deepEqualWithDomElements( doc.getMetadata(), new Array( 5 ),
|
2013-04-06 16:45:26 +00:00
|
|
|
'sparse metadata array is created'
|
|
|
|
);
|
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(),
|
2013-01-29 17:39:09 +00:00
|
|
|
new ve.dm.DocumentNode( [ new ve.dm.ParagraphNode( [], { 'type': 'paragraph' } ) ] ),
|
|
|
|
'empty paragraph no longer has a text node'
|
2012-06-06 22:33:42 +00:00
|
|
|
);
|
2012-10-30 01:42:12 +00:00
|
|
|
|
2013-03-20 22:35:05 +00:00
|
|
|
doc = ve.dm.example.createExampleDocument( 'withMeta' );
|
2013-06-05 17:22:01 +00:00
|
|
|
assert.deepEqualWithDomElements( doc.getData(), ve.dm.example.withMetaPlainData,
|
2012-10-30 01:42:12 +00:00
|
|
|
'metadata is stripped out of the linear model'
|
|
|
|
);
|
2013-06-05 17:22:01 +00:00
|
|
|
assert.deepEqualWithDomElements( doc.getMetadata(), ve.dm.example.withMetaMetaData,
|
2012-10-30 01:42:12 +00:00
|
|
|
'metadata is put in the meta-linmod'
|
|
|
|
);
|
|
|
|
assert.equalNodeTree(
|
|
|
|
doc.getDocumentNode(),
|
2013-06-10 23:05:42 +00:00
|
|
|
new ve.dm.DocumentNode( [
|
|
|
|
new ve.dm.ParagraphNode( [ new ve.dm.TextNode( 9 ) ], ve.dm.example.withMetaPlainData[0] ),
|
|
|
|
new ve.dm.InternalListNode( [], ve.dm.example.withMetaPlainData[11] )
|
|
|
|
] ),
|
2012-10-30 01:42:12 +00:00
|
|
|
'node tree does not contain metadata'
|
|
|
|
);
|
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 ) {
|
2013-03-20 22:35:05 +00:00
|
|
|
var doc = ve.dm.example.createExampleDocument(),
|
2013-07-28 20:51:32 +00:00
|
|
|
expectedData = ve.dm.example.preprocessAnnotations( ve.copy( ve.dm.example.data ) );
|
2013-06-05 17:22:01 +00:00
|
|
|
assert.deepEqualWithDomElements( doc.getData(), expectedData.getData() );
|
2012-05-17 18:23:56 +00:00
|
|
|
} );
|
|
|
|
|
2012-10-30 01:42:12 +00:00
|
|
|
QUnit.test( 'getFullData', 1, function ( assert ) {
|
2013-03-20 22:35:05 +00:00
|
|
|
var doc = ve.dm.example.createExampleDocument( 'withMeta' );
|
2013-06-05 17:22:01 +00:00
|
|
|
assert.deepEqualWithDomElements( doc.getFullData(), ve.dm.example.withMeta );
|
2012-10-30 01:42:12 +00:00
|
|
|
} );
|
|
|
|
|
2013-05-22 14:48:41 +00:00
|
|
|
QUnit.test( 'getDocumentSlice', function ( assert ) {
|
|
|
|
var i, doc2, doc = ve.dm.example.createExampleDocument( 'internalData' ),
|
|
|
|
cases = [
|
|
|
|
{
|
|
|
|
'msg': 'with range',
|
|
|
|
'doc': 'internalData',
|
|
|
|
'arg': new ve.Range( 7, 12 ),
|
|
|
|
'expectedData': doc.data.slice( 7, 12 ).concat( doc.data.slice( 5, 21 ) )
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'with node',
|
|
|
|
'doc': 'internalData',
|
|
|
|
'arg': doc.getInternalList().getItemNode( 1 ),
|
|
|
|
'expectedData': doc.data.slice( 14, 19 ).concat( doc.data.slice( 5, 21 ) )
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'paragraph at the start',
|
|
|
|
'doc': 'internalData',
|
|
|
|
'arg': new ve.Range( 0, 5 ),
|
|
|
|
'expectedData': doc.data.slice( 0, 21 )
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'paragraph at the end',
|
|
|
|
'doc': 'internalData',
|
|
|
|
'arg': new ve.Range( 21, 27 ),
|
|
|
|
'expectedData': doc.data.slice( 21, 27 ).concat( doc.data.slice( 5, 21 ) )
|
|
|
|
}
|
|
|
|
];
|
2013-06-07 16:58:34 +00:00
|
|
|
QUnit.expect( 4*cases.length );
|
2013-05-22 14:48:41 +00:00
|
|
|
for ( i = 0; i < cases.length; i++ ) {
|
|
|
|
doc = ve.dm.example.createExampleDocument( cases[i].doc );
|
|
|
|
doc2 = doc.getDocumentSlice( cases[i].arg );
|
|
|
|
assert.deepEqual( doc2.data.data, cases[i].expectedData,
|
|
|
|
cases[i].msg + ': sliced data' );
|
|
|
|
assert.notStrictEqual( doc2.data[0], cases[i].expectedData[0],
|
|
|
|
cases[i].msg + ': data is cloned, not the same' );
|
|
|
|
assert.deepEqual( doc2.store, doc.store,
|
|
|
|
cases[i].msg + ': store is copied' );
|
|
|
|
assert.notStrictEqual( doc2.store, doc.store,
|
|
|
|
cases[i].msg + ': store is a clone, not the same' );
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
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,
|
2013-03-20 22:35:05 +00:00
|
|
|
doc = ve.dm.example.createExampleDocument(),
|
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 ) {
|
2013-03-20 22:35:05 +00:00
|
|
|
var doc = ve.dm.example.createExampleDocument(),
|
2013-07-28 20:51:32 +00:00
|
|
|
expectedData = ve.dm.example.preprocessAnnotations( ve.copy( 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] ),
|
2013-03-20 22:35:05 +00:00
|
|
|
expectedData.slice( 1, 4 ),
|
2012-05-17 18:23:56 +00:00
|
|
|
'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] ),
|
2013-03-20 22:35:05 +00:00
|
|
|
expectedData.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( 'getOuterLength', 1, function ( assert ) {
|
2013-03-20 22:35:05 +00:00
|
|
|
var doc = ve.dm.example.createExampleDocument();
|
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'
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
2012-10-25 20:06:07 +00:00
|
|
|
QUnit.test( 'rebuildNodes', 2, function ( assert ) {
|
2012-08-02 18:46:13 +00:00
|
|
|
var tree,
|
2013-03-20 22:35:05 +00:00
|
|
|
doc = ve.dm.example.createExampleDocument(),
|
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
|
2013-04-06 16:45:26 +00:00
|
|
|
doc.data.batchSplice( 5, 32, [ { 'type': 'paragraph' }, 'a', 'b', 'c', { 'type': '/paragraph' } ] );
|
2012-11-23 23:16:08 +00:00
|
|
|
tree.splice( 1, 1, new ve.dm.ParagraphNode(
|
2013-03-20 22:35:05 +00:00
|
|
|
[new ve.dm.TextNode( 3 )], doc.data.getData( 5 )
|
2012-11-23 23:16:08 +00:00
|
|
|
) );
|
2012-05-07 23:25:39 +00:00
|
|
|
// 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
|
|
|
|
2013-06-14 00:29:32 +00:00
|
|
|
QUnit.test( 'selectNodes', function ( assert ) {
|
|
|
|
var i, doc, expectedSelection,
|
|
|
|
mainDoc = ve.dm.example.createExampleDocument(),
|
|
|
|
cases = ve.dm.example.selectNodesCases;
|
|
|
|
|
|
|
|
function resolveNode( item ) {
|
|
|
|
var newItem = ve.extendObject( {}, item );
|
|
|
|
newItem.node = ve.dm.example.lookupNode.apply(
|
|
|
|
ve.dm.example, [ doc.getDocumentNode() ].concat( item.node )
|
|
|
|
);
|
|
|
|
return newItem;
|
|
|
|
}
|
2012-10-25 20:06:07 +00:00
|
|
|
|
2013-06-14 00:29:32 +00:00
|
|
|
QUnit.expect( cases.length );
|
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++ ) {
|
2013-06-14 00:29:32 +00:00
|
|
|
doc = cases[i].doc ? ve.dm.example.createExampleDocument( cases[i].doc ) : mainDoc;
|
|
|
|
expectedSelection = cases[i].expected.map( resolveNode );
|
|
|
|
assert.equalNodeSelection(
|
|
|
|
doc.selectNodes( cases[i].range, cases[i].mode ), expectedSelection, 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
|
|
|
|
2012-12-07 01:23:03 +00:00
|
|
|
QUnit.test( 'getSlice', function ( assert ) {
|
2013-03-20 22:35:05 +00:00
|
|
|
var i, data, doc = ve.dm.example.createExampleDocument(),
|
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-10-06 00:34:12 +00:00
|
|
|
['b', [ ve.dm.example.bold ]]
|
2012-06-07 20:17:46 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'msg': 'range with two characters',
|
|
|
|
'range': new ve.Range( 2, 4 ),
|
|
|
|
'expected': [
|
2012-10-06 00:34:12 +00:00
|
|
|
['b', [ ve.dm.example.bold ]],
|
|
|
|
['c', [ ve.dm.example.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-10-06 00:34:12 +00:00
|
|
|
['b', [ ve.dm.example.bold ]],
|
|
|
|
['c', [ ve.dm.example.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-10-06 00:34:12 +00:00
|
|
|
['c', [ ve.dm.example.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++ ) {
|
2013-03-20 22:35:05 +00:00
|
|
|
data = ve.dm.example.preprocessAnnotations( cases[i].expected.slice(), doc.getStore() );
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.deepEqual(
|
2012-12-07 01:23:03 +00:00
|
|
|
doc.getSlice( cases[i].range ).getBalancedData(),
|
2013-03-20 22:35:05 +00:00
|
|
|
data.getData(),
|
2012-06-07 20:17:46 +00:00
|
|
|
cases[i].msg
|
|
|
|
);
|
|
|
|
}
|
2013-03-21 23:48:03 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
QUnit.test( 'protection against double application of transactions', 3, function ( assert ) {
|
|
|
|
var tx = new ve.dm.Transaction(),
|
|
|
|
testDocument = new ve.dm.Document( ve.dm.example.data );
|
|
|
|
tx.pushRetain( 1 );
|
2013-04-06 16:45:26 +00:00
|
|
|
tx.pushReplace( testDocument, 1, 0, ['H', 'e', 'l', 'l', 'o' ] );
|
2013-03-21 23:48:03 +00:00
|
|
|
assert.throws(
|
|
|
|
function () {
|
|
|
|
testDocument.rollback( tx );
|
|
|
|
},
|
|
|
|
Error,
|
|
|
|
'exception thrown when trying to rollback an uncommitted transaction'
|
|
|
|
);
|
|
|
|
testDocument.commit( tx );
|
|
|
|
assert.throws(
|
|
|
|
function () {
|
|
|
|
testDocument.commit( tx );
|
|
|
|
},
|
|
|
|
Error,
|
|
|
|
'exception thrown when trying to commit an already-committed transaction'
|
|
|
|
);
|
|
|
|
testDocument.rollback( tx );
|
|
|
|
assert.throws(
|
|
|
|
function () {
|
|
|
|
testDocument.rollback( tx );
|
|
|
|
},
|
|
|
|
Error,
|
|
|
|
'exception thrown when trying to roll back a transaction that has already been rolled back'
|
|
|
|
);
|
2013-07-28 20:51:32 +00:00
|
|
|
} );
|