Skip to content

Commit

Permalink
PDF generation working with unique mapped IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
danielnaab committed Mar 20, 2024
1 parent 39d986e commit 99609c1
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 589 deletions.
14 changes: 12 additions & 2 deletions packages/documents/src/__tests__/doj-pardon-marijuana.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { describe, expect, it } from 'vitest';
import { loadSamplePDF } from './sample-data';
import { fillPDF, getDocumentFieldData } from '../pdf';
import { Success } from '@atj/common';
import { DocumentFieldMap } from '@atj/forms';

describe('DOJ Pardon Office marijuana pardon application form', () => {
it('produces valid PDF from imported PDF', async () => {
Expand All @@ -21,15 +22,15 @@ describe('DOJ Pardon Office marijuana pardon application form', () => {
})) as Success<Uint8Array>;
expect(result.success).toEqual(true);
const fields = await getDocumentFieldData(result.data);
expect(fields.Gender).toEqual({
expect(getFieldByName(fields, 'Gender')).toEqual({
label: 'Gender',
name: 'Gender',
maxLength: undefined,
required: false,
type: 'TextField',
value: 'female',
});
expect(fields['Docket No']).toEqual({
expect(getFieldByName(fields, 'Docket No')).toEqual({
label: 'Docket No',
name: 'Docket No',
maxLength: undefined,
Expand All @@ -39,3 +40,12 @@ describe('DOJ Pardon Office marijuana pardon application form', () => {
});
});
});

const getFieldByName = (fields: DocumentFieldMap, name: string) => {
for (const field of Object.values(fields)) {
if (field.name === name) {
return field;
}
}
throw new Error(`field with name ${name} not found`);
};
Loading

0 comments on commit 99609c1

Please sign in to comment.