generated from shgysk8zer0/npm-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.test.js
More file actions
34 lines (33 loc) · 1.65 KB
/
index.test.js
File metadata and controls
34 lines (33 loc) · 1.65 KB
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
34
import { test, describe } from 'node:test';
import assert from 'node:assert';
import { createSVGBlob, createSVGFile, createGIFFile, createGIFBlob } from './index.js';
const signal = AbortSignal.timeout(300);
const input = 'https://github.com/AegisJSProject/qr-encoder';
describe('Test generating QR codes', () => {
test('Test generating SVG Blobs', { signal }, () => {
const result = createSVGBlob(input);
assert.ok(result instanceof Blob, 'Should output a `Blob`.');
assert.equal(result?.type, 'image/svg+xml', 'Should have an SVG type.');
assert.notEqual(result?.size, 0, 'Should not be empty.');
});
test('Test generating SVG Files', { signal }, () => {
const result = createSVGFile(input);
assert.ok(result instanceof File, 'Should output a `Blob`.');
assert.equal(result?.type, 'image/svg+xml', 'Should have an SVG type.');
assert.notEqual(result?.size, 0, 'Should not be empty.');
assert.ok(result?.name?.endsWith('.svg'), 'SVG files should have the `.svg` extension.');
});
test('Test generating GIF Blobs', { signal }, () => {
const result = createGIFBlob(input);
assert.ok(result instanceof Blob, 'Should output a `Blob`.');
assert.equal(result?.type, 'image/gif', 'Should have an SVG type.');
assert.notEqual(result?.size, 0, 'Should not be empty.');
});
test('Test generating GIF Files', { signal }, () => {
const result = createGIFFile(input);
assert.ok(result instanceof File, 'Should output a `Blob`.');
assert.equal(result?.type, 'image/gif', 'Should have an GIF type.');
assert.notEqual(result?.size, 0, 'Should not be empty.');
assert.ok(result?.name?.endsWith('.gif'), 'SVG files should have the `.gif` extension.');
});
});