-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Root-App/rmc-subscribable-fix
Updates Subscribable.Mixin to support unmounting
- Loading branch information
Showing
2 changed files
with
31 additions
and
21 deletions.
There are no files selected for viewing
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
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,25 @@ | ||
import React from 'react'; | ||
import { expect } from 'chai'; | ||
import Subscribable from '../../src/mixins/Subscribable.js'; | ||
import DeviceEventEmitter from '../../src/plugins/DeviceEventEmitter.js'; | ||
|
||
describe('Subscribable.Mixin', () => { | ||
it('Can mount and unmount with a DeviceEventEmitter subscribed. Does not interupt existing events.', () => { | ||
const SubscribableClass = React.createClass({ | ||
mixins: [Subscribable.Mixin], | ||
render() { | ||
return null; | ||
}, | ||
}); | ||
const subscribableComponent = new SubscribableClass(); | ||
const existingEventType = 'Existing Event'; | ||
DeviceEventEmitter.addListener(existingEventType, () => {}, context); | ||
expect(DeviceEventEmitter.listeners(existingEventType)).to.have.length(1); | ||
|
||
subscribableComponent.componentWillMount(); | ||
subscribableComponent.addListenerOn(DeviceEventEmitter, 'Test Event Type', () => {}); | ||
subscribableComponent.componentWillUnmount(); | ||
|
||
expect(DeviceEventEmitter.listeners(existingEventType)).to.have.length(1); | ||
}); | ||
}); |