Skip to content

Commit

Permalink
fix: rollback the unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
codefactor authored and i832513 committed Feb 22, 2023
1 parent 780c3d9 commit 9828188
Showing 1 changed file with 1 addition and 28 deletions.
29 changes: 1 addition & 28 deletions packages/core/test/util/cell.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,9 @@ import { UPDATE_DATA, UpdateAction } from '../../src/actions';
import configureStore from 'redux-mock-store';
import {
ControlElement,
createAjv,
defaultErrorTranslator,
JsonFormsState,
JsonSchema,
RuleEffect,
UISchemaElement,
validate
UISchemaElement
} from '../../src';
import { enumToEnumOptionMapper } from '../../src/util/renderer';

Expand Down Expand Up @@ -274,29 +270,6 @@ test('mapStateToCellProps - id', t => {
t.is(props.id, '#/properties/firstName');
});

test('mapStateToCellProps - translated error', t => {
const ownProps = {
uischema: coreUISchema,
id: '#/properties/firstName'
};
const state = createState(coreUISchema);
const schema = state.jsonforms.core?.schema as JsonSchema;
const data = state.jsonforms.core?.data as any;
// mark firstName as required, delete the value from data, then get errors from ajv from the compiled schema
schema.required = ["firstName"];
delete data.firstName;
const ajv = createAjv();
const v = ajv.compile(schema);
state.jsonforms.errors = validate(v, data);
// add a mock i18n state to verify that the error gets translated
state.jsonforms.i18n = {
translateError: (error) => `i18n-error:${error.keyword}`,
translate: (id: string) => `i18n-key:${id}`
};
const props = mapStateToCellProps(state, ownProps);
t.is(props.errors, 'i18n-error:required');
});

test('mapStateToEnumCellProps - set default options for dropdown list', t => {
const uischema: ControlElement = {
type: 'Control',
Expand Down

0 comments on commit 9828188

Please sign in to comment.