mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1178391 - Fix all warnings in Loop shared test suite. r=Standard8
This commit is contained in:
parent
8df935fa96
commit
d3ea3030c5
@ -43,7 +43,6 @@ var inChrome = typeof Components != "undefined" && "utils" in Components;
|
||||
* @param {Object}
|
||||
*/
|
||||
function setRootObject(obj) {
|
||||
console.log("loop.crpyto.mixins: rootObject set to " + obj);
|
||||
rootObject = obj;
|
||||
}
|
||||
|
||||
|
@ -283,6 +283,7 @@ loop.shared.views = (function(_, mozL10n) {
|
||||
|
||||
propTypes: {
|
||||
audio: React.PropTypes.object,
|
||||
dispatcher: React.PropTypes.instanceOf(loop.Dispatcher).isRequired,
|
||||
initiate: React.PropTypes.bool,
|
||||
isDesktop: React.PropTypes.bool,
|
||||
model: React.PropTypes.object.isRequired,
|
||||
@ -482,6 +483,7 @@ loop.shared.views = (function(_, mozL10n) {
|
||||
),
|
||||
React.createElement(ConversationToolbar, {
|
||||
audio: this.state.audio,
|
||||
dispatcher: this.props.dispatcher,
|
||||
hangup: this.hangup,
|
||||
publishStream: this.publishStream,
|
||||
video: this.state.video})
|
||||
@ -498,7 +500,6 @@ loop.shared.views = (function(_, mozL10n) {
|
||||
mixins: [Backbone.Events],
|
||||
|
||||
propTypes: {
|
||||
key: React.PropTypes.number.isRequired,
|
||||
notification: React.PropTypes.object.isRequired
|
||||
},
|
||||
|
||||
@ -506,8 +507,7 @@ loop.shared.views = (function(_, mozL10n) {
|
||||
var notification = this.props.notification;
|
||||
return (
|
||||
React.createElement("div", {className: "notificationContainer"},
|
||||
React.createElement("div", {className: "alert alert-" + notification.get("level"),
|
||||
key: this.props.key},
|
||||
React.createElement("div", {className: "alert alert-" + notification.get("level")},
|
||||
React.createElement("span", {className: "message"}, notification.get("message"))
|
||||
),
|
||||
React.createElement("div", {className: "detailsBar details-" + notification.get("level"),
|
||||
@ -571,7 +571,6 @@ loop.shared.views = (function(_, mozL10n) {
|
||||
this.props.notifications.map(function(notification, key) {
|
||||
return React.createElement(NotificationView, {key: key, notification: notification});
|
||||
})
|
||||
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -283,6 +283,7 @@ loop.shared.views = (function(_, mozL10n) {
|
||||
|
||||
propTypes: {
|
||||
audio: React.PropTypes.object,
|
||||
dispatcher: React.PropTypes.instanceOf(loop.Dispatcher).isRequired,
|
||||
initiate: React.PropTypes.bool,
|
||||
isDesktop: React.PropTypes.bool,
|
||||
model: React.PropTypes.object.isRequired,
|
||||
@ -482,6 +483,7 @@ loop.shared.views = (function(_, mozL10n) {
|
||||
</div>
|
||||
<ConversationToolbar
|
||||
audio={this.state.audio}
|
||||
dispatcher={this.props.dispatcher}
|
||||
hangup={this.hangup}
|
||||
publishStream={this.publishStream}
|
||||
video={this.state.video} />
|
||||
@ -498,7 +500,6 @@ loop.shared.views = (function(_, mozL10n) {
|
||||
mixins: [Backbone.Events],
|
||||
|
||||
propTypes: {
|
||||
key: React.PropTypes.number.isRequired,
|
||||
notification: React.PropTypes.object.isRequired
|
||||
},
|
||||
|
||||
@ -506,8 +507,7 @@ loop.shared.views = (function(_, mozL10n) {
|
||||
var notification = this.props.notification;
|
||||
return (
|
||||
<div className="notificationContainer">
|
||||
<div className={"alert alert-" + notification.get("level")}
|
||||
key={this.props.key}>
|
||||
<div className={"alert alert-" + notification.get("level")}>
|
||||
<span className="message">{notification.get("message")}</span>
|
||||
</div>
|
||||
<div className={"detailsBar details-" + notification.get("level")}
|
||||
@ -567,11 +567,10 @@ loop.shared.views = (function(_, mozL10n) {
|
||||
|
||||
render: function() {
|
||||
return (
|
||||
<div className="messages">{
|
||||
this.props.notifications.map(function(notification, key) {
|
||||
return <NotificationView key={key} notification={notification}/>;
|
||||
})
|
||||
}
|
||||
<div className="messages">
|
||||
{this.props.notifications.map(function(notification, key) {
|
||||
return <NotificationView key={key} notification={notification} />;
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -580,6 +580,7 @@ loop.webapp = (function($, _, OT, mozL10n) {
|
||||
propTypes: {
|
||||
conversation: React.PropTypes.instanceOf(sharedModels.ConversationModel)
|
||||
.isRequired,
|
||||
dispatcher: React.PropTypes.instanceOf(loop.Dispatcher).isRequired,
|
||||
onAfterFeedbackReceived: React.PropTypes.func.isRequired,
|
||||
sdk: React.PropTypes.object.isRequired
|
||||
},
|
||||
@ -594,6 +595,7 @@ loop.webapp = (function($, _, OT, mozL10n) {
|
||||
onAfterFeedbackReceived: this.props.onAfterFeedbackReceived}),
|
||||
React.createElement(sharedViews.ConversationView, {
|
||||
audio: {enabled: false, visible: false},
|
||||
dispatcher: this.props.dispatcher,
|
||||
initiate: false,
|
||||
model: this.props.conversation,
|
||||
sdk: this.props.sdk,
|
||||
@ -721,6 +723,7 @@ loop.webapp = (function($, _, OT, mozL10n) {
|
||||
currentStatus: mozL10n.get("status_in_conversation")});
|
||||
return (
|
||||
React.createElement(sharedViews.ConversationView, {
|
||||
dispatcher: this.props.dispatcher,
|
||||
initiate: true,
|
||||
model: this.props.conversation,
|
||||
sdk: this.props.sdk,
|
||||
@ -731,6 +734,7 @@ loop.webapp = (function($, _, OT, mozL10n) {
|
||||
return (
|
||||
React.createElement(EndedConversationView, {
|
||||
conversation: this.props.conversation,
|
||||
dispatcher: this.props.dispatcher,
|
||||
onAfterFeedbackReceived: this.resetCallStatus(),
|
||||
sdk: this.props.sdk})
|
||||
);
|
||||
|
@ -580,6 +580,7 @@ loop.webapp = (function($, _, OT, mozL10n) {
|
||||
propTypes: {
|
||||
conversation: React.PropTypes.instanceOf(sharedModels.ConversationModel)
|
||||
.isRequired,
|
||||
dispatcher: React.PropTypes.instanceOf(loop.Dispatcher).isRequired,
|
||||
onAfterFeedbackReceived: React.PropTypes.func.isRequired,
|
||||
sdk: React.PropTypes.object.isRequired
|
||||
},
|
||||
@ -594,6 +595,7 @@ loop.webapp = (function($, _, OT, mozL10n) {
|
||||
onAfterFeedbackReceived={this.props.onAfterFeedbackReceived} />
|
||||
<sharedViews.ConversationView
|
||||
audio={{enabled: false, visible: false}}
|
||||
dispatcher={this.props.dispatcher}
|
||||
initiate={false}
|
||||
model={this.props.conversation}
|
||||
sdk={this.props.sdk}
|
||||
@ -721,6 +723,7 @@ loop.webapp = (function($, _, OT, mozL10n) {
|
||||
currentStatus: mozL10n.get("status_in_conversation")});
|
||||
return (
|
||||
<sharedViews.ConversationView
|
||||
dispatcher={this.props.dispatcher}
|
||||
initiate={true}
|
||||
model={this.props.conversation}
|
||||
sdk={this.props.sdk}
|
||||
@ -731,6 +734,7 @@ loop.webapp = (function($, _, OT, mozL10n) {
|
||||
return (
|
||||
<EndedConversationView
|
||||
conversation={this.props.conversation}
|
||||
dispatcher={this.props.dispatcher}
|
||||
onAfterFeedbackReceived={this.resetCallStatus()}
|
||||
sdk={this.props.sdk} />
|
||||
);
|
||||
|
@ -20,6 +20,7 @@ describe("loop.store.ActiveRoomStore", function () {
|
||||
|
||||
dispatcher = new loop.Dispatcher();
|
||||
sandbox.stub(dispatcher, "dispatch");
|
||||
sandbox.stub(window, "close");
|
||||
|
||||
fakeMozLoop = {
|
||||
setLoopPref: sinon.stub(),
|
||||
@ -1252,6 +1253,15 @@ describe("loop.store.ActiveRoomStore", function () {
|
||||
store.setStoreState({
|
||||
screenSharingState: SCREEN_SHARE_STATES.ACTIVE
|
||||
});
|
||||
|
||||
// Stub to prevent errors surfacing in the console.
|
||||
sandbox.stub(window.console, "error");
|
||||
});
|
||||
|
||||
it("should log an error in the console", function() {
|
||||
listener(new Error("foo"));
|
||||
|
||||
sinon.assert.calledOnce(console.error);
|
||||
});
|
||||
|
||||
it("should update the SDK driver when a new window id is received", function() {
|
||||
@ -1581,6 +1591,24 @@ describe("loop.store.ActiveRoomStore", function () {
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
it("should call close window", function() {
|
||||
var fakeRoomData = {
|
||||
decryptedContext: {
|
||||
description: "fakeDescription",
|
||||
roomName: "fakeName",
|
||||
urls: {
|
||||
fake: "url"
|
||||
}
|
||||
},
|
||||
roomOwner: "you",
|
||||
roomUrl: "original"
|
||||
};
|
||||
|
||||
fakeMozLoop.rooms.on.callArgWith(1, "update", fakeRoomData);
|
||||
|
||||
sinon.assert.calledOnce(window.close);
|
||||
});
|
||||
});
|
||||
|
||||
describe("delete:{roomToken}", function() {
|
||||
|
@ -397,6 +397,8 @@ describe("loop.store.ConversationStore", function () {
|
||||
new sharedActions.ConnectCall({sessionData: fakeSessionData}));
|
||||
|
||||
sandbox.stub(dispatcher, "dispatch");
|
||||
// This is already covered by a test. Stub just prevents console msgs.
|
||||
sandbox.stub(window.console, "error");
|
||||
});
|
||||
|
||||
it("should dispatch a connection progress action on success", function(done) {
|
||||
@ -521,6 +523,7 @@ describe("loop.store.ConversationStore", function () {
|
||||
describe("server response handling", function() {
|
||||
beforeEach(function() {
|
||||
sandbox.stub(dispatcher, "dispatch");
|
||||
sandbox.stub(window.console, "error");
|
||||
});
|
||||
|
||||
it("should dispatch a connect call action on success", function() {
|
||||
@ -692,6 +695,7 @@ describe("loop.store.ConversationStore", function () {
|
||||
|
||||
describe("WebSocket connection result", function() {
|
||||
beforeEach(function() {
|
||||
sandbox.stub(window.console, "error");
|
||||
store.connectCall(
|
||||
new sharedActions.ConnectCall({sessionData: fakeSessionData}));
|
||||
|
||||
@ -715,6 +719,18 @@ describe("loop.store.ConversationStore", function () {
|
||||
});
|
||||
});
|
||||
|
||||
it("should log an error when connection fails", function(done) {
|
||||
rejectConnectPromise();
|
||||
|
||||
connectPromise.then(function() {
|
||||
done(new Error("Promise not reject"));
|
||||
}, function() {
|
||||
checkFailures(done, function() {
|
||||
sinon.assert.calledOnce(console.error);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("should dispatch a connection failure action on failure", function(done) {
|
||||
rejectConnectPromise();
|
||||
|
||||
@ -993,6 +1009,17 @@ describe("loop.store.ConversationStore", function () {
|
||||
});
|
||||
|
||||
describe("#setMute", function() {
|
||||
beforeEach(function() {
|
||||
dispatcher.dispatch(
|
||||
// Setup store to prevent console warnings.
|
||||
new sharedActions.SetupWindowData({
|
||||
windowId: "123456",
|
||||
type: "outgoing",
|
||||
contact: contact,
|
||||
callType: sharedUtils.CALL_TYPES.AUDIO_VIDEO
|
||||
}));
|
||||
});
|
||||
|
||||
it("should save the mute state for the audio stream", function() {
|
||||
store.setStoreState({"audioMuted": false});
|
||||
|
||||
|
@ -96,7 +96,7 @@
|
||||
|
||||
describe("Unexpected Warnings Check", function() {
|
||||
it("should long only the warnings we expect", function() {
|
||||
chai.expect(caughtWarnings.length).to.eql(73);
|
||||
chai.expect(caughtWarnings.length).to.eql(0);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -380,6 +380,10 @@ describe("loop.OTSdkDriver", function () {
|
||||
});
|
||||
|
||||
describe("On connection complete", function() {
|
||||
beforeEach(function() {
|
||||
sandbox.stub(window.console, "error");
|
||||
});
|
||||
|
||||
it("should publish the stream if the publisher is ready", function() {
|
||||
driver._publisherReady = true;
|
||||
session.connect.callsArg(2);
|
||||
@ -408,6 +412,21 @@ describe("loop.OTSdkDriver", function () {
|
||||
}));
|
||||
});
|
||||
|
||||
it("should log an error message and error object", function() {
|
||||
session.connect.callsArgWith(2, {
|
||||
title: "Fake",
|
||||
code: OT.ExceptionCodes.CONNECT_FAILED
|
||||
});
|
||||
|
||||
driver.connectSession(sessionData);
|
||||
|
||||
sinon.assert.calledOnce(console.error);
|
||||
sinon.assert.calledWithExactly(console.error, sinon.match.string, {
|
||||
title: "Fake",
|
||||
code: OT.ExceptionCodes.CONNECT_FAILED
|
||||
});
|
||||
});
|
||||
|
||||
it("should dispatch connectionFailure if connecting failed", function() {
|
||||
session.connect.callsArgWith(2, new Error("Failure"));
|
||||
|
||||
|
@ -143,7 +143,11 @@ describe("loop.shared.views.TextChatView", function () {
|
||||
|
||||
it("should not render a timestamp", function() {
|
||||
view = mountTestComponent({
|
||||
showTimestamp: false
|
||||
showTimestamp: false,
|
||||
timestamp: "2015-06-23T22:48:39.738Z",
|
||||
type: CHAT_MESSAGE_TYPES.RECEIVED,
|
||||
contentType: CHAT_CONTENT_TYPES.TEXT,
|
||||
message: "foo"
|
||||
});
|
||||
var node = view.getDOMNode();
|
||||
|
||||
@ -152,7 +156,11 @@ describe("loop.shared.views.TextChatView", function () {
|
||||
|
||||
it("should render a timestamp", function() {
|
||||
view = mountTestComponent({
|
||||
showTimestamp: true
|
||||
showTimestamp: true,
|
||||
timestamp: "2015-06-23T22:48:39.738Z",
|
||||
type: CHAT_MESSAGE_TYPES.RECEIVED,
|
||||
contentType: CHAT_CONTENT_TYPES.TEXT,
|
||||
message: "foo"
|
||||
});
|
||||
var node = view.getDOMNode();
|
||||
|
||||
@ -248,7 +256,7 @@ describe("loop.shared.views.TextChatView", function () {
|
||||
type: CHAT_MESSAGE_TYPES.RECEIVED,
|
||||
contentType: CHAT_CONTENT_TYPES.TEXT,
|
||||
message: "Is it me you're looking for?",
|
||||
sentTimestamp: "2015-06-25T17:53:55.357Z"
|
||||
receivedTimestamp: "2015-06-25T17:53:55.357Z"
|
||||
}]
|
||||
});
|
||||
node = view.getDOMNode();
|
||||
@ -259,22 +267,29 @@ describe("loop.shared.views.TextChatView", function () {
|
||||
});
|
||||
|
||||
describe("TextChatView", function() {
|
||||
var view;
|
||||
var view, fakeServer;
|
||||
|
||||
function mountTestComponent(extraProps) {
|
||||
var props = _.extend({
|
||||
dispatcher: dispatcher,
|
||||
showRoomName: false,
|
||||
useDesktopPaths: false
|
||||
useDesktopPaths: false,
|
||||
showAlways: true
|
||||
}, extraProps);
|
||||
return TestUtils.renderIntoDocument(
|
||||
React.createElement(loop.shared.views.chat.TextChatView, props));
|
||||
}
|
||||
|
||||
beforeEach(function() {
|
||||
// Fake server to catch all XHR requests.
|
||||
fakeServer = sinon.fakeServer.create();
|
||||
store.setStoreState({ textChatEnabled: true });
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
fakeServer.restore();
|
||||
});
|
||||
|
||||
it("should show timestamps from msgs sent more than 1 min apart", function() {
|
||||
view = mountTestComponent();
|
||||
|
||||
@ -358,7 +373,7 @@ describe("loop.shared.views.TextChatView", function () {
|
||||
store.sendTextChatMessage({
|
||||
contentType: CHAT_CONTENT_TYPES.TEXT,
|
||||
message: "Foo",
|
||||
timestamp: 0
|
||||
sentTimestamp: "2015-06-25T17:53:55.357Z"
|
||||
});
|
||||
|
||||
expect(node.querySelector(".sent")).to.not.eql(null);
|
||||
|
@ -313,6 +313,11 @@ describe("loop.shared.utils", function() {
|
||||
});
|
||||
|
||||
describe("#formatURL", function() {
|
||||
beforeEach(function() {
|
||||
// Stub to prevent console messages.
|
||||
sandbox.stub(window.console, "error");
|
||||
});
|
||||
|
||||
it("should decode encoded URIs", function() {
|
||||
expect(sharedUtils.formatURL("http://invalid.com/?a=Foo%20Bar"))
|
||||
.eql({
|
||||
@ -335,6 +340,12 @@ describe("loop.shared.utils", function() {
|
||||
it("should return null if it the url is not valid", function() {
|
||||
expect(sharedUtils.formatURL("hinvalid//url")).eql(null);
|
||||
});
|
||||
|
||||
it("should log an error message to the console", function() {
|
||||
sharedUtils.formatURL("hinvalid//url");
|
||||
|
||||
sinon.assert.calledOnce(console.error);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#composeCallUrlEmail", function() {
|
||||
@ -365,6 +376,8 @@ describe("loop.shared.utils", function() {
|
||||
composeEmail: composeEmail,
|
||||
telemetryAddValue: telemetryAddValue
|
||||
};
|
||||
|
||||
sandbox.stub(window.console, "error");
|
||||
});
|
||||
|
||||
it("should compose a call url email", function() {
|
||||
@ -388,6 +401,12 @@ describe("loop.shared.utils", function() {
|
||||
|
||||
sinon.assert.calledOnce(telemetryAddValue, "LOOP_SHARING_ROOM_URL", 2);
|
||||
});
|
||||
|
||||
it("should log an error for invalid URLs", function() {
|
||||
sharedUtils.composeCallUrlEmail("http://invalid", "fake@invalid.tld");
|
||||
|
||||
sinon.assert.calledOnce(console.error);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#btoa", function() {
|
||||
|
@ -88,7 +88,7 @@
|
||||
|
||||
describe("Unexpected Warnings Check", function() {
|
||||
it("should long only the warnings we expect", function() {
|
||||
chai.expect(caughtWarnings.length).to.eql(33);
|
||||
chai.expect(caughtWarnings.length).to.eql(15);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -1068,6 +1068,7 @@ describe("loop.webapp", function() {
|
||||
React.createElement(
|
||||
loop.webapp.EndedConversationView, {
|
||||
conversation: conversation,
|
||||
dispatcher: dispatcher,
|
||||
sdk: {},
|
||||
onAfterFeedbackReceived: function(){}
|
||||
}));
|
||||
|
@ -1315,7 +1315,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 = 28;
|
||||
var expectedWarningsCount = 24;
|
||||
var warningsMismatch = caughtWarnings.length !== expectedWarningsCount;
|
||||
if (uncaughtError || warningsMismatch) {
|
||||
$("#results").append("<div class='failures'><em>" +
|
||||
|
@ -1315,7 +1315,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 = 28;
|
||||
var expectedWarningsCount = 24;
|
||||
var warningsMismatch = caughtWarnings.length !== expectedWarningsCount;
|
||||
if (uncaughtError || warningsMismatch) {
|
||||
$("#results").append("<div class='failures'><em>" +
|
||||
|
Loading…
Reference in New Issue
Block a user