Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remote schema support for json form #102

Merged
merged 11 commits into from
Sep 23, 2024
21 changes: 20 additions & 1 deletion documentation/docs/mock-apps/components/json-form.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import Disclaimer from '../.././\_disclaimer.mdx';

The JsonForm component renders a dynamic form based on a provided JSON schema. It allows for flexible form creation and data entry, supporting various field types and structures defined in the schema. The component can be initialised with default data and customised with CSS classes and styles. It also supports advanced features like data construction rules and external schema references, making it suitable for complex form scenarios.

As a developer using the mock app system, you can now provide a remote schema URI to the JsonForm component or manually specify a local schema. This allows for the dynamic rendering of forms based on externally hosted schemas or custom local schemas, making the system more flexible and adaptable.

## Definitions

| Property | Required | Description | Type |
Expand All @@ -23,14 +25,16 @@ The JsonForm component renders a dynamic form based on a provided JSON schema. I

| Property | Required | Description | Type |
|----------|----------|-------------|------|
| schema | Yes | The JSON schema that defines the structure of the form | Object or `{ url: string }` |
| schema | Yes | The JSON schema that defines the structure of the form. It can either be a local object or an object with a URL property pointing to an external schema. | Object or `{ url: string }` |
| constructData | No | Defines the schema for constructing event data, including field mappings, default values, and data generation rules. | [ConstructData](/docs/mock-apps/common/construct-data) |
| data | No | The initial data for the form | Object |
| className | No | CSS class name for styling the form | String |
| style | No | CSS styles to apply to the form | Object |

## Example

### Manual schema input:

```json
{
"name": "JsonForm",
Expand Down Expand Up @@ -438,3 +442,18 @@ The JsonForm component renders a dynamic form based on a provided JSON schema. I
}
}
```

### Remote schema URL

```json
{
"name": "JsonForm",
"type": "EntryData",
"props": {
"schema": {
"url": "https://jargon.sh/user/unece/DigitalProductPassport/v/0.0.1/artefacts/jsonSchemas/render.json?class=ProductPassport"
}
}
...
}
```
77 changes: 65 additions & 12 deletions jest.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { defaults } from 'jest-config';
import ComponentPkg from './packages/components/package.json' assert { type: 'json' };
import MockAppPkg from './packages/mock-app/package.json' assert { type: 'json' };

