-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from ajaxorg/feature/filelist
Feature/filelist
- Loading branch information
Showing
3 changed files
with
93 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,55 @@ | ||
/* | ||
* @package jsDAV | ||
* @subpackage DAV | ||
* @copyright Copyright(c) 2011 Ajax.org B.V. <info AT ajax.org> | ||
* @author Ruben Daniels <ruben AT c9 DOT io> | ||
* @license http://github.com/mikedeboer/jsDAV/blob/master/LICENSE MIT License | ||
*/ | ||
"use strict"; | ||
|
||
var Http = require("http"); | ||
var Async = require("./../node_modules/asyncjs"); | ||
var assert = require("assert"); | ||
var jsDAV = require("./../lib/jsdav"); | ||
var jsDAV_Filelist_Plugin = require("./../lib/DAV/plugins/filelist"); | ||
|
||
var options = { | ||
host: "localhost", | ||
port: 8000, | ||
method: "REPORT", | ||
path: "/" | ||
}; | ||
jsDAV.debugMode = true; | ||
|
||
Async.range(1, 1000) | ||
.each(function(num) { | ||
var req = Http.request(options, function(res) { | ||
if (res.statusCode != 207) | ||
return next("Invalid status code! " + res.statusCode); | ||
|
||
console.log("[" + num + "] status: " + res.statusCode); | ||
//console.log("[" + num + "] headers: " + JSON.stringify(res.headers)); | ||
res.setEncoding("utf8"); | ||
res.on("data", function(chunk) { | ||
console.log("[" + num + "] body: " + chunk); | ||
}); | ||
|
||
res.on("end", function() { | ||
//next(); | ||
}); | ||
module.exports = { | ||
timeout: 30000, | ||
|
||
setUpSuite: function(next) { | ||
this.plugin = new jsDAV_Filelist_Plugin({ | ||
addEventListener : function(){} | ||
}); | ||
next(); | ||
}, | ||
|
||
tearDownSuite: function(next) { | ||
|
||
req.on("error", function(e) { | ||
console.log("problem with request: " + e.message); | ||
next(); | ||
}, | ||
|
||
"test retrieving a file list": function(next) { | ||
this.plugin.doFilelist({path: "./"}, {}, function(err, out){ | ||
assert.ok(out.indexOf("test_filelist.js") > -1); | ||
|
||
next(); | ||
}); | ||
|
||
// write data to request body | ||
req.write('<?xml version="1.0" encoding="utf-8" ?>\n'); | ||
req.write('<D:filelist xmlns:D="DAV:"></D:filelist>'); | ||
req.end(); | ||
}) | ||
.end(function(err) { | ||
console.log("DONE"); | ||
}); | ||
}, | ||
|
||
"test retrieving a file list including hidden files": function(next) { | ||
this.plugin.doFilelist({path: "../"}, { | ||
showHiddenFiles: "1" | ||
}, function(err, out){ | ||
assert.ok(out.indexOf(".gitignore") > -1); | ||
|
||
next(); | ||
}); | ||
} | ||
}; | ||
|
||
process.on("exit", function() { | ||
if (module.exports.conn) | ||
module.exports.conn.end(); | ||
}); | ||
|
||
!module.parent && require("./../node_modules/asyncjs/lib/test").testcase(module.exports).exec(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters