-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for the 'addResourceTree' method
- Loading branch information
1 parent
fab8388
commit 1bf0c47
Showing
1 changed file
with
87 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
"use strict"; | ||
var webdav = require('../../lib/index.js'), | ||
Client = require('webdav-fs'); | ||
|
||
module.exports = (test, options, index) => test('addResourceTree method', isValid => | ||
{ | ||
var server = new webdav.WebDAVServer(); | ||
server.start(options.port + index); | ||
isValid = isValid.multiple(2, server); | ||
const _ = (e, cb) => { | ||
if(e) | ||
isValid(false, e); | ||
else | ||
cb(); | ||
} | ||
|
||
const url = 'http://127.0.0.1:' + (options.port + index); | ||
const wfs = Client(url); | ||
|
||
const testFolder = new webdav.VirtualFolder('test'); | ||
server.addResourceTree({ | ||
r: testFolder, | ||
c: [{ | ||
r: new webdav.VirtualFolder('test1'), | ||
c: new webdav.VirtualFile('test2') | ||
}, { | ||
r: new webdav.VirtualFolder('test2'), | ||
c: [{ | ||
r: new webdav.VirtualFolder('test1'), | ||
c: new webdav.VirtualFile('test2') | ||
},{ | ||
r: new webdav.VirtualFolder('test2'), | ||
c: new webdav.VirtualFile('test2') | ||
}] | ||
}] | ||
}, (e) => _(e, () => { | ||
wfs.stat('/test', (e, stat) => _(e, () => { | ||
wfs.stat('/test/test1', (e, stat) => _(e, () => { | ||
wfs.stat('/test/test1/test2', (e, stat) => _(e, () => { | ||
wfs.stat('/test/test2', (e, stat) => _(e, () => { | ||
wfs.stat('/test/test2/test1', (e, stat) => _(e, () => { | ||
wfs.stat('/test/test2/test1/test2', (e, stat) => _(e, () => { | ||
wfs.stat('/test/test2/test2', (e, stat) => _(e, () => { | ||
wfs.stat('/test/test2/test2/test2', (e, stat) => _(e, () => { | ||
isValid(true); | ||
})) | ||
})) | ||
})) | ||
})) | ||
})) | ||
})) | ||
})) | ||
})) | ||
})) | ||
|
||
server.addResourceTree(testFolder, [{ | ||
r: new webdav.VirtualFolder('2test1'), | ||
c: new webdav.VirtualFile('2test2') | ||
}, { | ||
r: new webdav.VirtualFolder('2test2'), | ||
c: [{ | ||
r: new webdav.VirtualFolder('2test1'), | ||
c: new webdav.VirtualFile('2test2') | ||
},{ | ||
r: new webdav.VirtualFolder('2test2'), | ||
c: new webdav.VirtualFile('2test2') | ||
}] | ||
}], (e) => _(e, () => { | ||
wfs.stat('/test', (e, stat) => _(e, () => { | ||
wfs.stat('/test/2test1', (e, stat) => _(e, () => { | ||
wfs.stat('/test/2test1/2test2', (e, stat) => _(e, () => { | ||
wfs.stat('/test/2test2', (e, stat) => _(e, () => { | ||
wfs.stat('/test/2test2/2test1', (e, stat) => _(e, () => { | ||
wfs.stat('/test/2test2/2test1/2test2', (e, stat) => _(e, () => { | ||
wfs.stat('/test/2test2/2test2', (e, stat) => _(e, () => { | ||
wfs.stat('/test/2test2/2test2/2test2', (e, stat) => _(e, () => { | ||
isValid(true); | ||
})) | ||
})) | ||
})) | ||
})) | ||
})) | ||
})) | ||
})) | ||
})) | ||
})) | ||
}) |