-
Notifications
You must be signed in to change notification settings - Fork 481
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
e6fa4f0
commit 14d27f7
Showing
1 changed file
with
113 additions
and
0 deletions.
There are no files selected for viewing
113 changes: 113 additions & 0 deletions
113
client/src/app/panel/tabs/variable-outline/__tests__/VariableOutlineStatusBarItemSpec.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,113 @@ | ||
/** | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH | ||
* under one or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information regarding copyright | ||
* ownership. | ||
* | ||
* Camunda licenses this file to you under the MIT; you may not use this file | ||
* except in compliance with the MIT License. | ||
*/ | ||
|
||
/* global sinon */ | ||
|
||
import React from 'react'; | ||
|
||
import { mount } from 'enzyme'; | ||
|
||
import { | ||
SlotFillRoot, | ||
Slot | ||
} from '../../../../slot-fill'; | ||
|
||
import VariableOutlineStatusBarItem from '../VariableOutlineStatusBarItem'; | ||
|
||
const spy = sinon.spy; | ||
|
||
|
||
describe('VariableOutlineStatusBarItem', function() { | ||
|
||
it('should render', function() { | ||
|
||
// when | ||
const wrapper = renderVariableOutlineStatusBarItem(); | ||
|
||
// then | ||
expect(wrapper.find(VariableOutlineStatusBarItem).exists()).to.be.true; | ||
}); | ||
|
||
|
||
describe('toggle', function() { | ||
|
||
it('should be active (open)', function() { | ||
|
||
// when | ||
const wrapper = renderVariableOutlineStatusBarItem({ | ||
layout: { | ||
panel: { | ||
open: true, | ||
tab: 'variable-outline' | ||
} | ||
} | ||
}); | ||
|
||
// then | ||
expect(wrapper.find('.btn').hasClass('btn--active')).to.be.true; | ||
}); | ||
|
||
|
||
it('should not be active (closed)', function() { | ||
|
||
// when | ||
const wrapper = renderVariableOutlineStatusBarItem(); | ||
|
||
// then | ||
expect(wrapper.find('.btn').hasClass('btn--active')).to.be.false; | ||
}); | ||
|
||
|
||
it('should call callback on toggle', function() { | ||
|
||
// given | ||
const onToggleSpy = spy(); | ||
|
||
const wrapper = renderVariableOutlineStatusBarItem({ | ||
onToggle: onToggleSpy | ||
}); | ||
|
||
// when | ||
wrapper.find('.btn').simulate('click'); | ||
|
||
// then | ||
expect(onToggleSpy).to.have.been.calledOnce; | ||
}); | ||
|
||
}); | ||
|
||
}); | ||
|
||
|
||
// helpers ////////// | ||
|
||
const defaultLayout = { | ||
panel: { | ||
open: false, | ||
tab: 'variable-outline' | ||
} | ||
}; | ||
|
||
|
||
function renderVariableOutlineStatusBarItem(options = {}) { | ||
const { | ||
layout = defaultLayout, | ||
onToggle | ||
} = options; | ||
|
||
return mount( | ||
<SlotFillRoot> | ||
<Slot name="status-bar__file" /> | ||
<VariableOutlineStatusBarItem | ||
layout={ layout } | ||
onToggle={ onToggle } /> | ||
</SlotFillRoot> | ||
); | ||
} |