Skip to content

Commit

Permalink
sigrennesmetropole#34: Toggle toolbar buttons (sigrennesmetropole#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsuren1 authored Jul 29, 2021
1 parent d934910 commit 15160f3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
17 changes: 17 additions & 0 deletions js/extension/plugins/__tests__/UrbanismeToolbar-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,23 @@ describe('UrbanismeToolbar', () => {
expect(includes(ADSButton.getAttribute('class'), 'active')).toBe(true);
});

it('test reset tool of UrbanismeToolbar', () => {
const action = {
onToggleTool: () => {}
};
const spyOnToggleTool = expect.spyOn(action, "onToggleTool");
ReactDOM.render(<UrbanismeToolbar enabled onToggleTool={action.onToggleTool} urbanisme={{activeTool: "ADS"}}/>, document.getElementById("container"));
const container = document.getElementById('container');
expect(container).toBeTruthy();
const buttons = container.querySelectorAll("button");
expect(buttons.length).toBe(4);
// Active tool
const ADSButton = buttons[1];
TestUtils.Simulate.click(ADSButton);
expect(spyOnToggleTool).toHaveBeenCalled();
expect(spyOnToggleTool.calls[0].arguments[0]).toBe(null);
});

it('test UrbanismeToolbar close toolbar', () => {
const actions = {
onToggleControl: () => {}
Expand Down
4 changes: 2 additions & 2 deletions js/extension/plugins/urbanisme/UrbanismeToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const UrbanismeToolbar = ({
tooltip: <Message msgId={'urbanisme.nru.tooltip'}/>,
bsStyle: activeTool === NRU ? "success" : "primary",
active: activeTool === NRU,
onClick: () => onToggleTool(NRU)
onClick: () => onToggleTool(activeTool === NRU ? null : NRU)
},
{
text: <img src={ADSIcon} style={{
Expand All @@ -83,7 +83,7 @@ const UrbanismeToolbar = ({
tooltip: <Message msgId={'urbanisme.ads.tooltip'}/>,
bsStyle: activeTool === ADS ? "success" : "primary",
active: activeTool === ADS,
onClick: () => onToggleTool(ADS)
onClick: () => onToggleTool(activeTool === ADS ? null : ADS)
},
{
glyph: "question-sign",
Expand Down

0 comments on commit 15160f3

Please sign in to comment.