Skip to content

Commit c99798a

Browse files
Merge pull request #123 from CIRFMF/release/1.1.16-HF1
release/1.1.16-HF1
2 parents 456dcb2 + 5e4ca42 commit c99798a

5 files changed

Lines changed: 9 additions & 30 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@akmf/ksef-fe-invoice-converter",
3-
"version": "1.1.16",
3+
"version": "1.1.16-HF1",
44
"scripts": {
55
"dev": "vite --mode public --config vite.config.ts",
66
"build": "vite build --mode production",

src/lib-public/UPO-4_2-generators.spec.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,15 @@ describe('generatePDFUPO', () => {
1111
field2: 'value2',
1212
},
1313
};
14+
const mockBlob = new Blob(['pdf content'], { type: 'application/pdf' });
1415

1516
beforeEach(() => {
1617
vi.spyOn(XMLParser, 'parseXML').mockResolvedValue(dummyUpo);
1718

1819
vi.spyOn(pdfMake, 'createPdf').mockImplementation(
1920
() =>
2021
({
21-
getBlob: (callback: (blob: Blob | null) => void) => {
22-
const blob = new Blob(['PDF content'], { type: 'application/pdf' });
23-
24-
callback(blob);
25-
},
22+
getBlob: vi.fn(() => Promise.resolve(mockBlob)),
2623
}) as any
2724
);
2825
});
@@ -43,17 +40,7 @@ describe('generatePDFUPO', () => {
4340
reader.readAsText(blob);
4441
});
4542

46-
expect(text).toContain('PDF content');
47-
});
48-
49-
it('rejects promise if pdfMake returns null blob', async () => {
50-
vi.spyOn(pdfMake, 'createPdf').mockReturnValue({
51-
getBlob: (callback: (blob: Blob | null) => void) => {
52-
callback(null);
53-
},
54-
} as any);
55-
56-
await expect(generatePDFUPO(dummyFile)).rejects.toEqual('Error');
43+
expect(text).toContain('pdf content');
5744
});
5845

5946
it('calls parseXML with the input file', async () => {

src/lib-public/UPO-4_2-generators.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { generateStyle } from '../shared/PDF-functions';
55
import { generateNaglowekUPO } from './generators/UPO4_2/Naglowek';
66
import { parseXML } from '../shared/XML-parser';
77
import { Position } from '../shared/enums/common.enum';
8-
import { generateDokumentUPO } from './generators/UPO4_3/Dokumenty';
8+
import { generateDokumentUPO } from './generators/UPO4_2/Dokumenty';
99

1010
export async function generatePDFUPO(file: File): Promise<Blob> {
1111
const upo = (await parseXML(file)) as Upo;
@@ -23,13 +23,5 @@ export async function generatePDFUPO(file: File): Promise<Blob> {
2323
},
2424
};
2525

26-
return new Promise((resolve, reject): void => {
27-
pdfMake.createPdf(docDefinition).getBlob((blob: Blob): void => {
28-
if (blob) {
29-
resolve(blob);
30-
} else {
31-
reject('Error');
32-
}
33-
});
34-
});
26+
return pdfMake.createPdf(docDefinition).getBlob();
3527
}

src/shared/generators/common/functions.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,6 @@ describe('createVersionLabel', () => {
160160
.pop();
161161
expect(versionLabel).toContain('Aplikacja Podatnika KSeF');
162162
expect(versionLabel).toContain('ksef-pdf-generator');
163-
expect(version).toMatch(/^(\d+\.)?(\d+\.)?(\*|\d+)$/);
163+
expect(version).toMatch(/^\d+\.\d+\.\d+(-[A-Za-z0-9]+)?$/);
164164
});
165165
});

0 commit comments

Comments
 (0)