Skip to content

Commit 341cebb

Browse files
authored
Merge pull request #2356 from TrimmingFool/jest-tests
move httprpc response methods to js/rtorrent.js and add jest tests
2 parents 0c243db + e4c8740 commit 341cebb

19 files changed

Lines changed: 1168 additions & 590 deletions

js/rtorrent.js

Lines changed: 247 additions & 224 deletions
Large diffs are not rendered by default.

plugins/chunks/init.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,14 @@ rTorrentStub.prototype.getchunks = function()
105105
}
106106
}
107107

108-
rTorrentStub.prototype.getchunksResponse = function(xml)
108+
rTorrentStub.prototype.getchunksParseXML = function(xml)
109109
{
110110
if(plugin.hash!=theWebUI.dID)
111-
return({});
112-
var datas = xml.getElementsByTagName('data');
113-
var data = datas[0];
114-
var values = data.getElementsByTagName('value');
115-
var ret = { chunks: this.getValue(values,1), size: this.getValue(values,3), tsize: this.getValue(values,5) }
111+
return({});
112+
const values = this.getXMLValues(xml, 2, 1)[0];
113+
var ret = { chunks: values[0], size: values[1], tsize: values[2] }
116114
if(theWebUI.systemInfo.rTorrent.apiVersion>=4)
117-
ret.seen = this.getValue(values,7);
115+
ret.seen = values[3];
118116
return(ret);
119117
}
120118

@@ -164,4 +162,4 @@ plugin.onLangLoaded = function()
164162
plugin.onRemove = function()
165163
{
166164
plugin.removePageFromTabs("Chunks");
167-
}
165+
}

plugins/datadir/init.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ rTorrentStub.prototype.getsavepathResponse = function( xml )
5656
var save_path = '';
5757
if(torrent)
5858
{
59-
torrent.base_path = this.getValue( values, 3 );
59+
torrent.base_path = this.getXMLValue( values, 3 );
6060
var pos = torrent.base_path.lastIndexOf('/');
6161
torrent.save_path = (torrent.base_path.substring(pos+1) === torrent.name) ?
6262
torrent.base_path.substring(0,pos) : torrent.base_path;

0 commit comments

Comments
 (0)