2024-04-22 11:13:00 +00:00
|
|
|
import { expect, expectAsync, tap } from '@push.rocks/tapbundle';
|
|
|
|
import * as qenv from '@push.rocks/qenv';
|
2024-04-24 16:02:21 +00:00
|
|
|
import * as smartfile from '@push.rocks/smartfile';
|
|
|
|
|
2024-04-22 11:13:00 +00:00
|
|
|
const testQenv = new qenv.Qenv('./', './.nogit/');
|
|
|
|
|
|
|
|
import * as smartexpose from '../ts/index.js'
|
|
|
|
|
|
|
|
let testSmartexpose: smartexpose.SmartExpose;
|
|
|
|
|
|
|
|
tap.test('should create a valid instance of smartexpose using Webdav', async () => {
|
|
|
|
testSmartexpose = await smartexpose.SmartExpose.createWithWebdav({
|
|
|
|
webdavCredentials: {
|
|
|
|
serverUrl: await testQenv.getEnvVarOnDemand('WEBDAV_SERVER_URL'),
|
2024-04-24 16:02:21 +00:00
|
|
|
password: await testQenv.getEnvVarOnDemand('WEBDAV_SERVER_TOKEN'),
|
2024-04-22 11:13:00 +00:00
|
|
|
},
|
|
|
|
webdavSubPath: await testQenv.getEnvVarOnDemand('WEBDAV_SUB_PATH'),
|
|
|
|
exposeOptions: {
|
|
|
|
deleteAfterMillis: 30000,
|
|
|
|
privateUrl: true,
|
2024-04-24 16:02:21 +00:00
|
|
|
exposedBaseUrl: await testQenv.getEnvVarOnDemand('EXPOSED_BASE_URL'),
|
2024-04-22 11:13:00 +00:00
|
|
|
}
|
2024-04-24 16:02:21 +00:00
|
|
|
});
|
|
|
|
await testSmartexpose.start();
|
|
|
|
expect(testSmartexpose).toBeInstanceOf(smartexpose.SmartExpose);
|
|
|
|
});
|
|
|
|
|
|
|
|
tap.test('should expose a file', async () => {
|
|
|
|
await testSmartexpose.exposeFile({
|
|
|
|
smartFile: await smartfile.SmartFile.fromString('okidoks', 'hi there', 'utf8'),
|
|
|
|
deleteAfterMillis: 10000,
|
|
|
|
privateUrl: true,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
tap.test('should delete the file', async (toolsArg) => {
|
|
|
|
await toolsArg.delayFor(11000);
|
|
|
|
});
|
|
|
|
|
|
|
|
tap.test('should stop the smartexpose', async () => {
|
|
|
|
await testSmartexpose.stop();
|
|
|
|
})
|
2024-04-22 11:13:00 +00:00
|
|
|
|
2024-04-24 16:02:21 +00:00
|
|
|
export default tap.start();
|