0-valid.ts 827 B

12345678910111213141516171819202122
  1. import { testSuites, workers, bClone } from './util';
  2. import * as assert from 'uvu/assert';
  3. // Name is to ensure that this runs first
  4. // Note that workers are not used here to optimize performance but rather
  5. // to prevent infinite loops from hanging the process.
  6. testSuites({
  7. async compression(file) {
  8. const fileClone = bClone(file);
  9. const cProm = workers.fflate.deflate(fileClone, [fileClone.buffer]);
  10. cProm.timeout(10000);
  11. const buf = await cProm;
  12. assert.ok(file.equals(await workers.zlib.inflate(buf, [buf.buffer])));
  13. },
  14. async decompression(file) {
  15. const fileClone = bClone(file);
  16. const data = await workers.zlib.deflate(fileClone, [fileClone.buffer]);
  17. const dProm = workers.fflate.inflate(data, [data.buffer]);
  18. dProm.timeout(5000);
  19. assert.ok(file.equals(await dProm));
  20. }
  21. });