smartwebdav/test/test.ts
2024-04-20 21:24:55 +02:00

37 lines
1.3 KiB
TypeScript

import { expect, expectAsync, tap } from '@push.rocks/tapbundle';
import * as smartwebdav from '../ts/index.js'
import * as smartfile from '@push.rocks/smartfile';
import * as qenv from '@push.rocks/qenv';
const testQenv = new qenv.Qenv('./', './.nogit/');
let webdavClient: smartwebdav.WebdavClient;
tap.test('should', async () => {
webdavClient = new smartwebdav.WebdavClient({
serverUrl: await testQenv.getEnvVarOnDemand('SERVER_URL'),
authType: smartwebdav.authType.Password,
password: await testQenv.getEnvVarOnDemand('SERVER_TOKEN'),
});
const directoryListed = await webdavClient.listDirectory('/testdir');
console.log(directoryListed);
});
tap.test('should upload smartfiles', async () => {
const smartfile1 = await smartfile.SmartFile.fromString('./testdir/so/awesome/hello.txt', 'hello there', 'utf8');
const smartfile2 = await smartfile.SmartFile.fromString('./testdir/so/awesome/hello2.txt', 'hello there 2', 'utf8');
await webdavClient.uploadSmartFileArray([smartfile1, smartfile2]);
});
tap.test('should ensure directory', async () => {
await webdavClient.ensureDirectory('/testdir/another/dirctory');
})
tap.test('should delete a directory', async () => {
await webdavClient.deleteDirectory('/testdir/another');
})
export default tap.start()