Skip to content

Commit

Permalink
Added tests for the physical folder
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienCastex committed May 13, 2017
1 parent 3cd3934 commit 681caba
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions test/tests/makeFolder.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
var webdav = require('../../lib/index.js'),
Client = require("webdav-fs")
Client = require("webdav-fs"),
path = require('path'),
fs = require('fs')

module.exports = (test, options, index) => test('make a folder', isValid =>
{
var server = new webdav.WebDAVServer();
isValid = isValid.multiple(3, server);
isValid = isValid.multiple(4, server);
server.rootResource.addChild(new webdav.VirtualFile('testFile.txt'), e => {
if(e)
{
Expand All @@ -18,27 +20,50 @@ module.exports = (test, options, index) => test('make a folder', isValid =>
"http://127.0.0.1:" + (options.port + index)
);

wfs.mkdir('/testFile.txt/testFail', (e, content) => {
wfs.mkdir('/testFile.txt/testFail', (e) => {
isValid(!!e)
})

wfs.mkdir('/undefined/testFail', (e, content) => {
wfs.mkdir('/undefined/testFail', (e) => {
isValid(!!e)
})

wfs.mkdir('/testSuccess', (e, content) => {
wfs.mkdir('/testSuccess', (e) => {
if(e)
{
isValid(false, e)
return;
}

wfs.mkdir('/testSuccess/testSuccess2', (e, content) => {
wfs.mkdir('/testSuccess/testSuccess2', (e) => {
if(e)
isValid(false, e)
else
isValid(true);
})
})

const folderName = 'makeFolder';
const folderPath = path.join(__dirname, folderName);

const subFolderName = 'folder';
const subFolderPath = path.join(folderPath, subFolderName);
if(fs.existsSync(subFolderPath))
fs.rmdirSync(subFolderPath);

server.rootResource.addChild(new webdav.PhysicalFolder(folderPath), e => {
if(e)
{
isValid(false, e)
return;
}

wfs.mkdir('/' + folderName + '/' + subFolderName, (e) => {
if(e)
isValid(false, e)
else
isValid(fs.existsSync(subFolderPath));
})
});
});
})
Empty file added test/tests/makeFolder/.gitkeep
Empty file.

0 comments on commit 681caba

Please sign in to comment.