-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH Render some buttons for blocks that can not be edited inline
- Loading branch information
Maxime Rainville
committed
Mar 23, 2022
1 parent
a3e38c5
commit 92affe8
Showing
8 changed files
with
113 additions
and
54 deletions.
There are no files selected for viewing
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
50 changes: 50 additions & 0 deletions
50
client/src/components/ElementActions/tests/SaveAction-test.js
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,50 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
/* global jest, describe, it, expect */ | ||
|
||
import React from 'react'; | ||
import { Component as SaveAction } from '../SaveAction'; | ||
import Enzyme, { mount } from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
|
||
Enzyme.configure({ adapter: new Adapter() }); | ||
|
||
describe('SaveAction', () => { | ||
let wrapper = null; | ||
const mockMutation = jest.fn(() => new Promise((resolve) => { resolve(); })); | ||
const WrappedComponent = (props) => <div>{props.children}</div>; | ||
const ActionComponent = SaveAction(WrappedComponent); | ||
|
||
it('renders a button when block is expandable', () => { | ||
wrapper = mount( | ||
<ActionComponent | ||
title="My save action" | ||
element={{ | ||
ID: 123, | ||
BlockSchema: { type: 'Test' }, | ||
canCreate: true | ||
}} | ||
expandable | ||
actions={{ handlePublishBlock: mockMutation }} | ||
toggle={false} | ||
/> | ||
); | ||
expect(wrapper.find('button').length).toBe(1); | ||
}); | ||
|
||
it('does not renders a button when block is not expandable', () => { | ||
wrapper = mount( | ||
<ActionComponent | ||
title="My save action" | ||
element={{ | ||
ID: 123, | ||
BlockSchema: { type: 'Test' }, | ||
canCreate: true | ||
}} | ||
expandable={false} | ||
actions={{ handlePublishBlock: mockMutation }} | ||
toggle={false} | ||
/> | ||
); | ||
expect(wrapper.find('button').length).toBe(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
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