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

Commit

Permalink
test(Dropdown): Added test (#490)
Browse files Browse the repository at this point in the history
  • Loading branch information
Myoxocephalus authored and JacobBlomgren committed Dec 21, 2018
1 parent 0b98933 commit 8ab2874
Showing 1 changed file with 10 additions and 0 deletions.
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();
});
});

0 comments on commit 8ab2874

Please sign in to comment.