Bug 1171940: update/ fix tests that my patches above have broken and lower the total amount of warnings generated by React in the console. r=Standard8

This commit is contained in:
Mike de Boer 2015-07-03 19:00:30 +02:00
parent 75dd81e809
commit 9ee1b247a1
21 changed files with 164 additions and 236 deletions

View File

@ -129,7 +129,9 @@ loop.contacts = (function(_, mozL10n) {
});
return (
React.createElement("div", {className: "contacts-gravatar-promo"},
React.createElement(Button, {additionalClass: "button-close", onClick: this.handleCloseButtonClick}),
React.createElement(Button, {additionalClass: "button-close",
caption: "",
onClick: this.handleCloseButtonClick}),
React.createElement("p", {dangerouslySetInnerHTML: {__html: message},
onClick: this.handleLinkClick}),
React.createElement(ButtonGroup, null,

View File

@ -129,7 +129,9 @@ loop.contacts = (function(_, mozL10n) {
});
return (
<div className="contacts-gravatar-promo">
<Button additionalClass="button-close" onClick={this.handleCloseButtonClick}/>
<Button additionalClass="button-close"
caption=""
onClick={this.handleCloseButtonClick} />
<p dangerouslySetInnerHTML={{__html: message}}
onClick={this.handleLinkClick}></p>
<ButtonGroup>

View File

@ -659,6 +659,7 @@ loop.conversationViews = (function(mozL10n) {
React.createElement("div", {className: "video_wrapper remote_wrapper"},
React.createElement("div", {className: "video_inner remote focus-stream"},
React.createElement(sharedViews.MediaView, {displayAvatar: !this.shouldRenderRemoteVideo(),
isLoading: false,
mediaType: "remote",
posterUrl: this.props.remotePosterUrl,
srcVideoObject: this.state.remoteSrcVideoObject})
@ -666,6 +667,7 @@ loop.conversationViews = (function(mozL10n) {
),
React.createElement("div", {className: localStreamClasses},
React.createElement(sharedViews.MediaView, {displayAvatar: !this.props.video.enabled,
isLoading: false,
mediaType: "local",
posterUrl: this.props.localPosterUrl,
srcVideoObject: this.state.localSrcVideoObject})

View File

@ -659,6 +659,7 @@ loop.conversationViews = (function(mozL10n) {
<div className="video_wrapper remote_wrapper">
<div className="video_inner remote focus-stream">
<sharedViews.MediaView displayAvatar={!this.shouldRenderRemoteVideo()}
isLoading={false}
mediaType="remote"
posterUrl={this.props.remotePosterUrl}
srcVideoObject={this.state.remoteSrcVideoObject} />
@ -666,6 +667,7 @@ loop.conversationViews = (function(mozL10n) {
</div>
<div className={localStreamClasses}>
<sharedViews.MediaView displayAvatar={!this.props.video.enabled}
isLoading={false}
mediaType="local"
posterUrl={this.props.localPosterUrl}
srcVideoObject={this.state.localSrcVideoObject} />

View File

@ -285,8 +285,6 @@ loop.roomViews = (function(mozL10n) {
mixins: [React.addons.LinkedStateMixin],
propTypes: {
// Only used for tests.
availableContext: React.PropTypes.object,
dispatcher: React.PropTypes.instanceOf(loop.Dispatcher).isRequired,
error: React.PropTypes.object,
mozLoop: React.PropTypes.object.isRequired,
@ -354,7 +352,7 @@ loop.roomViews = (function(mozL10n) {
var url = this._getURL();
return {
// `availableContext` prop only used in tests.
availableContext: this.props.availableContext,
availableContext: null,
show: this.props.show,
newRoomName: this.props.roomData.roomName || "",
newRoomURL: url && url.location || "",
@ -670,9 +668,9 @@ loop.roomViews = (function(mozL10n) {
* @private
*/
_shouldRenderRemoteLoading: function() {
return this.state.roomState === ROOM_STATES.HAS_PARTICIPANTS &&
!this.state.remoteSrcVideoObject &&
!this.state.mediaConnected;
return !!(this.state.roomState === ROOM_STATES.HAS_PARTICIPANTS &&
!this.state.remoteSrcVideoObject &&
!this.state.mediaConnected);
},
handleAddContextClick: function() {
@ -700,7 +698,7 @@ loop.roomViews = (function(mozL10n) {
});
var screenShareData = {
state: this.state.screenSharingState,
state: this.state.screenSharingState || SCREEN_SHARE_STATES.INACTIVE,
visible: true
};

View File

@ -285,8 +285,6 @@ loop.roomViews = (function(mozL10n) {
mixins: [React.addons.LinkedStateMixin],
propTypes: {
// Only used for tests.
availableContext: React.PropTypes.object,
dispatcher: React.PropTypes.instanceOf(loop.Dispatcher).isRequired,
error: React.PropTypes.object,
mozLoop: React.PropTypes.object.isRequired,
@ -354,7 +352,7 @@ loop.roomViews = (function(mozL10n) {
var url = this._getURL();
return {
// `availableContext` prop only used in tests.
availableContext: this.props.availableContext,
availableContext: null,
show: this.props.show,
newRoomName: this.props.roomData.roomName || "",
newRoomURL: url && url.location || "",
@ -670,9 +668,9 @@ loop.roomViews = (function(mozL10n) {
* @private
*/
_shouldRenderRemoteLoading: function() {
return this.state.roomState === ROOM_STATES.HAS_PARTICIPANTS &&
!this.state.remoteSrcVideoObject &&
!this.state.mediaConnected;
return !!(this.state.roomState === ROOM_STATES.HAS_PARTICIPANTS &&
!this.state.remoteSrcVideoObject &&
!this.state.mediaConnected);
},
handleAddContextClick: function() {
@ -700,7 +698,7 @@ loop.roomViews = (function(mozL10n) {
});
var screenShareData = {
state: this.state.screenSharingState,
state: this.state.screenSharingState || SCREEN_SHARE_STATES.INACTIVE,
visible: true
};

View File

@ -323,7 +323,7 @@ loop.shared.views = (function(_, l10n) {
};
}
this.listenTo(this.props.sdk, "exception", this._handleSdkException.bind(this));
this.listenTo(this.props.sdk, "exception", this._handleSdkException);
this.listenTo(this.props.model, "session:connected",
this._onSessionConnected);
@ -425,14 +425,14 @@ loop.shared.views = (function(_, l10n) {
audio: {enabled: ev.stream.hasAudio},
video: {enabled: ev.stream.hasVideo}
});
}.bind(this));
});
this.listenTo(this.publisher, "streamDestroyed", function() {
this.setState({
audio: {enabled: false},
video: {enabled: false}
});
}.bind(this));
});
this.props.model.publish(this.publisher);
},
@ -542,7 +542,7 @@ loop.shared.views = (function(_, l10n) {
componentDidMount: function() {
this.listenTo(this.props.notifications, "reset add remove", function() {
this.forceUpdate();
}.bind(this));
});
},
componentWillUnmount: function() {

View File

@ -323,7 +323,7 @@ loop.shared.views = (function(_, l10n) {
};
}
this.listenTo(this.props.sdk, "exception", this._handleSdkException.bind(this));
this.listenTo(this.props.sdk, "exception", this._handleSdkException);
this.listenTo(this.props.model, "session:connected",
this._onSessionConnected);
@ -425,14 +425,14 @@ loop.shared.views = (function(_, l10n) {
audio: {enabled: ev.stream.hasAudio},
video: {enabled: ev.stream.hasVideo}
});
}.bind(this));
});
this.listenTo(this.publisher, "streamDestroyed", function() {
this.setState({
audio: {enabled: false},
video: {enabled: false}
});
}.bind(this));
});
this.props.model.publish(this.publisher);
},
@ -542,7 +542,7 @@ loop.shared.views = (function(_, l10n) {
componentDidMount: function() {
this.listenTo(this.props.notifications, "reset add remove", function() {
this.forceUpdate();
}.bind(this));
});
},
componentWillUnmount: function() {

View File

@ -394,9 +394,9 @@ loop.standaloneRoomViews = (function(mozL10n) {
* @private
*/
_shouldRenderRemoteLoading: function() {
return this.state.roomState === ROOM_STATES.HAS_PARTICIPANTS &&
!this.state.remoteSrcVideoObject &&
!this.state.mediaConnected;
return !!(this.state.roomState === ROOM_STATES.HAS_PARTICIPANTS &&
!this.state.remoteSrcVideoObject &&
!this.state.mediaConnected);
},
/**

View File

@ -394,9 +394,9 @@ loop.standaloneRoomViews = (function(mozL10n) {
* @private
*/
_shouldRenderRemoteLoading: function() {
return this.state.roomState === ROOM_STATES.HAS_PARTICIPANTS &&
!this.state.remoteSrcVideoObject &&
!this.state.mediaConnected;
return !!(this.state.roomState === ROOM_STATES.HAS_PARTICIPANTS &&
!this.state.remoteSrcVideoObject &&
!this.state.mediaConnected);
},
/**

View File

@ -146,7 +146,8 @@ describe("loop.contacts", function() {
it("should show the gravatars promo box", function() {
listView = TestUtils.renderIntoDocument(
React.createElement(loop.contacts.ContactsList, {
notifications: notifications
notifications: notifications,
startForm: function() {}
}));
var promo = listView.getDOMNode().querySelector(".contacts-gravatar-promo");
@ -166,7 +167,8 @@ describe("loop.contacts", function() {
};
listView = TestUtils.renderIntoDocument(
React.createElement(loop.contacts.ContactsList, {
notifications: notifications
notifications: notifications,
startForm: function() {}
}));
var promo = listView.getDOMNode().querySelector(".contacts-gravatar-promo");
@ -178,7 +180,8 @@ describe("loop.contacts", function() {
it("should hide the gravatars promo box when the 'use' button is clicked", function() {
listView = TestUtils.renderIntoDocument(
React.createElement(loop.contacts.ContactsList, {
notifications: notifications
notifications: notifications,
startForm: function() {}
}));
React.addons.TestUtils.Simulate.click(listView.getDOMNode().querySelector(
@ -193,7 +196,8 @@ describe("loop.contacts", function() {
it("should should set the prefs correctly when the 'use' button is clicked", function() {
listView = TestUtils.renderIntoDocument(
React.createElement(loop.contacts.ContactsList, {
notifications: notifications
notifications: notifications,
startForm: function() {}
}));
React.addons.TestUtils.Simulate.click(listView.getDOMNode().querySelector(
@ -207,7 +211,8 @@ describe("loop.contacts", function() {
it("should hide the gravatars promo box when the 'close' button is clicked", function() {
listView = TestUtils.renderIntoDocument(
React.createElement(loop.contacts.ContactsList, {
notifications: notifications
notifications: notifications,
startForm: function() {}
}));
React.addons.TestUtils.Simulate.click(listView.getDOMNode().querySelector(
@ -220,7 +225,8 @@ describe("loop.contacts", function() {
it("should set prefs correctly when the 'close' button is clicked", function() {
listView = TestUtils.renderIntoDocument(
React.createElement(loop.contacts.ContactsList, {
notifications: notifications
notifications: notifications,
startForm: function() {}
}));
React.addons.TestUtils.Simulate.click(listView.getDOMNode().querySelector(
@ -242,7 +248,8 @@ describe("loop.contacts", function() {
listView = TestUtils.renderIntoDocument(
React.createElement(loop.contacts.ContactsList, {
notifications: notifications
notifications: notifications,
startForm: function() {}
}));
});
@ -299,8 +306,10 @@ describe("loop.contacts", function() {
beforeEach(function() {
view = TestUtils.renderIntoDocument(
React.createElement(
loop.contacts.ContactDetailsForm, {mode: "add"}));
React.createElement(loop.contacts.ContactDetailsForm, {
mode: "add",
selectTab: function() {}
}));
});
it("should render 'add' header", function() {
@ -409,8 +418,10 @@ describe("loop.contacts", function() {
beforeEach(function() {
view = TestUtils.renderIntoDocument(
React.createElement(
loop.contacts.ContactDetailsForm, {mode: "edit"}));
React.createElement(loop.contacts.ContactDetailsForm, {
mode: "edit",
selectTab: function() {}
}));
});
it("should render 'edit' header", function() {

View File

@ -46,7 +46,10 @@ describe("loop.conversation", function() {
},
getAudioBlob: sinon.spy(function(name, callback) {
callback(null, new Blob([new ArrayBuffer(10)], {type: "audio/ogg"}));
})
}),
getSelectedTabMetadata: function(callback) {
callback({});
}
};
fakeWindow = {

View File

@ -97,7 +97,7 @@
describe("Unexpected Warnings Check", function() {
it("should long only the warnings we expect", function() {
chai.expect(caughtWarnings.length).to.eql(128);
chai.expect(caughtWarnings.length).to.eql(30);
});
});

View File

@ -778,7 +778,7 @@ describe("loop.panel", function() {
"conversation button",
function() {
navigator.mozLoop.userProfile = {email: fakeEmail};
var view = createTestComponent();
var view = createTestComponent(false);
TestUtils.Simulate.click(view.getDOMNode().querySelector(".new-room-button"));
@ -801,7 +801,7 @@ describe("loop.panel", function() {
});
};
var view = createTestComponent();
var view = createTestComponent(false);
// Simulate being visible
view.onDocumentVisible();
@ -841,7 +841,7 @@ describe("loop.panel", function() {
});
};
var view = createTestComponent();
var view = createTestComponent(false);
// Simulate being visible
view.onDocumentVisible();
@ -859,7 +859,7 @@ describe("loop.panel", function() {
});
};
var view = createTestComponent();
var view = createTestComponent(false);
view.setState({ checked: true });
@ -878,7 +878,7 @@ describe("loop.panel", function() {
});
};
var view = createTestComponent();
var view = createTestComponent(false);
// Simulate being visible
view.onDocumentVisible();
@ -896,7 +896,7 @@ describe("loop.panel", function() {
});
};
var view = createTestComponent();
var view = createTestComponent(false);
view.onDocumentVisible();
@ -913,7 +913,7 @@ describe("loop.panel", function() {
});
};
var view = createTestComponent();
var view = createTestComponent(false);
// Simulate being visible
view.onDocumentVisible();
@ -933,7 +933,7 @@ describe("loop.panel", function() {
});
};
var view = createTestComponent();
var view = createTestComponent(false);
// Simulate being visible.
view.onDocumentVisible();

View File

@ -141,8 +141,9 @@ describe("loop.roomViews", function () {
dispatcher: dispatcher,
mozLoop: fakeMozLoop,
roomData: {},
savingContext: false,
show: true,
showContext: false
showEditContext: false
}, props);
return TestUtils.renderIntoDocument(
React.createElement(loop.roomViews.DesktopRoomInvitationView, props));
@ -247,78 +248,6 @@ describe("loop.roomViews", function () {
expect(view.refs.menu.props.show).to.eql(true);
});
});
describe("Context", function() {
it("should not render the context data when told not to", function() {
view = mountTestComponent();
expect(view.getDOMNode().querySelector(".room-context")).to.eql(null);
});
it("should render context when data is available", function() {
view = mountTestComponent({
showContext: true,
roomData: {
roomContextUrls: [fakeContextURL]
}
});
expect(view.getDOMNode().querySelector(".room-context")).to.not.eql(null);
});
it("should render the context in editMode when the pencil is clicked", function() {
view = mountTestComponent({
showContext: true,
roomData: {
roomContextUrls: [fakeContextURL]
}
});
var pencil = view.getDOMNode().querySelector(".room-context-btn-edit");
expect(pencil).to.not.eql(null);
React.addons.TestUtils.Simulate.click(pencil);
expect(view.state.editMode).to.eql(true);
var node = view.getDOMNode();
expect(node.querySelector("form")).to.not.eql(null);
// No text paragraphs should be visible in editMode.
var visiblePs = Array.slice(node.querySelector("p")).filter(function(p) {
return p.classList.contains("hide") || p.classList.contains("error");
});
expect(visiblePs.length).to.eql(0);
});
it("should format the context url for display", function() {
sandbox.stub(sharedUtils, "formatURL").returns({
location: "location",
hostname: "hostname"
});
view = mountTestComponent({
showContext: true,
roomData: {
roomContextUrls: [fakeContextURL]
}
});
expect(view.getDOMNode().querySelector(".room-context-url").textContent)
.eql("hostname");
});
it("should show a default favicon when none is available", function() {
fakeContextURL.thumbnail = null;
view = mountTestComponent({
showContext: true,
roomData: {
roomContextUrls: [fakeContextURL]
}
});
expect(view.getDOMNode().querySelector(".room-context-thumbnail").src)
.to.match(/loop\/shared\/img\/icons-16x16.svg#globe$/);
});
});
});
describe("DesktopRoomConversationView", function() {
@ -331,6 +260,12 @@ describe("loop.roomViews", function () {
})
});
sandbox.stub(dispatcher, "dispatch");
fakeMozLoop.getLoopPref = function(prefName) {
if (prefName == "contextInConversations.enabled") {
return true;
}
return "test";
};
});
function mountTestComponent() {
@ -741,7 +676,7 @@ describe("loop.roomViews", function () {
});
});
describe("DesktopRoomContextView", function() {
describe("DesktopRoomEditContextView", function() {
var view;
afterEach(function() {
@ -759,35 +694,10 @@ describe("loop.roomViews", function () {
}
}, props);
return TestUtils.renderIntoDocument(
React.createElement(loop.roomViews.DesktopRoomContextView, props));
React.createElement(loop.roomViews.DesktopRoomEditContextView, props));
}
describe("#render", function() {
it("should show the context information properly when available", function() {
view = mountTestComponent({
roomData: {
roomDescription: "Hello, is it me you're looking for?",
roomContextUrls: [fakeContextURL]
}
});
var node = view.getDOMNode();
expect(node).to.not.eql(null);
expect(node.querySelector(".room-context-thumbnail").src).to.
eql(fakeContextURL.thumbnail);
expect(node.querySelector(".room-context-description").firstChild.textContent).
to.eql(fakeContextURL.description);
});
it("should not render optional data", function() {
view = mountTestComponent({
roomData: { roomContextUrls: [fakeContextURL] }
});
expect(view.getDOMNode().querySelector(".room-context-comment")).to.
eql(null);
});
it("should not render the component when 'show' is false", function() {
view = mountTestComponent({
show: false
@ -806,10 +716,9 @@ describe("loop.roomViews", function () {
expect(view.getDOMNode()).to.eql(null);
});
it("should render the view in editMode when appropriate", function() {
it("should render the view correctly", function() {
var roomName = "Hello, is it me you're looking for?";
view = mountTestComponent({
editMode: true,
roomData: {
roomName: roomName,
roomContextUrls: [fakeContextURL]
@ -826,7 +735,6 @@ describe("loop.roomViews", function () {
it("should show the checkbox as disabled when context is already set", function() {
view = mountTestComponent({
editMode: true,
roomData: {
roomToken: "fakeToken",
roomName: "fakeName",
@ -838,34 +746,7 @@ describe("loop.roomViews", function () {
expect(checkbox.classList.contains("disabled")).to.eql(true);
});
it("should render the editMode view when the edit button is clicked", function(done) {
var roomName = "Hello, is it me you're looking for?";
view = mountTestComponent({
roomData: {
roomToken: "fakeToken",
roomName: roomName,
roomContextUrls: [fakeContextURL]
}
});
// Switch to editMode via setting the prop, since we can control that
// better.
view.setProps({ editMode: true }, function() {
// First check if availableContext is set correctly.
expect(view.state.availableContext).to.not.eql(null);
expect(view.state.availableContext.previewImage).to.eql(favicon);
var node = view.getDOMNode();
expect(node.querySelector(".checkbox-wrapper").classList.contains("disabled")).to.eql(true);
expect(node.querySelector(".room-context-name").value).to.eql(roomName);
expect(node.querySelector(".room-context-url").value).to.eql(fakeContextURL.location);
expect(node.querySelector(".room-context-comments").value).to.eql(fakeContextURL.description);
done();
});
});
it("should hide the checkbox when no context data is stored or available", function(done) {
it("should hide the checkbox when no context data is stored or available", function() {
view = mountTestComponent({
roomData: {
roomToken: "fakeToken",
@ -873,18 +754,12 @@ describe("loop.roomViews", function () {
}
});
// Switch to editMode via setting the prop, since we can control that
// better.
view.setProps({ editMode: true }, function() {
// First check if availableContext is set correctly.
expect(view.state.availableContext).to.not.eql(null);
expect(view.state.availableContext.previewImage).to.eql(favicon);
// First check if availableContext is set correctly.
expect(view.state.availableContext).to.not.eql(null);
expect(view.state.availableContext.previewImage).to.eql(favicon);
var node = view.getDOMNode();
expect(node.querySelector(".checkbox-wrapper").classList.contains("hide")).to.eql(true);
done();
});
var node = view.getDOMNode();
expect(node.querySelector(".checkbox-wrapper").classList.contains("hide")).to.eql(true);
});
});
@ -952,8 +827,8 @@ describe("loop.roomViews", function () {
// Now simulate a successful save.
view.setProps({ savingContext: false }, function() {
// The editMode flag should be updated.
expect(view.state.editMode).to.eql(false);
// The 'show flag should be updated.
expect(view.state.show).to.eql(false);
done();
});
});
@ -964,13 +839,12 @@ describe("loop.roomViews", function () {
var node, checkbox;
beforeEach(function() {
fakeMozLoop.getSelectedTabMetadata = sinon.stub().callsArgWith(0, {
favicon: fakeContextURL.thumbnail,
title: fakeContextURL.description,
url: fakeContextURL.location
});
view = mountTestComponent({
availableContext: {
description: fakeContextURL.description,
previewImage: fakeContextURL.thumbnail,
url: fakeContextURL.location
},
editMode: true,
roomData: {
roomToken: "fakeToken",
roomName: "fakeName"

View File

@ -96,7 +96,7 @@
describe("Unexpected Warnings Check", function() {
it("should long only the warnings we expect", function() {
chai.expect(caughtWarnings.length).to.eql(180);
chai.expect(caughtWarnings.length).to.eql(73);
});
});

View File

@ -43,7 +43,8 @@ describe("loop.shared.views.TextChatView", function () {
function mountTestComponent(extraProps) {
var basicProps = {
dispatcher: dispatcher,
messageList: []
messageList: [],
useDesktopPaths: false
};
return TestUtils.renderIntoDocument(
@ -56,11 +57,13 @@ describe("loop.shared.views.TextChatView", function () {
messageList: [{
type: CHAT_MESSAGE_TYPES.RECEIVED,
contentType: CHAT_CONTENT_TYPES.TEXT,
message: "Hello!"
message: "Hello!",
receivedTimestamp: "2015-06-25T17:53:55.357Z"
}, {
type: CHAT_MESSAGE_TYPES.SENT,
contentType: CHAT_CONTENT_TYPES.TEXT,
message: "Is it me you're looking for?"
message: "Is it me you're looking for?",
sentTimestamp: "2015-06-25T17:53:55.357Z"
}]
});
@ -81,7 +84,8 @@ describe("loop.shared.views.TextChatView", function () {
messageList: [{
type: CHAT_MESSAGE_TYPES.RECEIVED,
contentType: CHAT_CONTENT_TYPES.TEXT,
message: "Hello!"
message: "Hello!",
receivedTimestamp: "2015-06-25T17:53:55.357Z"
}]
});
@ -97,7 +101,8 @@ describe("loop.shared.views.TextChatView", function () {
messageList: [{
type: CHAT_MESSAGE_TYPES.SPECIAL,
contentType: CHAT_CONTENT_TYPES.ROOM_NAME,
message: "Hello!"
message: "Hello!",
receivedTimestamp: "2015-06-25T17:53:55.357Z"
}]
});
@ -112,7 +117,8 @@ describe("loop.shared.views.TextChatView", function () {
messageList: [{
type: CHAT_MESSAGE_TYPES.SENT,
contentType: CHAT_CONTENT_TYPES.TEXT,
message: "Hello!"
message: "Hello!",
sentTimestamp: "2015-06-25T17:53:55.357Z"
}]
});
@ -125,7 +131,11 @@ describe("loop.shared.views.TextChatView", function () {
function mountTestComponent(extraProps) {
var props = _.extend({
dispatcher: dispatcher
contentType: CHAT_CONTENT_TYPES.TEXT,
dispatcher: dispatcher,
message: "test",
type: CHAT_MESSAGE_TYPES.RECEIVED,
timestamp: "2015-06-23T22:48:39.738Z"
}, extraProps);
return TestUtils.renderIntoDocument(
React.createElement(loop.shared.views.chat.TextChatEntry, props));
@ -133,8 +143,7 @@ describe("loop.shared.views.TextChatView", function () {
it("should not render a timestamp", function() {
view = mountTestComponent({
showTimestamp: false,
timestamp: "2015-06-23T22:48:39.738Z"
showTimestamp: false
});
var node = view.getDOMNode();
@ -143,8 +152,7 @@ describe("loop.shared.views.TextChatView", function () {
it("should render a timestamp", function() {
view = mountTestComponent({
showTimestamp: true,
timestamp: "2015-06-23T22:48:39.738Z"
showTimestamp: true
});
var node = view.getDOMNode();
@ -157,7 +165,9 @@ describe("loop.shared.views.TextChatView", function () {
function mountTestComponent(extraProps) {
var props = _.extend({
dispatcher: dispatcher
dispatcher: dispatcher,
messageList: [],
useDesktopPaths: false
}, extraProps);
return TestUtils.renderIntoDocument(
React.createElement(loop.shared.views.chat.TextChatEntriesView, props));
@ -172,11 +182,13 @@ describe("loop.shared.views.TextChatView", function () {
messageList: [{
type: CHAT_MESSAGE_TYPES.RECEIVED,
contentType: CHAT_CONTENT_TYPES.TEXT,
message: "Hello!"
message: "Hello!",
receivedTimestamp: "2015-06-25T17:53:55.357Z"
}, {
type: CHAT_MESSAGE_TYPES.SENT,
contentType: CHAT_CONTENT_TYPES.TEXT,
message: "Is it me you're looking for?"
message: "Is it me you're looking for?",
sentTimestamp: "2015-06-25T17:53:55.357Z"
}]
});
node = view.getDOMNode();
@ -230,11 +242,13 @@ describe("loop.shared.views.TextChatView", function () {
messageList: [{
type: CHAT_MESSAGE_TYPES.RECEIVED,
contentType: CHAT_CONTENT_TYPES.TEXT,
message: "Hello!"
message: "Hello!",
receivedTimestamp: "2015-06-25T17:53:55.357Z"
}, {
type: CHAT_MESSAGE_TYPES.RECEIVED,
contentType: CHAT_CONTENT_TYPES.TEXT,
message: "Is it me you're looking for?"
message: "Is it me you're looking for?",
sentTimestamp: "2015-06-25T17:53:55.357Z"
}]
});
node = view.getDOMNode();
@ -250,6 +264,7 @@ describe("loop.shared.views.TextChatView", function () {
function mountTestComponent(extraProps) {
var props = _.extend({
dispatcher: dispatcher,
showRoomName: false,
useDesktopPaths: false
}, extraProps);
return TestUtils.renderIntoDocument(
@ -289,15 +304,15 @@ describe("loop.shared.views.TextChatView", function () {
.to.eql(2);
});
it("should display the view if no messages and text chat not enabled", function() {
it("should not display the view if no messages and text chat not enabled", function() {
store.setStoreState({ textChatEnabled: false });
view = mountTestComponent();
expect(view.getDOMNode()).not.eql(null);
expect(view.getDOMNode()).eql(null);
});
it("should display the view if text chat is enabled", function() {
it("should display the view if no messages and text chat is enabled", function() {
view = mountTestComponent();
expect(view.getDOMNode()).not.eql(null);
@ -317,11 +332,15 @@ describe("loop.shared.views.TextChatView", function () {
store.receivedTextChatMessage({
contentType: CHAT_CONTENT_TYPES.TEXT,
message: "Hello!"
message: "Hello!",
sentTimestamp: "1970-01-01T00:03:00.000Z",
receivedTimestamp: "1970-01-01T00:03:00.000Z"
});
store.sendTextChatMessage({
contentType: CHAT_CONTENT_TYPES.TEXT,
message: "Is it me you're looking for?"
message: "Is it me you're looking for?",
sentTimestamp: "1970-01-01T00:03:00.000Z",
receivedTimestamp: "1970-01-01T00:03:00.000Z"
});
var node = view.getDOMNode();
@ -346,17 +365,18 @@ describe("loop.shared.views.TextChatView", function () {
});
it("should add `received` CSS class selector to msg of type RECEIVED",
function() {
var node = mountTestComponent().getDOMNode();
function() {
var node = mountTestComponent().getDOMNode();
store.receivedTextChatMessage({
contentType: CHAT_CONTENT_TYPES.TEXT,
message: "Foo",
timestamp: 0
});
store.receivedTextChatMessage({
contentType: CHAT_CONTENT_TYPES.TEXT,
message: "Foo",
sentTimestamp: "1970-01-01T00:03:00.000Z",
receivedTimestamp: "1970-01-01T00:03:00.000Z"
});
expect(node.querySelector(".received")).to.not.eql(null);
});
expect(node.querySelector(".received")).to.not.eql(null);
});
it("should render a room name special entry", function() {
view = mountTestComponent({

View File

@ -256,6 +256,9 @@ describe("loop.shared.views", function() {
var hangup, publishStream;
function mountTestComponent(props) {
props = _.extend({
dispatcher: dispatcher
}, props || {});
return TestUtils.renderIntoDocument(
React.createElement(sharedViews.ConversationToolbar, props));
}
@ -362,6 +365,9 @@ describe("loop.shared.views", function() {
var fakeSDK, fakeSessionData, fakeSession, fakePublisher, model, fakeAudio;
function mountTestComponent(props) {
props = _.extend({
dispatcher: dispatcher
}, props || {});
return TestUtils.renderIntoDocument(
React.createElement(sharedViews.ConversationView, props));
}
@ -676,6 +682,9 @@ describe("loop.shared.views", function() {
var coll, view, testNotif;
function mountTestComponent(props) {
props = _.extend({
key: 0
}, props || {});
return TestUtils.renderIntoDocument(
React.createElement(sharedViews.NotificationListView, props));
}
@ -831,7 +840,11 @@ describe("loop.shared.views", function() {
function mountTestComponent(extraProps) {
var props = _.extend({
dispatcher: dispatcher
allowClick: false,
description: "test",
dispatcher: dispatcher,
showContextTitle: false,
useDesktopPaths: false
}, extraProps);
return TestUtils.renderIntoDocument(
React.createElement(sharedViews.ContextUrlView, props));
@ -913,6 +926,9 @@ describe("loop.shared.views", function() {
var view;
function mountTestComponent(props) {
props = _.extend({
isLoading: false
}, props || {});
return TestUtils.renderIntoDocument(
React.createElement(sharedViews.MediaView, props));
}

View File

@ -88,7 +88,7 @@
describe("Unexpected Warnings Check", function() {
it("should long only the warnings we expect", function() {
chai.expect(caughtWarnings.length).to.eql(37);
chai.expect(caughtWarnings.length).to.eql(36);
});
});

View File

@ -1313,7 +1313,7 @@
// This simulates the mocha layout for errors which means we can run
// this alongside our other unit tests but use the same harness.
var expectedWarningsCount = 53;
var expectedWarningsCount = 29;
var warningsMismatch = caughtWarnings.length !== expectedWarningsCount;
if (uncaughtError || warningsMismatch) {
$("#results").append("<div class='failures'><em>" +

View File

@ -1313,7 +1313,7 @@
// This simulates the mocha layout for errors which means we can run
// this alongside our other unit tests but use the same harness.
var expectedWarningsCount = 53;
var expectedWarningsCount = 29;
var warningsMismatch = caughtWarnings.length !== expectedWarningsCount;
if (uncaughtError || warningsMismatch) {
$("#results").append("<div class='failures'><em>" +