generated from napi-rs/package-template
/
index.spec.ts
33 lines (26 loc) · 1.22 KB
/
index.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import test from 'ava'
import { compressSync, compress, uncompressSync, uncompress } from '../index'
test('should be able to compress Buffer', (t) => {
const fixture = 'hello world'
t.deepEqual(compressSync(fixture), Buffer.from([11, 40, 104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]))
})
test('compress should be async version of compressSync', async (t) => {
const fixture = 'hello world 😂 🎧 🚀'
t.deepEqual(await compress(fixture), compressSync(fixture))
})
test('should be able to uncompress sync', (t) => {
const fixture = 'hello world 😂 🎧 🚀'
t.deepEqual(uncompressSync(compressSync(fixture)), Buffer.from(fixture))
})
test('should be able to uncompress sync into string', (t) => {
const fixture = 'hello world 😂 🎧 🚀'
t.deepEqual(uncompressSync(compressSync(fixture), { asBuffer: false }), fixture)
})
test('should be able to uncompress', async (t) => {
const fixture = 'hello world 😂 🎧 🚀'
t.deepEqual(await uncompress(await compress(fixture)), Buffer.from(fixture))
})
test('should be able to uncompress into string', async (t) => {
const fixture = 'hello world 😂 🎧 🚀'
t.deepEqual(await uncompress(await compress(fixture), { asBuffer: false }), fixture)
})