Skip to content

Commit

Permalink
test: fix bug reported by sonarqube, add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kreafox committed Nov 24, 2023
1 parent 0c5fc63 commit 3599b0f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/manage/Blocks/Group/CounterComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const countTextInEachBlock = (countTextIn, ignoreSpaces, groupCharCount) => ([
};

const countTextInBlocks = (blocksObject, ignoreSpaces, maxChars) => {
const { countTextIn } = config.blocks?.blocksConfig?.group;
const { countTextIn } = config.blocks?.blocksConfig?.group || [];
// use obj ref to update value - if you send number it will not be updated
const groupCharCount = { value: 0 };

Expand Down
27 changes: 27 additions & 0 deletions src/components/manage/Blocks/Group/DefaultBody.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,30 @@ describe('DefaultBody', () => {
expect(getByText('RenderBlocks')).toBeInTheDocument();
});
});

describe('DefaultBody Edit', () => {
it('renders children', () => {
const props = {
isEditMode: true,
data: {
variation: {},
allowedBlocks: ['listing'],
},
metadata: {},
properties: {},
variation: {},
onSelectBlock: jest.fn(),
onDeleteBlock: jest.fn(),
onMutateBlock: jest.fn(),
onInsertBlock: jest.fn(),
selected: true,
};

const { getByText } = render(
<Provider store={store}>
<DefaultBody {...props} />
</Provider>,
);
expect(getByText('RenderBlocks')).toBeInTheDocument();
});
});

0 comments on commit 3599b0f

Please sign in to comment.