mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-09-29 13:26:28 +00:00
f04abd02d4
3 or 5 tilde signatures will be assumed to be erroneous and fixed to 4 tilde signatures. This will be visible in the preview so shouldn't come as a suprise to users. Bug: T245628 Change-Id: I741f0761a6fb10c99cf3239ac5c6c7e1a2b872c7
68 lines
1.4 KiB
JavaScript
68 lines
1.4 KiB
JavaScript
var
|
|
utils = require( './testUtils.js' ),
|
|
controller = require( 'ext.discussionTools.init' ).controller;
|
|
|
|
QUnit.module( 'mw.dt.controller', utils.newEnvironment() );
|
|
|
|
QUnit.test( 'autoSignWikitext', function ( assert ) {
|
|
var cases;
|
|
|
|
cases = [
|
|
{
|
|
msg: 'Simple message',
|
|
wikitext: 'Foo bar',
|
|
expected: 'Foo bar ~~~~'
|
|
},
|
|
{
|
|
msg: 'Whitespace',
|
|
wikitext: ' \t Foo bar \t ',
|
|
expected: 'Foo bar ~~~~'
|
|
},
|
|
{
|
|
msg: 'Already signed',
|
|
wikitext: 'Foo bar ~~~~',
|
|
expected: 'Foo bar ~~~~'
|
|
},
|
|
{
|
|
msg: 'Already signed multi-line',
|
|
wikitext: 'Foo\n\nbar\n\n~~~~',
|
|
expected: 'Foo\n\nbar\n\n~~~~'
|
|
},
|
|
{
|
|
msg: 'Already signed with hyphens',
|
|
wikitext: 'Foo bar --~~~~',
|
|
expected: 'Foo bar --~~~~'
|
|
},
|
|
{
|
|
msg: 'Already signed without space',
|
|
wikitext: 'Foo bar~~~~',
|
|
// Unless we special case certain characters, such as "-" this
|
|
// has to behave the same as "Already signed with hyphens"
|
|
expected: 'Foo bar~~~~'
|
|
},
|
|
{
|
|
msg: 'Signed with 5 tildes',
|
|
wikitext: 'Foo bar ~~~~~',
|
|
expected: 'Foo bar ~~~~'
|
|
},
|
|
{
|
|
msg: 'Signed with 3 tildes',
|
|
wikitext: 'Foo bar ~~~',
|
|
expected: 'Foo bar ~~~~'
|
|
},
|
|
{
|
|
msg: 'Signed with 3 tildes and prefix',
|
|
wikitext: 'Foo bar --~~~',
|
|
expected: 'Foo bar --~~~~'
|
|
}
|
|
];
|
|
|
|
cases.forEach( function ( caseItem ) {
|
|
assert.strictEqual(
|
|
controller.autoSignWikitext( caseItem.wikitext ),
|
|
caseItem.expected,
|
|
caseItem.msg
|
|
);
|
|
} );
|
|
} );
|