Skip to content

Commit

Permalink
Add args to generate mock util
Browse files Browse the repository at this point in the history
  • Loading branch information
Kunalpal216 committed Nov 8, 2024
1 parent 7766328 commit b86458a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
9 changes: 2 additions & 7 deletions scripts/__mocks__/@pdfme/generator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@ import { generate } from './generator';

describe('Testing mock generate util', () => {
test('should return a Promise', async () => {
const result = generate();
const result = generate({ template: {}, inputs: [] });
expect(result).toBeInstanceOf(Promise);
});

test('should resolve to a Uint8Array', async () => {
const result = await generate();
const result = generate({ template: {}, inputs: [] });
expect(result).toBeInstanceOf(Uint8Array);
});

test('should resolve to a Uint8Array with correct values', async () => {
const result = await generate();
expect(result).toEqual(new Uint8Array([10, 20, 30, 40, 50]));
});
});
13 changes: 11 additions & 2 deletions scripts/__mocks__/@pdfme/generator.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
export const generate = async (): Promise<Uint8Array> => {
return new Uint8Array([10, 20, 30, 40, 50]);
import type { Template } from '@pdfme/common';
import { generate as pdfmeGenerate } from '@pdfme/generator';

export const generate = async ({
template,
inputs,
}: {
template: Template;
inputs: Record<string, string>[];
}): Promise<Uint8Array> => {
return await pdfmeGenerate({ template: template, inputs });
};

0 comments on commit b86458a

Please sign in to comment.