application/__tests__/components/common/rich-editor/media-results-test.js
jest.unmock('./../../../../components/common/rich-editor/media-results');
jest.unmock('./../../../../components/common/rich-editor/media-result');
jest.unmock('./../../../../components/common/loading-indicator');
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 AltTestingUtils from 'alt-utils/lib/AltTestingUtils';
import {GridTile} from 'material-ui/GridList';
import MediaResults from './../../../../components/common/rich-editor/media-results';
import MediaResult from './../../../../components/common/rich-editor/media-result';
import LoadingIndicator from './../../../../components/common/loading-indicator';
describe('MediaResultsEditorComponent', () => {
it('loads indicator', () => {
const content = Immutable.fromJS([{attachment: {}}]);
const pagination = Immutable.fromJS({});
const clickSpy = sinon.stub();
const el = TestUtils.renderIntoDocument(<MediaResults results={content} pagination={pagination} onSelectMedia={clickSpy} />);
const pag = TestUtils.findRenderedComponentWithType(el, LoadingIndicator);
expect(pag).not.toBeUndefined();
});
it('bubbles onSelect', () => {
const content = Immutable.fromJS([{attachment: {}},{attachment: {}}]);
const pagination = Immutable.fromJS({first: 1, last: 1, next: 1, back: 1});
const clickSpy = sinon.stub();
const el = TestUtils.renderIntoDocument(<MediaResults results={content} pagination={pagination} onSelectMedia={clickSpy} />);
const mediaItem = TestUtils.scryRenderedComponentsWithType(el, MediaResult)[0];
const item = TestUtils.findRenderedComponentWithType(
mediaItem,
GridTile
);
expect(item);
mediaItem.onSelect();
expect(clickSpy.called).toEqual(true);
});
});