mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Thanks
synced 2024-11-14 18:44:51 +00:00
Merge "Use mw.cookie instead of $.cookie"
This commit is contained in:
commit
850fb00009
|
@ -81,7 +81,7 @@
|
|||
"ext.thanks.thank.js"
|
||||
],
|
||||
"dependencies": [
|
||||
"jquery.cookie",
|
||||
"mediawiki.cookie",
|
||||
"mediawiki.api"
|
||||
]
|
||||
},
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
attrName: 'data-revision-id',
|
||||
|
||||
load: function () {
|
||||
var cookie = $.cookie( this.cookieName );
|
||||
var cookie = mw.cookie.get( this.cookieName );
|
||||
if ( cookie === null ) {
|
||||
return [];
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
|||
if ( saved.length > this.maxHistory ) { // prevent forever growing
|
||||
saved = saved.slice( saved.length - this.maxHistory );
|
||||
}
|
||||
$.cookie( this.cookieName, escape( saved.join( ',' ) ) );
|
||||
mw.cookie.set( this.cookieName, escape( saved.join( ',' ) ) );
|
||||
},
|
||||
|
||||
contains: function ( $thankLink ) {
|
||||
|
|
|
@ -8,13 +8,13 @@ QUnit.module( 'Thanks thank', QUnit.newMwEnvironment( {
|
|||
QUnit.test( 'thanked cookie', function ( assert ) {
|
||||
var $thankLink = $( '<a ' + mw.thanks.thanked.attrName + '="8" />' ),
|
||||
$thankLinkNonExisting = $( '<a ' + mw.thanks.thanked.attrName + '="13" />' );
|
||||
$.cookie( mw.thanks.thanked.cookieName, escape( '17,11' ) );
|
||||
mw.cookie.set( mw.thanks.thanked.cookieName, escape( '17,11' ) );
|
||||
|
||||
assert.deepEqual( mw.thanks.thanked.load(), [ '17', '11' ], 'gets cookie with two values' );
|
||||
|
||||
// Makes the 0 100th element
|
||||
// eslint-disable-next-line no-restricted-properties
|
||||
$.cookie( mw.thanks.thanked.cookieName, escape( '9,'.repeat( mw.thanks.thanked.maxHistory - 1 ) + '0' ) );
|
||||
mw.cookie.set( mw.thanks.thanked.cookieName, escape( '9,'.repeat( mw.thanks.thanked.maxHistory - 1 ) + '0' ) );
|
||||
|
||||
assert.strictEqual( mw.thanks.thanked.load()[ mw.thanks.thanked.maxHistory - 1 ], '0', 'loads ' + mw.thanks.thanked.maxHistory + ' ids from a cookie' );
|
||||
mw.thanks.thanked.push( $thankLink );
|
||||
|
|
Loading…
Reference in a new issue