summaryrefslogtreecommitdiff
path: root/test/0-valid.ts
blob: 99516b44c69113c963bd02e28a09e902a1ab11ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { testSuites, workers, bClone } from './util';
import * as assert from 'uvu/assert';

// Name is to ensure that this runs first
// Note that workers are not used here to optimize performance but rather
// to prevent infinite loops from hanging the process.
testSuites({
  async compression(file) {
    const fileClone = bClone(file);
    const cProm = workers.fflate.deflate(fileClone, [fileClone.buffer]);
    cProm.timeout(10000);
    const buf = await cProm;
    assert.ok(file.equals(await workers.zlib.inflate(buf, [buf.buffer])));
  },
  async decompression(file) {
    const fileClone = bClone(file);
    const data = await workers.zlib.deflate(fileClone, [fileClone.buffer]);
    const dProm = workers.fflate.inflate(data, [data.buffer]);
    dProm.timeout(5000);
    assert.ok(file.equals(await dProm));
  }
});