Create gdz file on the fly in test

This commit is contained in:
Przemek Więch
2026-05-18 23:22:00 +02:00
parent a9ac4d7513
commit 92dd39b311
3 changed files with 7 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
import {describe, expect, it} from '@jest/globals'; import {describe, expect, it} from '@jest/globals';
import {Blob} from 'buffer'; import {Blob, Buffer} from 'buffer';
import {zipSync} from 'fflate';
import {readFileSync} from 'fs'; import {readFileSync} from 'fs';
import {loadFile} from './load_data'; import {loadFile} from './load_data';
@@ -17,8 +18,11 @@ describe('loadFile', () => {
}); });
it('loads GEDZIP file', async () => { it('loads GEDZIP file', async () => {
const file = readFileSync('src/datasource/testdata/test.gdz'); const file = zipSync({
const blob = new Blob([file]) as globalThis.Blob; 'test.ged': readFileSync('src/datasource/testdata/test.ged'),
'topola.jpg': readFileSync('src/datasource/testdata/topola.jpg'),
});
const blob = new Blob([Buffer.from(file)]) as globalThis.Blob;
const {gedcom, images} = await loadFile(blob); const {gedcom, images} = await loadFile(blob);
expect(gedcom.length).toBe(4408); expect(gedcom.length).toBe(4408);
expect(images.size).toBe(1); expect(images.size).toBe(1);

Binary file not shown.

BIN
src/datasource/testdata/topola.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB