application/__tests__/metaproperties/meta-properties-test.js
jest.unmock('./../../metaproperties/meta-properties');
jest.unmock('./../../metaproperties/text-meta-property');
import React from 'react';
import ReactDOM from 'react-dom';
import TestUtils from 'react-addons-test-utils';
import Immutable from 'immutable';
import sinon from 'sinon';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import getMuiTheme from 'material-ui/styles/getMuiTheme';
import MetaProperties from './../../metaproperties/meta-properties';
import TextMetaProperty from './../../metaproperties/text-meta-property';
import BaseView from './../../components/base-view';
class MockContainer extends BaseView {
render() {
return (
<MuiThemeProvider><div>{this.props.children}</div></MuiThemeProvider>
);
}
}
describe('MetaProperties', () => {
it('returns selected property', () => {
const meta = {
'test': [
'TextMetaProperty'
]
};
MetaProperties.init(meta);
const props = MetaProperties.propertiesForGroup('test');
expect(props).toContain('TextMetaProperty');
});
it('returns empty group', () => {
const meta = {
'test': [
'TextMetaProperty'
]
};
MetaProperties.init(meta);
const props = MetaProperties.propertiesForGroup('feraf');
expect(props).toEqual([]);
});
it('returns component', () => {
const meta = {
'test': [
'TextMetaProperty'
]
};
MetaProperties.init(meta);
const component = MetaProperties.componentForType('TextMetaProperty', {'field': 'foo'});
const rendered = TestUtils.renderIntoDocument(<MockContainer>{component}</MockContainer>);
const el = TestUtils.findRenderedComponentWithType(rendered, TextMetaProperty);
});
it('spreads properties', () => {
const meta = {
'test': [
'TextMetaProperty'
]
};
MetaProperties.init(meta);
const component = MetaProperties.componentForType('TextMetaProperty', {field: 'foo', key: 1, rando: 'Fraf'});
const rendered = TestUtils.renderIntoDocument(<MockContainer>{component}</MockContainer>);
const el = TestUtils.findRenderedComponentWithType(rendered, TextMetaProperty);
expect(el);
expect(el.props.rando).toEqual('Fraf');
});
});