Commit 85ede011 authored by Eric Eastwood's avatar Eric Eastwood Committed by Andrew Newdigate

Merge branch 'develop' into feature/fix-tooltip-react-warning-unknown-props-v2

 Conflicts:
	modules/topics-ui/shared/containers/components/tooltip.jsx
	modules/topics-ui/test/specs/shared/containers/components/tooltip-test.jsx
parents 1931010b b108a548
import React, { PropTypes } from 'react';
import _ from 'lodash';
import classNames from 'classnames';
const Tooltip = React.createClass({
......@@ -44,6 +45,8 @@ const Tooltip = React.createClass({
const ElementType = elementType;
const compiledTooltipClassName = classNames({
[tooltipClassName]: true,
//This active element actually HIDES the element
//so the naming here is wrong
active: tooltip && tooltip.length > 0
});
......
......@@ -13,7 +13,8 @@ export default [
tags: [ '1', '2', '3' ],
user: { username: 'cutandpastey', avatarUrl: 'test-src'},
replyingUsers: [],
subscriptionState: SUBSCRIPTION_STATE_UNSUBSCRIBED
subscriptionState: SUBSCRIPTION_STATE_UNSUBSCRIBED,
reactions: { likes: 1 }
},
{
title: '2',
......@@ -26,7 +27,8 @@ export default [
tags: [ '2', '3', '4' ],
user: { username: 'test', avatarUrl: 'test-src'},
replyingUsers: [],
subscriptionState: SUBSCRIPTION_STATE_UNSUBSCRIBED
subscriptionState: SUBSCRIPTION_STATE_UNSUBSCRIBED,
reactions: { likes: 1 }
},
{
title: '3',
......@@ -39,7 +41,8 @@ export default [
tags: [ '3', '4', '5' ],
user: { username: 'cutandpastey', avatarUrl: 'test-src'},
replyingUsers: [],
subscriptionState: SUBSCRIPTION_STATE_UNSUBSCRIBED
subscriptionState: SUBSCRIPTION_STATE_UNSUBSCRIBED,
reactions: { likes: 1 }
},
{
title: '4',
......@@ -51,7 +54,8 @@ export default [
tags: [ '4', '5', '6' ],
user: { username: 'test', avatarUrl: 'test-src'},
replyingUsers: [],
subscriptionState: SUBSCRIPTION_STATE_UNSUBSCRIBED
subscriptionState: SUBSCRIPTION_STATE_UNSUBSCRIBED,
reactions: { likes: 1 }
},
{
title: '5',
......@@ -64,6 +68,7 @@ export default [
tags: [ '5', '6', '7' ],
user: { username: 'test-user', avatarUrl: 'test-src'},
replyingUsers: [],
subscriptionState: SUBSCRIPTION_STATE_UNSUBSCRIBED
subscriptionState: SUBSCRIPTION_STATE_UNSUBSCRIBED,
reactions: { likes: 1 }
},
];
import assert from 'assert';
import sinon from 'sinon';
import * as forumCatConstants from '../../../../shared/constants/forum-categories';
import {UPDATE_ACTIVE_CATEGORY} from '../../../../shared/constants/forum-categories';
import mockRouter from '../../../mocks/router';
import categories from '../../../mocks/mock-data/categories';
import injector from 'inject-loader!../../../../browser/js/stores/forum-category-store';
const {getForumCategoryStore} = injector({
const {ForumCategoryStore} = injector({
'../routers/index': mockRouter
});
describe('ForumCategoryStore', function(){
let categoryStore;
let handle;
let categoryStore;
beforeEach(function(){
handle = sinon.spy();
categoryStore = getForumCategoryStore(categories);
categoryStore = new ForumCategoryStore(categories);
});
it('should update the active element when the route changes', function(){
mockRouter.set('categoryName', 'test-1');
mockRouter.set('category', 'test-1');
assert.equal(categoryStore.at(0).get('active'), false);
assert(categoryStore.at(1).get('active'));
});
//This works when run with only ???
it('should dispatch un active:update event when the active category changes', function(){
categoryStore.on(forumCatConstants.UPDATE_ACTIVE_CATEGORY, handle)
mockRouter.set('categoryName', 'test-1');
categoryStore.on(UPDATE_ACTIVE_CATEGORY, handle);
mockRouter.set('category', 'test-2');
assert.equal(handle.callCount, 1);
});
......
......@@ -41,7 +41,7 @@ describe('CategoryStore', function(){
it('should allow you to get by id', () => {
const expected = categories[1];
const result = store.getById(expected.id);
assert.deepEqual(result, expected);
assert.equal(result.category, expected.category);
});
......
......@@ -11,8 +11,8 @@ describe('<IconButton/>', () => {
wrapper = shallow(<IconButton/>);
});
it('should fail a test because you should write some', () => {
assert(false, 'Srsly, write some tests');
it('should render', () => {
assert(wrapper.length);
});
});
......@@ -28,13 +28,14 @@ describe('<TextTypeAhead/>', () => {
});
it('should render a ul when the input has content', () => {
equal(wrapper.find('ul').length, 0);
wrapper.find('Input').at(0).prop('onFocus')();
wrapper.find('Input').at(0).prop('onChange')('test');
equal(wrapper.find('ul').length, 1, 'failed to render the ul');
equal(wrapper.find('li').length, completions.length, 'failed to render the li\'s');
});
it('should filter the list items based on the term', () => {
wrapper.find('Input').at(0).prop('onFocus')();
wrapper.find('Input').at(0).prop('onChange')('1');
equal(wrapper.find('li').length, 1, 'failed to render the li\'s');
});
......@@ -57,34 +58,45 @@ describe('<TextTypeAhead/>', () => {
it('should call onSubmit when a type ahead item is clicked', () => {
mockEvent.keyCode = DOWN_KEY;
wrapper.find('Input').at(0).prop('onFocus')();
wrapper.find('.type-ahead-wrapper').simulate('keyDown', mockEvent);
wrapper.find('Input').at(0).prop('onChange')('test');
wrapper.find('li').at(0).simulate('mouseDown', mockEvent);
wrapper.find('li').at(0).prop('onMouseDown')(mockEvent);
equal(changeHandle.callCount, 1);
});
it('should cycle active classes through the completions when the down key is pressed', () => {
wrapper.find('Input').at(0).prop('onChange')('test');
mockEvent.keyCode = DOWN_KEY;
wrapper.find('Input').at(0).prop('onFocus')();
wrapper.find('Input').at(0).prop('onChange')('test');
wrapper.find('.type-ahead-wrapper').simulate('keyDown', mockEvent);
equal(wrapper.find('li').at(0).prop('className'), 'type-ahead__child--active');
equal(wrapper.find('li').at(0).prop('className'), 'type-ahead__child--active', 'first');
wrapper.find('.type-ahead-wrapper').simulate('keyDown', mockEvent);
equal(wrapper.find('li').at(1).prop('className'), 'type-ahead__child--active');
equal(wrapper.find('li').at(1).prop('className'), 'type-ahead__child--active', 'second');
wrapper.find('.type-ahead-wrapper').simulate('keyDown', mockEvent);
equal(wrapper.find('li').at(2).prop('className'), 'type-ahead__child--active');
equal(wrapper.find('li').at(2).prop('className'), 'type-ahead__child--active', 'third');
wrapper.find('.type-ahead-wrapper').simulate('keyDown', mockEvent);
equal(wrapper.find('li').at(0).prop('className'), 'type-ahead__child--active');
equal(wrapper.find('li').at(0).prop('className'), 'type-ahead__child--active', 'fouth');
});
it('should cycle active classes through the completions backwards when the up key is pressed', () => {
wrapper.find('Input').at(0).prop('onChange')('test');
mockEvent.keyCode = UP_KEY;
wrapper.find('Input').at(0).prop('onFocus')();
wrapper.find('Input').at(0).prop('onChange')('test');
wrapper.find('.type-ahead-wrapper').simulate('keyDown', mockEvent);
equal(wrapper.find('li').at(2).prop('className'), 'type-ahead__child--active');
wrapper.find('.type-ahead-wrapper').simulate('keyDown', mockEvent);
equal(wrapper.find('li').at(1).prop('className'), 'type-ahead__child--active');
wrapper.find('.type-ahead-wrapper').simulate('keyDown', mockEvent);
equal(wrapper.find('li').at(0).prop('className'), 'type-ahead__child--active');
wrapper.find('.type-ahead-wrapper').simulate('keyDown', mockEvent);
equal(wrapper.find('li').at(2).prop('className'), 'type-ahead__child--active');
});
......
......@@ -24,7 +24,8 @@ describe('<TopicsTableHeader/>', () => {
});
it('should render the th elements with the right class', () => {
equal(wrapper.find('.topics-table-header__cell').length, 4);
equal(wrapper.find('.topics-table-header__cell').length, 3);
equal(wrapper.find('.topics-table-header__cell--user').length, 1);
});
});
......@@ -27,7 +27,7 @@ describe('<ForumCategoryLink/>', () => {
});
it('should render the right title', () => {
equal(wrapper.find('a').at(0).prop('title'), `View all ${category.name} topics`);
equal(wrapper.find('a').at(0).prop('title'), `View all ${category.category} topics`);
});
it('should render the right href', () => {
......@@ -38,7 +38,7 @@ describe('<ForumCategoryLink/>', () => {
wrapper = shallow(
<ForumCategoryLink
groupUri="gitterHQ"
category={{name: DEFAULT_CATEGORY_NAME, slug: 'all'}}>
category={{category: DEFAULT_CATEGORY_NAME, slug: 'all'}}>
test
</ForumCategoryLink>
)
......
......@@ -16,6 +16,7 @@ describe('<H1/>', () => {
});
it('should render a .h1 class', () => {
wrapper = shallow(<H1/>);
equal(wrapper.find('.h1').length, 1);
});
......
......@@ -16,7 +16,7 @@ describe('<TopicHeader/>', () => {
<TopicHeader
tags={topic.tags}
topic={topic}
category={category}
categories={categories}
groupUri="gitterHQ"/>
);
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment