Skip to content

Commit

Permalink
test: undo changes + update snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
kreafox committed Dec 12, 2023
1 parent 652f980 commit 8200241
Show file tree
Hide file tree
Showing 8 changed files with 208 additions and 124 deletions.
48 changes: 17 additions & 31 deletions src/Blocks/EmbedTableauVisualization/Edit.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,10 @@ import React from 'react';
import renderer from 'react-test-renderer';
import { Provider } from 'react-intl-redux';
import config from '@plone/volto/registry';
import configureStore from 'redux-mock-store';
import { MemoryRouter } from 'react-router-dom';

import Edit from './Edit';
import installEmbedTableau from '.';

const mockStore = configureStore();

const store = mockStore({
userSession: { token: '1234' },
intl: {
locale: 'en',
messages: {},
},
});

installEmbedTableau(config);

describe('Edit', () => {
Expand All @@ -35,25 +23,23 @@ describe('Edit', () => {

it('should render the component', () => {
const component = renderer.create(
<Provider store={store}>
<MemoryRouter>
<Edit
id="my-tableau"
data={data}
pathname="/news"
selected={false}
block="1234"
index={1}
onChangeBlock={() => {}}
onSelectBlock={() => {}}
onDeleteBlock={() => {}}
onFocusPreviousBlock={() => {}}
onFocusNextBlock={() => {}}
handleKeyDown={() => {}}
content={{}}
useVisibilitySensor={false}
/>
</MemoryRouter>
<Provider store={global.store}>
<Edit
id="my-tableau"
data={data}
pathname="/news"
selected={false}
block="1234"
index={1}
onChangeBlock={() => {}}
onSelectBlock={() => {}}
onDeleteBlock={() => {}}
onFocusPreviousBlock={() => {}}
onFocusNextBlock={() => {}}
handleKeyDown={() => {}}
content={{}}
useVisibilitySensor={false}
/>
</Provider>,
);
const json = component.toJSON();
Expand Down
18 changes: 2 additions & 16 deletions src/Blocks/EmbedTableauVisualization/View.test.jsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
import React from 'react';
import renderer from 'react-test-renderer';
import configureStore from 'redux-mock-store';
import { MemoryRouter } from 'react-router-dom';
import { Provider } from 'react-intl-redux';
import View from './View';

const mockStore = configureStore();

const store = mockStore({
userSession: { token: '1234' },
intl: {
locale: 'en',
messages: {},
},
});

describe('View', () => {
const data = {
'@type': 'embed_tableau_visualization',
Expand All @@ -30,10 +18,8 @@ describe('View', () => {

it('should render the component', () => {
const component = renderer.create(
<Provider store={store}>
<MemoryRouter>
<View data={data} useVisibilitySensor={false} />
</MemoryRouter>
<Provider store={global.store}>
<View data={data} useVisibilitySensor={false} />
</Provider>,
);
const json = component.toJSON();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ Array [
-
Tableau height
</div>
<div
className="mocked-boolean-widget"
id="mocked-field-enable_queries"
>
Enable queries
-
Will import Criteria from content-type.
</div>
</div>
</div>
<div
Expand Down Expand Up @@ -181,6 +189,75 @@ Array [
</div>
</div>
</div>
<div
className="accordion ui fluid styled form"
>
<div
id="blockform-fieldset-options"
>
<div
className="title"
onClick={[Function]}
>
Options
<svg
className="icon"
dangerouslySetInnerHTML={
Object {
"__html": undefined,
}
}
onClick={null}
style={
Object {
"fill": "currentColor",
"height": "20px",
"width": "auto",
}
}
viewBox=""
xmlns=""
/>
</div>
<div
className="content"
>
<div
aria-hidden={true}
className="rah-static rah-static--height-zero"
style={
Object {
"height": 0,
"overflow": "hidden",
}
}
>
<div
style={
Object {
"WebkitTransition": "opacity 500ms ease 0ms",
"opacity": 0,
"transition": "opacity 500ms ease 0ms",
}
}
>
<div
className="ui segment attached"
>
<div
className="mocked-default-widget"
id="mocked-field-static_params"
>
Static parameters
-
Set a list of static parameters.
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div
className="accordion ui fluid styled form"
>
Expand Down
18 changes: 2 additions & 16 deletions src/Tableau/Tableau.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,13 @@ import React from 'react';
import { render } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';
import { Provider } from 'react-redux';
import configureStore from 'redux-mock-store';
import { MemoryRouter } from 'react-router-dom';
import Tableau from './Tableau';

const mockStore = configureStore();

const store = mockStore({
userSession: { token: '1234' },
intl: {
locale: 'en',
messages: {},
},
});

describe('Tableau', () => {
it('should render the component', () => {
const { container } = render(
<Provider store={store}>
<MemoryRouter>
<Tableau />
</MemoryRouter>
<Provider store={global.store}>
<Tableau />
</Provider>,
);
expect(container.querySelector('.tableau-wrapper')).toBeInTheDocument();
Expand Down
18 changes: 2 additions & 16 deletions src/Utils/Download.test.jsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,14 @@
import React from 'react';
import renderer from 'react-test-renderer';
import { Provider } from 'react-intl-redux';
import configureStore from 'redux-mock-store';
import { MemoryRouter } from 'react-router-dom';

import Download from './Download';

const mockStore = configureStore();

const store = mockStore({
userSession: { token: '1234' },
intl: {
locale: 'en',
messages: {},
},
});

describe('Edit', () => {
it('should render the component', () => {
const component = renderer.create(
<Provider store={store}>
<MemoryRouter>
<Download />
</MemoryRouter>
<Provider store={global.store}>
<Download />
</Provider>,
);
const json = component.toJSON();
Expand Down
116 changes: 103 additions & 13 deletions src/Utils/__snapshots__/Download.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,110 @@

exports[`Edit should render the component 1`] = `
<div
className="tableau-download-container"
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
onMouseEnter={[Function]}
onMouseLeave={[Function]}
className="popup"
>
<button
className="trigger-button"
<div
className="trigger"
>
<i
className="ri-download-fill"
/>
Download
</button>
<div
className="tableau-download-container"
>
<button
className="trigger-button"
>
<i
className="ri-download-fill"
/>
Download
</button>
</div>
</div>
<div
className="content"
>
<div
className="item"
>
<span
className="label"
>
Data formats
</span>
<div
className="types"
>
<div
className="type"
>
<button
onClick={[Function]}
>
<span>
CSV
</span>
</button>
</div>
<div
className="type"
>
<button
onClick={[Function]}
>
<span>
Excel
</span>
</button>
</div>
</div>
</div>
<div
className="item"
>
<span
className="label"
>
Image formats
</span>
<div
className="types"
>
<div
className="type"
>
<button
onClick={[Function]}
>
<span>
PNG
</span>
</button>
</div>
</div>
</div>
<div
className="item"
>
<span
className="label"
>
Other formats
</span>
<div
className="types"
>
<div
className="type"
>
<button
onClick={[Function]}
>
<span>
PDF
</span>
</button>
</div>
</div>
</div>
</div>
</div>
`;
Loading

0 comments on commit 8200241

Please sign in to comment.