smartexpose/test/test.ts

45 lines
1.4 KiB
TypeScript
Raw Permalink Normal View History

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 () => {
2024-04-24 16:14:57 +00:00
testSmartexpose = new smartexpose.SmartExpose({
webdav: {
webdavCredentials: {
serverUrl: await testQenv.getEnvVarOnDemand('WEBDAV_SERVER_URL'),
password: await testQenv.getEnvVarOnDemand('WEBDAV_SERVER_TOKEN'),
},
webdavSubPath: await testQenv.getEnvVarOnDemand('WEBDAV_SUB_PATH'),
2024-04-22 11:13:00 +00:00
},
2024-04-24 16:14:57 +00:00
deleteAfterMillis: 30000,
privateUrl: true,
exposedBaseUrl: await testQenv.getEnvVarOnDemand('EXPOSED_BASE_URL'),
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();