core-resource-app-test
Version:
App that contains assets and scripts for the core apps
27 lines (19 loc) • 864 B
JavaScript
import React from 'react';
import addD2Context from '../../src/component-helpers/addD2Context';
describe('addD2Context', () => {
it('should be a function', () => {
expect(addD2Context).to.be.a('function');
});
it('should be return the passed in class with the context added to it', () => {
class Component extends React.Component {}
const componentWithD2Context = addD2Context(Component, {
name: React.PropTypes.object,
});
expect(componentWithD2Context.contextTypes).to.deep.equal({ d2: React.PropTypes.object });
});
it('should also add the contextTypes to a function component', () => {
function App() {}
const componentWithD2Context = addD2Context(App);
expect(componentWithD2Context.contextTypes).to.deep.equal({ d2: React.PropTypes.object });
});
});