generated from eea/volto-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from eea/develop
Release
- Loading branch information
Showing
15 changed files
with
377 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { Provider } from 'react-intl-redux'; | ||
import DefaultBody from './DefaultBody'; | ||
import configureStore from 'redux-mock-store'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
|
||
jest.mock('react-router-dom', () => ({ | ||
...jest.requireActual('react-router-dom'), | ||
useLocation: () => ({ | ||
pathname: '/', | ||
hash: '', | ||
search: '', | ||
}), | ||
})); | ||
|
||
jest.mock('@plone/volto/components', () => ({ | ||
BlocksForm: jest.fn(() => <div className="blocks-form">RenderBlocks</div>), | ||
RenderBlocks: jest.fn(() => <div>RenderBlocks</div>), | ||
})); | ||
|
||
const mockStore = configureStore(); | ||
const store = mockStore({ | ||
intl: { | ||
locale: 'en', | ||
messages: {}, | ||
}, | ||
}); | ||
|
||
describe('DefaultBody', () => { | ||
it('renders children', () => { | ||
const props = { | ||
data: { | ||
variation: {}, | ||
}, | ||
metadata: {}, | ||
properties: {}, | ||
variation: {}, | ||
}; | ||
|
||
const { getByText } = render( | ||
<Provider store={store}> | ||
<DefaultBody {...props} /> | ||
</Provider>, | ||
); | ||
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(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export function countCharsWithoutSpaces(paragraph) { | ||
const regex = /[^\s\\]/g; | ||
return (paragraph.match(regex) || []).length; | ||
} | ||
|
||
export function countCharsWithSpaces(paragraph) { | ||
return paragraph?.length || 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { countCharsWithoutSpaces, countCharsWithSpaces } from './utils'; | ||
|
||
describe('countCharsWithoutSpaces', () => { | ||
it('should return number of charts without spaces', () => { | ||
const paragraph = 'Lorem ipsum dolor sit'; | ||
expect(countCharsWithoutSpaces(paragraph)).toBe(18); | ||
}); | ||
}); | ||
|
||
describe('countCharsWithSpaces', () => { | ||
it('should return number of charts with spaces', () => { | ||
const paragraph = 'Lorem ipsum dolor sit'; | ||
expect(countCharsWithSpaces(paragraph)).toBe(21); | ||
}); | ||
}); |