generated from eea/volto-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa07bd2
commit f3d3728
Showing
5 changed files
with
212 additions
and
7 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
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,107 @@ | ||
import React from 'react'; | ||
import renderer from 'react-test-renderer'; | ||
import configureStore from 'redux-mock-store'; | ||
import { Provider } from 'react-intl-redux'; | ||
import config from '@plone/volto/registry'; | ||
import installColumnsBlock from '@eeacms/volto-columns-block'; | ||
import { waitFor, render, screen } from '@testing-library/react'; | ||
|
||
import ColumnsBlockView from './ColumnsBlockView'; | ||
|
||
const mockStore = configureStore(); | ||
|
||
const blockId = '1234'; | ||
|
||
const blocks = { | ||
"1234": { | ||
"@type": "columnsBlock", | ||
"data": { | ||
"blocks": { | ||
"9d3b36b7-bc2c-4fd5-80f4-88d104443304": { | ||
"blocks": { | ||
"421f925b-b89f-4a30-b691-3ee14625101e": { | ||
"@type": "text", | ||
"text": "right" | ||
} | ||
}, | ||
"blocks_layout": { | ||
"items": [ | ||
"421f925b-b89f-4a30-b691-3ee14625101e" | ||
] | ||
} | ||
}, | ||
"b80e32c4-dbd9-481e-a98a-ba42b377e593": { | ||
"blocks": { | ||
"6cae4500-c1e2-408c-adee-ce87913b072f": { | ||
"@type": "text", | ||
"text": "left marker" | ||
} | ||
}, | ||
"blocks_layout": { | ||
"items": [ | ||
"6cae4500-c1e2-408c-adee-ce87913b072f" | ||
] | ||
} | ||
} | ||
}, | ||
"blocks_layout": { | ||
"items": [ | ||
"b80e32c4-dbd9-481e-a98a-ba42b377e593", | ||
"9d3b36b7-bc2c-4fd5-80f4-88d104443304" | ||
] | ||
} | ||
}, | ||
"gridCols": [ | ||
"halfWidth", | ||
"halfWidth" | ||
], | ||
"gridSize": 12 | ||
}} | ||
|
||
|
||
const Nop = (props) => <div></div>; | ||
const TextView = ({data}) => { | ||
return data.text; | ||
}; | ||
|
||
test('renders 2 columns', async () => { | ||
installColumnsBlock(config); | ||
config.blocks.blocksConfig.text = { | ||
id: 'text', | ||
title: 'Text', | ||
icon: Nop, | ||
group: 'common', | ||
view: TextView, | ||
edit: TextView, | ||
restricted: false, | ||
mostUsed: false, | ||
blockHasOwnFocusManagement: true, | ||
sidebarTab: 1, | ||
security: { | ||
addPermission: [], | ||
view: [], | ||
}, | ||
} | ||
|
||
const store = mockStore({ | ||
content: { | ||
create: {}, | ||
data: {}, | ||
subrequests: {}, | ||
}, | ||
intl: { | ||
locale: 'en', | ||
messages: {}, | ||
}, | ||
}); | ||
|
||
|
||
const { container } = render( | ||
<Provider store={store}> | ||
<ColumnsBlockView data={blocks['1234']} metadata={{blocks}}/> | ||
</Provider>, | ||
); | ||
await waitFor(() => screen.getByText('left marker')); | ||
expect(container).toMatchSnapshot(); | ||
|
||
}); |
28 changes: 28 additions & 0 deletions
28
src/ColumnsBlock/__snapshots__/ColumnsBlockView.test.js.snap
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,28 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`renders 2 columns 1`] = ` | ||
<div> | ||
<div | ||
class="columns-view" | ||
> | ||
<div | ||
class="ui twelve column grid column-grid" | ||
> | ||
<div | ||
class="six wide computer twelve wide mobile six wide tablet column column-blocks-wrapper" | ||
> | ||
<div> | ||
left marker | ||
</div> | ||
</div> | ||
<div | ||
class="six wide computer twelve wide mobile six wide tablet column column-blocks-wrapper" | ||
> | ||
<div> | ||
right | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
`; |