aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/responsive
diff options
context:
space:
mode:
authorDan Finlay <flyswatter@users.noreply.github.com>2017-07-19 02:05:19 +0800
committerGitHub <noreply@github.com>2017-07-19 02:05:19 +0800
commit199587383b022a17d56adcb56d6a99ceba71fec7 (patch)
treef66c331820ef10fa6e61df8e2d8c129d70c8cc4c /test/unit/responsive
parent1e0cd5f3028619d088fedf4cdb1b4a7cb81f9cf1 (diff)
parent9e8e445695585f47e9cc3f63b2ec8313b4fc4eb8 (diff)
downloadtangerine-wallet-browser-199587383b022a17d56adcb56d6a99ceba71fec7.tar
tangerine-wallet-browser-199587383b022a17d56adcb56d6a99ceba71fec7.tar.gz
tangerine-wallet-browser-199587383b022a17d56adcb56d6a99ceba71fec7.tar.bz2
tangerine-wallet-browser-199587383b022a17d56adcb56d6a99ceba71fec7.tar.lz
tangerine-wallet-browser-199587383b022a17d56adcb56d6a99ceba71fec7.tar.xz
tangerine-wallet-browser-199587383b022a17d56adcb56d6a99ceba71fec7.tar.zst
tangerine-wallet-browser-199587383b022a17d56adcb56d6a99ceba71fec7.zip
Merge pull request #1790 from sdtsui/newui-account-dropdowns
[newui] - Implement Advanced Option Menu & Account Switching Menu
Diffstat (limited to 'test/unit/responsive')
-rw-r--r--test/unit/responsive/components/dropdown-test.js108
1 files changed, 86 insertions, 22 deletions
diff --git a/test/unit/responsive/components/dropdown-test.js b/test/unit/responsive/components/dropdown-test.js
index feadc792e..4d417d394 100644
--- a/test/unit/responsive/components/dropdown-test.js
+++ b/test/unit/responsive/components/dropdown-test.js
@@ -9,14 +9,18 @@ const Dropdown = require(path.join(__dirname, '..', '..', '..', '..', 'ui', 'res
const DropdownMenuItem = require(path.join(__dirname, '..', '..', '..', '..', 'ui', 'responsive', 'app', 'components', 'dropdown.js')).DropdownMenuItem;
describe('Dropdown components', function () {
- it('can render two items', function () {
- const renderer = ReactTestUtils.createRenderer()
+ let onClickOutside;
+ let closeMenu;
+ let onClick;
- const onClickOutside = sinon.spy();
- const closeMenu = sinon.spy();
- const onClick = sinon.spy();
+ let dropdownComponentProps;
+ const renderer = ReactTestUtils.createRenderer()
+ beforeEach(function () {
+ onClickOutside = sinon.spy();
+ closeMenu = sinon.spy();
+ onClick = sinon.spy();
- const dropdownComponent = h(Dropdown, {
+ dropdownComponentProps = {
isOpen: true,
zIndex: 11,
onClickOutside,
@@ -26,26 +30,86 @@ describe('Dropdown components', function () {
top: '36px',
},
innerStyle: {},
- }, [ // DROP MENU ITEMS
- h('style', `
- .drop-menu-item:hover { background:rgb(235, 235, 235); }
- .drop-menu-item i { margin: 11px; }
- `),
-
- h(DropdownMenuItem, {
- closeMenu,
- onClick,
- }, 'Item 1'),
-
- h(DropdownMenuItem, {
- closeMenu,
- onClick,
- }, 'Item 2'),
- ])
+ }
+ });
+
+ it('can render two items', function () {
+ const dropdownComponent = h(
+ Dropdown,
+ dropdownComponentProps,
+ [
+ h('style', `
+ .drop-menu-item:hover { background:rgb(235, 235, 235); }
+ .drop-menu-item i { margin: 11px; }
+ `),
+ h(DropdownMenuItem, {
+ closeMenu,
+ onClick,
+ }, 'Item 1'),
+ h(DropdownMenuItem, {
+ closeMenu,
+ onClick,
+ }, 'Item 2'),
+ ]
+ )
const component = additions.renderIntoDocument(dropdownComponent);
renderer.render(dropdownComponent);
const items = additions.find(component, 'li');
assert.equal(items.length, 2);
});
+
+ it('closes when item clicked', function() {
+ const dropdownComponent = h(
+ Dropdown,
+ dropdownComponentProps,
+ [
+ h('style', `
+ .drop-menu-item:hover { background:rgb(235, 235, 235); }
+ .drop-menu-item i { margin: 11px; }
+ `),
+ h(DropdownMenuItem, {
+ closeMenu,
+ onClick,
+ }, 'Item 1'),
+ h(DropdownMenuItem, {
+ closeMenu,
+ onClick,
+ }, 'Item 2'),
+ ]
+ )
+ const component = additions.renderIntoDocument(dropdownComponent);
+ renderer.render(dropdownComponent);
+ const items = additions.find(component, 'li');
+ const node = items[0];
+ ReactTestUtils.Simulate.click(node);
+ assert.equal(closeMenu.calledOnce, true);
+ });
+
+ it('invokes click handler when item clicked', function() {
+ const dropdownComponent = h(
+ Dropdown,
+ dropdownComponentProps,
+ [
+ h('style', `
+ .drop-menu-item:hover { background:rgb(235, 235, 235); }
+ .drop-menu-item i { margin: 11px; }
+ `),
+ h(DropdownMenuItem, {
+ closeMenu,
+ onClick,
+ }, 'Item 1'),
+ h(DropdownMenuItem, {
+ closeMenu,
+ onClick,
+ }, 'Item 2'),
+ ]
+ )
+ const component = additions.renderIntoDocument(dropdownComponent);
+ renderer.render(dropdownComponent);
+ const items = additions.find(component, 'li');
+ const node = items[0];
+ ReactTestUtils.Simulate.click(node);
+ assert.equal(onClick.calledOnce, true);
+ });
}); \ No newline at end of file