export default {
rootDir: './',
Expand All @@ -10,25 +12,76 @@ export default {
'!**/types/**',
'!**/build/**',
'!**/node_modules/**',
'!packages/services/src/identityProviders/GS1Provider.ts' // This file call a function that is not exported
],
coverageReporters: ['text', 'lcov', 'json'],
coverageProvider: 'v8',
coverageDirectory: './coverage',
extensionsToTreatAsEsm: ['.ts'],
testMatch: ['**/__tests__/**/*.test.*'],
testPathIgnorePatterns: ['<rootDir>/node_modules/'],
testPathIgnorePatterns: [
'<rootDir>/node_modules/',
],
testEnvironment: 'node',
automock: false,
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
transform: {
'^.+\\.m?tsx?$': [
'ts-jest',
{
useESM: true,
tsconfig: './packages/tsconfig.settings.json',
extensionsToTreatAsEsm: ['.ts'],
projects: [
{
preset: 'ts-jest',
testEnvironment: 'jsdom',
setupFilesAfterEnv: ['<rootDir>/packages/components/src/setupTests.ts'],
displayName: ComponentPkg.name,
testMatch: ['<rootDir>/packages/components/**/?(*.)+(spec|test).[jt]s?(x)'],
transform: {
'^.+\\.m?tsx?$': [
'ts-jest',
{
useESM: true,
tsconfig: '<rootDir>/packages/components/tsconfig.json',
},
],
},
],
},
},
{
preset: 'ts-jest',
testEnvironment: 'jsdom',
setupFilesAfterEnv: ['<rootDir>/packages/mock-app/jest.config.js'],
displayName: MockAppPkg.name,
testMatch: ['<rootDir>/packages/mock-app/jest.config.js'],
transform: {
'^.+\\.m?tsx?$': [
'ts-jest',
{
useESM: true,
tsconfig: '<rootDir>/packages/mock-app/tsconfig.json',
},
],
},
},
{
// Default Node.js environment tests for all other packages
preset: 'ts-jest',
displayName: 'Node.js environment',
testEnvironment: 'node',
testMatch: ['<rootDir>/packages/**/src/**/?(*.)+(spec|test).[jt]s?(x)'],
testPathIgnorePatterns: [
'<rootDir>/node_modules/',
'<rootDir>/packages/components',
'<rootDir>/packages/mock-app',
'<rootDir>/packages/services/src/__tests__/gs1.test.ts' // This file call a library that is not exported, so it is ignored
],
transform: {
'^.+\\.m?tsx?$': [
'ts-jest',
{
useESM: true,
tsconfig: '<rootDir>/packages/tsconfig.settings.json',
},
],
},
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
}
},
],
};
1 change: 1 addition & 0 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"ajv": "^8.16.0",
"ajv-errors": "^3.0.0",
"ajv-formats": "^3.0.1",
"jest-fetch-mock": "^3.0.3",
"jsonpointer": "^5.0.1",
"react": "18.2.0",
"react-barcode": "^1.5.3",
Expand Down
48 changes: 47 additions & 1 deletion packages/components/src/__tests__/JsonForm.test.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import React from 'react';
import { fireEvent, render, screen } from '@testing-library/react';
import { fireEvent, render, screen, act } from '@testing-library/react';
import fetchMock from 'jest-fetch-mock';
import { JsonForms } from '@jsonforms/react';

import { schema, initialData, uiSchema } from './mocks/JsonForm.mock';
import { JsonForm } from '../components/JsonForm/JsonForm';

// Enable fetch mocks
fetchMock.enableMocks();

describe('render json schema component', () => {
beforeEach(() => {
/*
Expand Down Expand Up @@ -100,4 +104,46 @@ describe('render json schema component', () => {
fireEvent.click(button);
expect(onChange).toHaveBeenCalledWith({ data: { name: 'Dwight D. Terry' }, errors: [] });
});

it('should fetch and render schema from url', async () => {
const schemaUrl = 'https://example.io/schema.json';
// Mock the fetch response
fetchMock.mockResponseOnce(JSON.stringify(schema));

// Wrap the rendering inside act(...)
await act(async () => {
render(
<JsonForm
schema={{ url: schemaUrl }}
data={initialData}
onChange={onChangeJsonSchemaForm}
className='json-form'
/>,
);
});

expect(fetch).toHaveBeenCalledTimes(1);
expect(fetch).toHaveBeenCalledWith(schemaUrl);

const getStringField = screen.getByLabelText('Name');
expect(getStringField).toHaveValue(initialData.name);

const getBooleanField = screen.getByLabelText('Vegetarian');
expect(getBooleanField).toBeChecked();
});

it('should show error message when fetch schema failed', async () => {
const schemaUrl = 'https://example.io/schema.json';
fetchMock.mockReject(new Error('Failed to fetch schema'));

await act(async () => {
render(<JsonForm schema={{ url: schemaUrl }} onChange={onChangeJsonSchemaForm} className='json-form' />);
});

expect(fetch).toHaveBeenCalledTimes(1);
expect(fetch).toHaveBeenCalledWith(schemaUrl);

const errorElement = screen.getByText('Error setup schema');
expect(errorElement).toBeInTheDocument();
});
});
7 changes: 6 additions & 1 deletion packages/services/src/__tests__/aggregationEvent.test.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
import * as vckitService from '../vckit.service';
import { getStorageServiceLink } from '../storage.service';
import * as linkResolverService from '../linkResolver.service';
import { IAggregationEventContext } from '../epcisEvents/types';
import { Result } from '../types/validateContext';
import * as validateContext from '../epcisEvents/validateContext';
import * as helpers from '../epcisEvents/helpers';
import { processAggregationEvent } from '../epcisEvents';
import { publicAPI } from '../utils/httpService';
import { aggregationEventMock } from './mocks/constants';

jest.mock('../vckit.service', () => ({
issueVC: jest.fn(),
}));
jest.mock('../storage.service', () => ({
getStorageServiceLink: jest.fn(),
}));
jest.mock('../linkResolver.service', () => ({
registerLinkResolver: jest.fn(),
createLinkResolver: jest.fn(),
IdentificationKeyType: jest.fn(),
getLinkResolverIdentifier: jest.fn(),
LinkType: {

Check warning on line 23 in packages/services/src/__tests__/aggregationEvent.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
verificationLinkType : 'gs1:verificationService',

Check warning on line 24 in packages/services/src/__tests__/aggregationEvent.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
certificationLinkType : 'gs1:certificationInfo',

Check warning on line 25 in packages/services/src/__tests__/aggregationEvent.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
epcisLinkType : 'gs1:epcis',

Check warning on line 26 in packages/services/src/__tests__/aggregationEvent.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

Check warning on line 27 in packages/services/src/__tests__/aggregationEvent.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}));

describe('processAggregationEvent', () => {
Expand Down Expand Up @@ -88,7 +93,7 @@
try {
const invalidIdentifierContent = {
...context,
identifierKeyPath: 'invalid',
identifierKeyPath: '/invalid',

Check warning on line 96 in packages/services/src/__tests__/aggregationEvent.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
};
jest
.spyOn(validateContext, 'validateAggregationEventContext')
Expand Down
6 changes: 5 additions & 1 deletion packages/services/src/__tests__/gs1.test.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
import { GS1Provider, GS1ServiceEnum } from '../identityProviders/GS1Provider';
import { publicAPI } from '../utils/httpService';

jest.mock('../types/types', () => ({
SupportedProviderTypesEnum: {
gs1: 'gs1',
},
}));

describe('Gs1Provider', () => {
const gtinAI = 'gtin';
const mockCode = '0109359502000010';
const providerUrl = 'https://example.com';

let gs1Provider: GS1Provider;

beforeEach(() => {
// Set up a new instance of GS1Provider with the specified provider type and URL
gs1Provider = new GS1Provider();
});

describe('getDlrUrl', () => {
it('should return null if code is not set', async () => {
const dlrUrl = await gs1Provider.getDlrUrl('', providerUrl);
const code = '';

Check warning on line 24 in packages/services/src/__tests__/gs1.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
jest.spyOn(publicAPI, 'post').mockResolvedValueOnce([]);

Check warning on line 25 in packages/services/src/__tests__/gs1.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
// Act

Check warning on line 26 in packages/services/src/__tests__/gs1.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
const dlrUrl = await gs1Provider.getDlrUrl(code, providerUrl);

Check warning on line 27 in packages/services/src/__tests__/gs1.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

// Assert

Check warning on line 29 in packages/services/src/__tests__/gs1.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
expect(dlrUrl).toBeNull();
});

Expand Down
18 changes: 18 additions & 0 deletions packages/services/src/__tests__/mocks/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
export const contextTransformationEvent = {
transformationEventCredential: {
mappingFields: [
{
"sourcePath": "/",
"destinationPath": "/"
}
]
},
dppCredentials: [
{
"mappingFields": [
{
"sourcePath": "/",
"destinationPath": "/"
}
]
}
],
epcisTransformationEvent: {
context: ['https://dpp-json-ld.s3.ap-southeast-2.amazonaws.com/transformation-event-ld.json'],
renderTemplate: [{ template: '<p>Render epcis template</p>', '@type': 'WebRenderingTemplate2022' }],
Expand Down
19 changes: 15 additions & 4 deletions packages/services/src/__tests__/processDPP.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { processDPP } from '../processDPP.service';
import { issueVC, contextDefault } from '../vckit.service';
import { getStorageServiceLink } from '../storage.service';
import { registerLinkResolver, IdentificationKeyType } from '../linkResolver.service';
import { registerLinkResolver, IdentificationKeyType, LinkType } from '../linkResolver.service';

Check warning on line 4 in packages/services/src/__tests__/processDPP.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
import { contextDPP, dataDPP } from './mocks/constants';

jest.mock('../vckit.service', () => ({
Expand All @@ -20,8 +20,14 @@
nlisid: 'nlisid',
},
getLinkResolverIdentifier: jest.fn(() => ({ identifier: '9359502000010', qualifierPath: '/10/ABC123' })),
LinkType: {

Check warning on line 23 in packages/services/src/__tests__/processDPP.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
verificationLinkType: 'gs1:verificationService',

Check warning on line 24 in packages/services/src/__tests__/processDPP.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
certificationLinkType: 'gs1:certificationInfo',

Check warning on line 25 in packages/services/src/__tests__/processDPP.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
epcisLinkType: 'gs1:epcis',

Check warning on line 26 in packages/services/src/__tests__/processDPP.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

Check warning on line 27 in packages/services/src/__tests__/processDPP.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}));


Check warning on line 30 in packages/services/src/__tests__/processDPP.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
describe('processDPP', () => {
describe('successful case', () => {
afterEach(() => {
Expand Down Expand Up @@ -51,7 +57,7 @@

it('should call process DPP', async () => {
(getStorageServiceLink as jest.Mock).mockImplementation(({ url, _data, path }) => {
return `${url}/${path}`;
return `${url}/${dataDPP.data.herd.identifier}`;

Check warning on line 60 in packages/services/src/__tests__/processDPP.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
});

(registerLinkResolver as jest.Mock).mockImplementation(
Expand All @@ -69,14 +75,17 @@
linkTitle,
verificationPage,
dlrAPIKey,
identificationKey,
identificationKey

Check warning on line 78 in packages/services/src/__tests__/processDPP.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
});
return `${dlrAPIUrl}/${identificationKeyType}/${identificationKey}?linkType=all`;
},
);

const vc = await processDPP(dataDPP, contextDPP);
expect(vc).toEqual(expectVCResult);
expect(vc).toEqual({

Check warning on line 85 in packages/services/src/__tests__/processDPP.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
vc: expectVCResult,

Check warning on line 86 in packages/services/src/__tests__/processDPP.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
linkResolver: contextDPP.dpp.dlrVerificationPage + '/' + contextDPP.dpp.dlrIdentificationKeyType + '/' + dataDPP.data.herd.identifier + '?linkType=all',

Check warning on line 87 in packages/services/src/__tests__/processDPP.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
});

Check warning on line 88 in packages/services/src/__tests__/processDPP.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
expect(getStorageServiceLink).toHaveBeenCalled();
expect(registerLinkResolver).toHaveBeenCalled();

Expand All @@ -87,10 +96,12 @@
dppContext.dlrIdentificationKeyType,
dataDPP.data.herd.identifier,
dppContext.dlrLinkTitle,
LinkType.certificationLinkType,

Check warning on line 99 in packages/services/src/__tests__/processDPP.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
dppContext.dlrVerificationPage,
dlrContext.dlrAPIUrl,
dlrContext.dlrAPIKey,
dataDPP.qualifierPath,
LinkType.certificationLinkType,

Check warning on line 104 in packages/services/src/__tests__/processDPP.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
);
});
});
Expand Down
20 changes: 17 additions & 3 deletions packages/services/src/__tests__/transactionEvent.test.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
import * as vckitService from '../vckit.service';
import * as linkResolverService from '../linkResolver.service';
import * as helpers from '../epcisEvents/helpers';
import * as validateContext from '../epcisEvents/validateContext';
import { processTransactionEvent } from '../epcisEvents/transactionEvent';
import { getStorageServiceLink } from '../storage.service';
import { Result } from '../types/validateContext';
import { ITransactionEventContext } from '../epcisEvents/types';
import { publicAPI } from '../utils/httpService';
import { transactionEventMock } from './mocks/constants';

jest.mock('../vckit.service', () => ({
issueVC: jest.fn(),
}));
jest.mock('../storage.service', () => ({
getStorageServiceLink: jest.fn(),
}));
jest.mock('../linkResolver.service', () => ({
registerLinkResolver: jest.fn(),
createLinkResolver: jest.fn(),
IdentificationKeyType: jest.fn(),
getLinkResolverIdentifier: jest.fn(() => ({ identifier: '9359502000010', qualifierPath: '/10/ABC123' })),
LinkType: {

Check warning on line 23 in packages/services/src/__tests__/transactionEvent.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
verificationLinkType : 'gs1:verificationService',

Check warning on line 24 in packages/services/src/__tests__/transactionEvent.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
certificationLinkType : 'gs1:certificationInfo',

Check warning on line 25 in packages/services/src/__tests__/transactionEvent.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
epcisLinkType : 'gs1:epcis',

Check warning on line 26 in packages/services/src/__tests__/transactionEvent.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

Check warning on line 27 in packages/services/src/__tests__/transactionEvent.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}));

jest.mock('../epcisEvents/helpers', () => ({

Check warning on line 30 in packages/services/src/__tests__/transactionEvent.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
deleteValuesFromLocalStorageByKeyPath: jest.fn(),

Check warning on line 31 in packages/services/src/__tests__/transactionEvent.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}));

Check warning on line 32 in packages/services/src/__tests__/transactionEvent.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 33 in packages/services/src/__tests__/transactionEvent.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 34 in packages/services/src/__tests__/transactionEvent.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
describe('processTransactionEvent', () => {
const { nlisidMock, transactionEventDLRMock, transactionVCMock } = transactionEventMock;
const transactionEvent = {
Expand Down Expand Up @@ -54,6 +64,7 @@
},
},
identifierKeyPath: '/transaction/identifier',
localStorageParams: { "storageKey": "transaction", "keyPath": "/transaction/type" }

Check warning on line 67 in packages/services/src/__tests__/transactionEvent.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
};

it('should process transaction event', async () => {
Expand All @@ -67,8 +78,11 @@
jest.spyOn(linkResolverService, 'registerLinkResolver').mockResolvedValueOnce(transactionEventDLRMock);

const transactionVC = await processTransactionEvent(transactionEvent, context);

expect(transactionVC).toBe(transactionVCMock);

Check warning on line 81 in packages/services/src/__tests__/transactionEvent.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
expect(transactionVC).toEqual({

Check warning on line 82 in packages/services/src/__tests__/transactionEvent.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
vc: transactionVCMock,

Check warning on line 83 in packages/services/src/__tests__/transactionEvent.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
linkResolver: transactionEventDLRMock,

Check warning on line 84 in packages/services/src/__tests__/transactionEvent.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
});

Check warning on line 85 in packages/services/src/__tests__/transactionEvent.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
expect(getStorageServiceLink).toHaveBeenCalled();
expect(validateContext.validateTransactionEventContext).toHaveBeenCalled();
expect(linkResolverService.registerLinkResolver).toHaveBeenCalled();
Expand All @@ -95,7 +109,7 @@
try {
const invalidIdentifierContext = {
...context,
identifierKeyPath: 'invalid-key',
identifierKeyPath: '/invalid-key',

Check warning on line 112 in packages/services/src/__tests__/transactionEvent.test.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (πŸ§ͺ jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
};
jest
.spyOn(validateContext, 'validateTransactionEventContext')
Expand Down
Loading
Loading