/* eslint-disable camelcase */
/* eslint no-underscore-dangle: "off" */
-( function ( mw, $ ) {
+( function () {
var mockFilterStructure = [ {
name: 'group1',
title: 'Group 1',
QUnit.test( 'getVersion', function ( assert ) {
var uriProcessor = new mw.rcfilters.UriProcessor( new mw.rcfilters.dm.FiltersViewModel() );
- assert.ok(
+ assert.strictEqual(
uriProcessor.getVersion( { param1: 'foo', urlversion: '2' } ),
2,
'Retrieving the version from the URI query'
);
- assert.ok(
+ assert.strictEqual(
uriProcessor.getVersion( { param1: 'foo' } ),
1,
'Getting version 1 if no version is specified'
uriProcessor = new mw.rcfilters.UriProcessor( filtersModel );
cases.forEach( function ( testCase ) {
- assert.equal(
+ assert.strictEqual(
uriProcessor.isNewState( testCase.states.curr, testCase.states.new ),
testCase.result,
testCase.message
uriProcessor = new mw.rcfilters.UriProcessor( filtersModel );
cases.forEach( function ( testCase ) {
- assert.equal(
+ assert.strictEqual(
uriProcessor.doesQueryContainRecognizedParams( testCase.query ),
testCase.result,
testCase.message
} );
QUnit.test( '_normalizeTargetInUri', function ( assert ) {
- var uriProcessor = new mw.rcfilters.UriProcessor( null ),
- cases = [
- {
- input: 'http://host/wiki/Special:RecentChangesLinked/Moai',
- output: 'http://host/wiki/Special:RecentChangesLinked?target=Moai',
- message: 'Target as subpage in path'
- },
- {
- input: 'http://host/wiki/Special:RecentChangesLinked/Château',
- output: 'http://host/wiki/Special:RecentChangesLinked?target=Château',
- message: 'Target as subpage in path with special characters'
- },
- {
- input: 'http://host/wiki/Special:RecentChangesLinked/Moai/Sub1',
- output: 'http://host/wiki/Special:RecentChangesLinked?target=Moai/Sub1',
- message: 'Target as subpage also has a subpage'
- },
- {
- input: 'http://host/wiki/Special:RecentChangesLinked/Category:Foo',
- output: 'http://host/wiki/Special:RecentChangesLinked?target=Category:Foo',
- message: 'Target as subpage in path (with namespace)'
- },
- {
- input: 'http://host/wiki/Special:RecentChangesLinked/Category:Foo/Bar',
- output: 'http://host/wiki/Special:RecentChangesLinked?target=Category:Foo/Bar',
- message: 'Target as subpage in path also has a subpage (with namespace)'
- },
- {
- input: 'http://host/w/index.php?title=Special:RecentChangesLinked/Moai',
- output: 'http://host/w/index.php?title=Special:RecentChangesLinked&target=Moai',
- message: 'Target as subpage in title param'
- },
- {
- input: 'http://host/w/index.php?title=Special:RecentChangesLinked/Moai/Sub1',
- output: 'http://host/w/index.php?title=Special:RecentChangesLinked&target=Moai/Sub1',
- message: 'Target as subpage in title param also has a subpage'
- },
- {
- input: 'http://host/w/index.php?title=Special:RecentChangesLinked/Category:Foo/Bar',
- output: 'http://host/w/index.php?title=Special:RecentChangesLinked&target=Category:Foo/Bar',
- message: 'Target as subpage in title param also has a subpage (with namespace)'
- },
+ var cases = [
+ {
+ input: 'http://host/wiki/Special:RecentChangesLinked/Moai',
+ output: 'http://host/wiki/Special:RecentChangesLinked?target=Moai',
+ message: 'Target as subpage in path'
+ },
+ {
+ input: 'http://host/wiki/Special:RecentChangesLinked/Château',
+ output: 'http://host/wiki/Special:RecentChangesLinked?target=Château',
+ message: 'Target as subpage in path with special characters'
+ },
+ {
+ input: 'http://host/wiki/Special:RecentChangesLinked/Moai/Sub1',
+ output: 'http://host/wiki/Special:RecentChangesLinked?target=Moai/Sub1',
+ message: 'Target as subpage also has a subpage'
+ },
+ {
+ input: 'http://host/wiki/Special:RecentChangesLinked/Category:Foo',
+ output: 'http://host/wiki/Special:RecentChangesLinked?target=Category:Foo',
+ message: 'Target as subpage in path (with namespace)'
+ },
+ {
+ input: 'http://host/wiki/Special:RecentChangesLinked/Category:Foo/Bar',
+ output: 'http://host/wiki/Special:RecentChangesLinked?target=Category:Foo/Bar',
+ message: 'Target as subpage in path also has a subpage (with namespace)'
+ },
+ {
+ input: 'http://host/w/index.php?title=Special:RecentChangesLinked/Moai',
+ output: 'http://host/w/index.php?title=Special:RecentChangesLinked&target=Moai',
+ message: 'Target as subpage in title param'
+ },
+ {
+ input: 'http://host/w/index.php?title=Special:RecentChangesLinked/Moai/Sub1',
+ output: 'http://host/w/index.php?title=Special:RecentChangesLinked&target=Moai/Sub1',
+ message: 'Target as subpage in title param also has a subpage'
+ },
+ {
+ input: 'http://host/w/index.php?title=Special:RecentChangesLinked/Category:Foo/Bar',
+ output: 'http://host/w/index.php?title=Special:RecentChangesLinked&target=Category:Foo/Bar',
+ message: 'Target as subpage in title param also has a subpage (with namespace)'
+ },
+ {
+ input: 'http://host/wiki/Special:Watchlist',
+ output: 'http://host/wiki/Special:Watchlist',
+ message: 'No target specified'
+ },
+ {
+ normalizeTarget: false,
+ input: 'http://host/wiki/Special:RecentChanges/Foo',
+ output: 'http://host/wiki/Special:RecentChanges/Foo',
+ message: 'Do not normalize if "normalizeTarget" is false.'
+ }
+ ];
+
+ cases.forEach( function ( testCase ) {
+ var uriProcessor = new mw.rcfilters.UriProcessor(
+ null,
{
- input: 'http://host/wiki/Special:Watchlist',
- output: 'http://host/wiki/Special:Watchlist',
- message: 'No target specified'
+ normalizeTarget: testCase.normalizeTarget === undefined ?
+ true : testCase.normalizeTarget
}
- ];
+ );
- cases.forEach( function ( testCase ) {
- assert.equal(
- uriProcessor._normalizeTargetInUri( new mw.Uri( testCase.input ) ).toString(),
+ assert.strictEqual(
+ uriProcessor._normalizeTargetInUri(
+ new mw.Uri( testCase.input )
+ ).toString(),
new mw.Uri( testCase.output ).toString(),
testCase.message
);
} );
} );
-}( mediaWiki, jQuery ) );
+}() );