', () => {
expect(toJson(wrapper)).toMatchSnapshot();
});
- xit('should call fetchMessages() at componentDidMount', () => {
- // FIXME TODO need store to render nested connected component
+ it('should call fetchData() at lifecycle changes', () => {
+ const { props, component } = setup();
+ const newProps = setup({convoName: 'react'}).props;
+ const wrapper = mount(component);
+ // fetchMessages called once on mount
+ expect(props.fetchMessages).toHaveBeenCalledTimes(1);
+ // fetchMessages not called, no change in props
+ wrapper.instance().componentDidUpdate(props);
+ expect(props.fetchMessages).toHaveBeenCalledTimes(1);
+ // fetchMessages called again on update
+ wrapper.instance().componentDidUpdate(newProps);
+ expect(props.fetchMessages).toHaveBeenCalledTimes(2);
});
it('should receive the correct props from state', () => {
diff --git a/src/client/components/chatmain/ChatToolbar.jsx b/src/client/components/chatmain/ChatToolbar.jsx
index de8bec2..b46f279 100644
--- a/src/client/components/chatmain/ChatToolbar.jsx
+++ b/src/client/components/chatmain/ChatToolbar.jsx
@@ -1,9 +1,27 @@
import React from 'react';
-export const ChatToolbar = () => (
-
-);
+export const ChatToolbar = ({ messages, user }) => {
+ const currentUser = user.username ? [{...user}] : [];
+ const users = messages
+ .concat(currentUser)
+ .map((message) => message.username)
+ .filter((username, i, arr) => arr.indexOf(username) === i)
+ .map((username) => (
+
+
+ {/* */}
+
+ ));
+ return (
+
+ );
+};
export default ChatToolbar;
diff --git a/src/client/components/chatmain/ChatToolbar.spec.js b/src/client/components/chatmain/ChatToolbar.spec.js
index d1548bb..3ef005c 100644
--- a/src/client/components/chatmain/ChatToolbar.spec.js
+++ b/src/client/components/chatmain/ChatToolbar.spec.js
@@ -3,18 +3,31 @@ import React from 'react';
import renderer from 'react-test-renderer';
import ChatToolbar from './ChatToolbar.jsx';
-const setup = () => {
- const component =
;
+const setup = (propOverrides) => {
+ const props = Object.assign({
+ messages: [
+ {username: 'Joe'},
+ {username: 'Josh'},
+ ],
+ user: {username: 'Liz'}
+ }, propOverrides);
return {
- component
+ props
};
};
describe('
', () => {
- it('should render correctly', () => {
- const { component } = setup();
- const renderedComponent = renderer.create(component);
+ it('should render correctly when logged in', () => {
+ const { props } = setup();
+ const renderedComponent = renderer.create(
);
+ const tree = renderedComponent.toJSON();
+ expect(tree).toMatchSnapshot();
+ });
+
+ it('should render correctly when not logged in', () => {
+ const { props } = setup({user: {}});
+ const renderedComponent = renderer.create(
);
const tree = renderedComponent.toJSON();
expect(tree).toMatchSnapshot();
});
diff --git a/src/client/components/chatmain/chatmain.scss b/src/client/components/chatmain/chatmain.scss
index eb4e9de..a435fdb 100644
--- a/src/client/components/chatmain/chatmain.scss
+++ b/src/client/components/chatmain/chatmain.scss
@@ -1,7 +1,7 @@
@import '../../mixins/_variables.scss';
.loading-container {
- background-color: rgba(0, 0, 0, 0.5);
+ background-color: $trans-black5;
display: flex;
align-items: center;
justify-content: center;
@@ -14,8 +14,8 @@
width: 80px;
height: 80px;
border-radius: 100%;
- border: 10px solid rgba(255, 255, 255, 0.2);
- border-top-color: #FFF;
+ border: 10px solid $trans-white2;
+ border-top-color: $white;
animation: spin 1s infinite linear;
}
@@ -58,6 +58,7 @@
.chat-toolbar {
position: relative;
+ padding: 20px;
top: 0;
bottom: 0;
right: 0;
@@ -65,8 +66,42 @@
flex-shrink: 0;
display: flex;
width: 70px;
- //
- border-left: 1px solid #f1f1f1;
+ border-left: 1px solid $seashell;
+
+ .roster {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ }
+
+ .avatar {
+ display: inline-block;
+ position: relative;
+ background-size: cover;
+
+ img {
+ height: 30px;
+ width: 30px;
+ border-radius: 4px;
+ }
+ }
+
+ .status {
+ background-color: $white;
+ box-shadow: inset 0 0 0 2px $supernova;
+ position: absolute;
+ top: 5px;
+ left: -6px;
+ overflow: hidden;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ width: 7px;
+ height: 7px;
+ border: 2px solid $white;
+ border-radius: 80px;
+ box-sizing: content-box;
+ }
}
.chat-header {
@@ -86,7 +121,7 @@
padding-right: 18px;
img {
- border: 3px solid white;
+ border: 3px solid $white;
border-radius: 4px;
}
}
@@ -97,7 +132,7 @@
overflow: hidden;
display: inline-block;
max-width: 100%;
- color: white;
+ color: $white;
font-size: 24px;
line-height: 40px;
font-weight: 300;
@@ -105,7 +140,7 @@
}
.chat-user-avatar {
- border-left: 1px solid rgba(0, 0, 0, 0.1);
+ border-left: 1px solid $trans-black1;
padding: 8px 0 8px 19px;
margin-right: 19px;
}
@@ -129,7 +164,7 @@
overflow-y: auto;
flex-grow: 1;
flex-shrink: 1;
- background-color: #fdfdfd;
+ background-color: $romance;
.chat-item {
transition: background-color 0.2s linear;
@@ -337,7 +372,7 @@
.token.important,
.token.bold {
- font-weight: bold;
+ font-weight: 600;
}
.token.italic {
@@ -352,7 +387,7 @@
.chat-input {
align-self: flex-end;
- background-color: #fdfdfd;
+ background-color: $romance;
flex-shrink: 0;
width: 100%;
border-top: 1px solid rgba(0, 0, 0, 0.05);
@@ -379,11 +414,11 @@
min-height: 44px;
margin: 0;
padding: 0;
- background-color: #fff;
+ background-color: $white;
box-shadow: none;
border: 0;
outline: none;
- color: black;
+ color: $black;
font-size: 1em;
line-height: 1.38em;
resize: none;
@@ -393,10 +428,11 @@
position: absolute;
right: 0;
top: 0;
- height: 50px;
+ height: 42px;
background-color: $maroon;
- color: white;
+ color: $white;
border-radius: 4px;
+ margin-right: 4px;
border: 0;
}
}
@@ -412,8 +448,8 @@
text-decoration: none;
border: none;
border-radius: 6px;
- background: #ea9448;
- color: #fff;
+ background: $sea-buckthorn;
+ color: $white;
-webkit-flex-shrink: 0;
-ms-flex-negative: 0;
flex-shrink: 0;
@@ -427,11 +463,11 @@
box-sizing: border-box;
display: inline-block;
padding: 9.6px 42px;
- background-color: #46bc99;
+ background-color: $puerto-rico;
border: none;
border-radius: 6px;
outline: none;
- color: #ffffff;
+ color: $white;
text-transform: uppercase;
letter-spacing: 0.1em;
text-align: center;
diff --git a/src/client/components/chatmenu/ChatMenu.jsx b/src/client/components/chatmenu/ChatMenu.jsx
index a482377..e6da959 100644
--- a/src/client/components/chatmenu/ChatMenu.jsx
+++ b/src/client/components/chatmenu/ChatMenu.jsx
@@ -1,5 +1,6 @@
import React from 'react';
import { connect } from 'react-redux';
+import { Link } from 'react-router';
import {
openCreateRoomModal,
closeModal,
@@ -26,7 +27,8 @@ export class ChatMenu extends React.Component {
}));
}
handleMouseLeave(e) {
- if (e.clientX < 74) return; // ignore leaving to minibar
+ /* istanbul ignore next: ignore leaving to minibar */
+ if (e.clientX < 74) return;
this.toggleActive();
}
handleMinibarButtonClick() {
@@ -39,9 +41,14 @@ export class ChatMenu extends React.Component {