mirror of
https://github.com/codedread/bitjs
synced 2025-10-04 10:09:16 +02:00
Add some unit tests for unarchivers. Provide a way to disconnect the impl from the host (for unit tests).
This commit is contained in:
parent
eba7042abe
commit
cf26e0a2de
17 changed files with 211 additions and 13 deletions
|
@ -80,7 +80,6 @@ const CompressorState = {
|
|||
FINISHED: 3,
|
||||
};
|
||||
let state = CompressorState.NOT_STARTED;
|
||||
let lastFileReceived = false;
|
||||
const crc32Table = createCRC32Table();
|
||||
|
||||
/** Helper functions. */
|
||||
|
@ -280,8 +279,21 @@ const onmessage = function(evt) {
|
|||
*/
|
||||
export function connect(port) {
|
||||
if (hostPort) {
|
||||
throw `hostPort already connected`;
|
||||
throw `hostPort already connected in zip.js`;
|
||||
}
|
||||
hostPort = port;
|
||||
port.onmessage = onmessage;
|
||||
}
|
||||
|
||||
export function disconnect() {
|
||||
if (!hostPort) {
|
||||
throw `hostPort was not connected in unzip.js`;
|
||||
}
|
||||
|
||||
hostPort = null;
|
||||
|
||||
centralDirectoryInfos = [];
|
||||
numBytesWritten = 0;
|
||||
state = CompressorState.NOT_STARTED;
|
||||
lastFileReceived = false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue