Skip to content

Commit

Permalink
✅ [#4796] Added ZGW API products mock function for storybook tests
Browse files Browse the repository at this point in the history
  • Loading branch information
robinmolen committed Oct 30, 2024
1 parent 2ae68e4 commit 5bfb862
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from 'components/admin/form_design/registrations/objectsapi/mocks';
import {
mockCaseTypesGet,
mockProductsGet,
mockCataloguesGet as mockZGWApisCataloguesGet,
} from 'components/admin/form_design/registrations/zgw/mocks';
import {
Expand Down Expand Up @@ -207,7 +208,7 @@ export default {
mockObjectsApiCataloguesGet(),
mockDocumentTypesGet(),
],
zgwMocks: [mockZGWApisCataloguesGet(), mockCaseTypesGet()],
zgwMocks: [mockZGWApisCataloguesGet(), mockCaseTypesGet(), mockProductsGet()],
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from 'components/admin/form_design/story-decorators';

import ZGWFormFields from './ZGWOptionsFormFields';
import {mockCaseTypesGet, mockCataloguesGet} from './mocks';
import {mockCaseTypesGet, mockCataloguesGet, mockProductsGet} from './mocks';

const NAME = 'form.registrationBackends.0.options';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,20 @@ export const mockCaseTypesGet = () =>
const match = CASE_TYPES[catalogueUrl] ?? [];
return res(ctx.json(match));
});

const PRODUCTS = [
{
uri: 'https://example.com/product/1234',
},
{
uri: 'https://example.com/product/4321',
},
{
uri: 'https://example.com/product/1423',
},
];

export const mockProductsGet = () =>
rest.get(`${API_BASE_URL}/api/v2/registration/plugins/zgw-api/products`, (req, res, ctx) => {
return res(ctx.json(PRODUCTS));
});

0 comments on commit 5bfb862

Please sign in to comment.