1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-20 14:54:15 +01:00

(test) test AccountingCodesSettings

This commit is contained in:
Sylvain 2022-11-28 17:39:37 +01:00
parent 84dfcf38c7
commit 9d2dde8257
2 changed files with 22 additions and 0 deletions

View File

@ -37,6 +37,9 @@ export const server = setupServer(
const { names } = req.params;
const foundSettings = settings.filter(name => names.replace(/[[\]']/g, '').split(',').includes(name));
return res(ctx.json(foundSettings));
}),
rest.patch('/api/settings/bulk_update', (req, res, ctx) => {
return res(ctx.json(req.body));
})
);

View File

@ -0,0 +1,19 @@
import React from 'react';
import { AccountingCodesSettings } from 'components/accounting/accounting-codes-settings';
import { render, fireEvent, waitFor, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
describe('AccountingCodesSettings', () => {
const onSuccess = jest.fn(message => {});
const onError = jest.fn(e => {});
test('render AccountingCodesSettings', async () => {
render(<AccountingCodesSettings onError={onError} onSuccess={onSuccess} />);
await waitFor(() => screen.getByRole('heading', { name: /app.admin.accounting_codes_settings.advanced_accounting/ }));
expect(screen.getByLabelText(/app.admin.accounting_codes_settings.enable_advanced/)).toBeInTheDocument();
expect(screen.getByLabelText(/app.admin.accounting_codes_settings.journal_code/)).toBeInTheDocument();
expect(screen.getAllByLabelText(/app.admin.accounting_codes_settings.code/)).toHaveLength(13);
expect(screen.getAllByLabelText(/app.admin.accounting_codes_settings.label/)).toHaveLength(13);
expect(screen.getByRole('button', { name: /app.admin.accounting_codes_settings.save/ })).toBeInTheDocument();
});
});