Skip to content

Commit

Permalink
Added tests for the 'addResourceTree' method
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienCastex committed May 23, 2017
1 parent fab8388 commit 1bf0c47
Showing 1 changed file with 87 additions and 0 deletions.
87 changes: 87 additions & 0 deletions test/tests/addResourceTree.js
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);
}))
}))
}))
}))
}))
}))
}))
}))
}))
})

0 comments on commit 1bf0c47

Please sign in to comment.