Files
DefinitelyTyped/types/libarchive.js/libarchive.js-tests.ts
Niklas Mollenhauer 42cd6927ee 🤖 Merge PR #59207 Fix return type of Archive#open by @nikeee
* Fix return type of Archive#open

`Archive.open(f, o)` calls `new Archive(f, o)` and returns `archive.open()`, which returns a `Promise<Archive>`.
So this method is actually synchronous.

Refs:
https://github.com/nika-begiashvili/libarchivejs#readme

d2c4d676e5/src/libarchive.js (L24-L30)

* Adjust test for `Archive#open`

Adjust tests to assert return type to be `Promise<Archive>`.
2022-03-20 09:38:52 -07:00

39 lines
1002 B
TypeScript

import { Archive } from 'libarchive.js/main';
let testFile: File = new File([""], "filename");
const testArchive = new Archive(testFile, { workerUrl: 'test'});
Archive.init({ workerUrl: 'test' });
Archive.open(testFile).then(e => void e);
Archive.open(testFile, { workerUrl: 'test' }).then(e => void e);
const FilesObject1: { [key: string]: any } = {
test2: testFile
};
let FilesObject2: { [key: string]: any } = {
test2: FilesObject1
};
let testArray: Array<{ file: any, path: string }> = [];
testArchive.hasEncryptedData().then((res) => {
console.log(res);
});
testArchive.usePassword('qwe').then(() => {});
testArchive.getFilesObject().then((res) => {
FilesObject2 = res;
});
testArchive.getFilesArray().then((res) => {
testArray = res;
});
testArchive.extractFiles((entry) => {
testArray.push(entry);
}).then(() => {});
testArchive.extractFiles().then((res) => {
FilesObject2 = res;
});
testArchive.extractSingleFile('qwe').then((res) => {
testFile = res;
});