Skip to content
This repository has been archived by the owner on Dec 13, 2020. It is now read-only.

Commit

Permalink
Namespace child context under key "shortcuts"
Browse files Browse the repository at this point in the history
Issue #1283
  • Loading branch information
pablosichert committed Nov 16, 2017
1 parent d69a136 commit 1e77a05
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
12 changes: 8 additions & 4 deletions src/components/Shortcuts/ShortcutProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ export default class ShortcutProvider extends Component {
};

static childContextTypes = {
subscribe: PropTypes.func.isRequired,
unsubscribe: PropTypes.func.isRequired
shortcuts: PropTypes.shape({
subscribe: PropTypes.func.isRequired,
unsubscribe: PropTypes.func.isRequired
})
};

hotkeys = {};
Expand All @@ -17,8 +19,10 @@ export default class ShortcutProvider extends Component {

getChildContext() {
return {
subscribe: this.subscribe,
unsubscribe: this.unsubscribe
shortcuts: {
subscribe: this.subscribe,
unsubscribe: this.unsubscribe
}
};
}

Expand Down
8 changes: 5 additions & 3 deletions src/components/Shortcuts/ShortcutProvider.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import ShortcutProvider from './ShortcutProvider';

chai.use(sinonChai);

describe('Shortcuts', () => {
describe('ShortcutProvider', () => {
it('should be a React component', () => {
expect(ShortcutProvider).to.be.an.instanceOf(Component.constructor);
});
Expand Down Expand Up @@ -73,8 +73,10 @@ describe('Shortcuts', () => {
const context = shortcutProvider.getChildContext();

expect(context).to.deep.equal({
subscribe: shortcutProvider.subscribe,
unsubscribe: shortcutProvider.unsubscribe
shortcuts: {
subscribe: shortcutProvider.subscribe,
unsubscribe: shortcutProvider.unsubscribe
}
});
});

Expand Down

0 comments on commit 1e77a05

Please sign in to comment.