Skip to content
This repository has been archived by the owner on Oct 20, 2022. It is now read-only.

Dropdown test #490

Merged
merged 7 commits into from
Dec 21, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions test/components/dropdown/dropdown.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import sinon from 'sinon';
import { expect, assert } from 'chai';
import { shallow } from 'enzyme';
import { mockClasses, theme } from '../../../src';
Expand Down Expand Up @@ -35,4 +36,13 @@ describe('<Dropdown />', () => {
it(`should have the ${classes.dropdown} class`, () => {
expect(wrapper.hasClass(classes.dropdown)).to.equal(true);
});

it('should unsubscribe from click events on unmount', () => {
const sandbox = sinon.sandbox.create();
const removeEventSpy = sandbox.spy(document, 'removeEventListener');
const handleClick = wrapper.instance().handleClick;
wrapper.unmount();
expect(removeEventSpy.calledWith('click', handleClick)).to.equal(true);
sandbox.restore();
});
});