mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-23 08:56:17 -04:00
tests: Invert conditions to improve readability
This commit is contained in:
parent
dd9c08d821
commit
62403159df
2 changed files with 35 additions and 46 deletions
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
helper.spyOnSocketIO = () => {
|
helper.spyOnSocketIO = () => {
|
||||||
helper.contentWindow().pad.socket.on('message', (msg) => {
|
helper.contentWindow().pad.socket.on('message', (msg) => {
|
||||||
if (msg.type === 'COLLABROOM') {
|
if (msg.type !== 'COLLABROOM') return;
|
||||||
if (msg.data.type === 'ACCEPT_COMMIT') {
|
if (msg.data.type === 'ACCEPT_COMMIT') {
|
||||||
helper.commits.push(msg);
|
helper.commits.push(msg);
|
||||||
} else if (msg.data.type === 'USER_NEWINFO') {
|
} else if (msg.data.type === 'USER_NEWINFO') {
|
||||||
|
@ -14,7 +14,6 @@ helper.spyOnSocketIO = () => {
|
||||||
} else if (msg.data.type === 'CHAT_MESSAGE') {
|
} else if (msg.data.type === 'CHAT_MESSAGE') {
|
||||||
helper.chatMessages.push(msg);
|
helper.chatMessages.push(msg);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -93,10 +92,9 @@ helper.sendChatMessage = (message) => {
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
helper.showSettings = () => {
|
helper.showSettings = () => {
|
||||||
if (!helper.isSettingsShown()) {
|
if (helper.isSettingsShown()) return;
|
||||||
helper.settingsButton().click();
|
helper.settingsButton().click();
|
||||||
return helper.waitForPromise(() => helper.isSettingsShown(), 2000);
|
return helper.waitForPromise(() => helper.isSettingsShown(), 2000);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -106,10 +104,9 @@ helper.showSettings = () => {
|
||||||
* @todo untested
|
* @todo untested
|
||||||
*/
|
*/
|
||||||
helper.hideSettings = () => {
|
helper.hideSettings = () => {
|
||||||
if (helper.isSettingsShown()) {
|
if (!helper.isSettingsShown()) return;
|
||||||
helper.settingsButton().click();
|
helper.settingsButton().click();
|
||||||
return helper.waitForPromise(() => !helper.isSettingsShown(), 2000);
|
return helper.waitForPromise(() => !helper.isSettingsShown(), 2000);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -120,10 +117,9 @@ helper.hideSettings = () => {
|
||||||
*/
|
*/
|
||||||
helper.enableStickyChatviaSettings = () => {
|
helper.enableStickyChatviaSettings = () => {
|
||||||
const stickyChat = helper.padChrome$('#options-stickychat');
|
const stickyChat = helper.padChrome$('#options-stickychat');
|
||||||
if (helper.isSettingsShown() && !stickyChat.is(':checked')) {
|
if (!helper.isSettingsShown() || stickyChat.is(':checked')) return;
|
||||||
stickyChat.click();
|
stickyChat.click();
|
||||||
return helper.waitForPromise(() => helper.isChatboxSticky(), 2000);
|
return helper.waitForPromise(() => helper.isChatboxSticky(), 2000);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -134,10 +130,9 @@ helper.enableStickyChatviaSettings = () => {
|
||||||
*/
|
*/
|
||||||
helper.disableStickyChatviaSettings = () => {
|
helper.disableStickyChatviaSettings = () => {
|
||||||
const stickyChat = helper.padChrome$('#options-stickychat');
|
const stickyChat = helper.padChrome$('#options-stickychat');
|
||||||
if (helper.isSettingsShown() && stickyChat.is(':checked')) {
|
if (!helper.isSettingsShown() || !stickyChat.is(':checked')) return;
|
||||||
stickyChat.click();
|
stickyChat.click();
|
||||||
return helper.waitForPromise(() => !helper.isChatboxSticky(), 2000);
|
return helper.waitForPromise(() => !helper.isChatboxSticky(), 2000);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -148,10 +143,9 @@ helper.disableStickyChatviaSettings = () => {
|
||||||
*/
|
*/
|
||||||
helper.enableStickyChatviaIcon = () => {
|
helper.enableStickyChatviaIcon = () => {
|
||||||
const stickyChat = helper.padChrome$('#titlesticky');
|
const stickyChat = helper.padChrome$('#titlesticky');
|
||||||
if (helper.isChatboxShown() && !helper.isChatboxSticky()) {
|
if (!helper.isChatboxShown() || helper.isChatboxSticky()) return;
|
||||||
stickyChat.click();
|
stickyChat.click();
|
||||||
return helper.waitForPromise(() => helper.isChatboxSticky(), 2000);
|
return helper.waitForPromise(() => helper.isChatboxSticky(), 2000);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -161,10 +155,9 @@ helper.enableStickyChatviaIcon = () => {
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
helper.disableStickyChatviaIcon = () => {
|
helper.disableStickyChatviaIcon = () => {
|
||||||
if (helper.isChatboxShown() && helper.isChatboxSticky()) {
|
if (!helper.isChatboxShown() || !helper.isChatboxSticky()) return;
|
||||||
helper.titlecross().click();
|
helper.titlecross().click();
|
||||||
return helper.waitForPromise(() => !helper.isChatboxSticky(), 2000);
|
return helper.waitForPromise(() => !helper.isChatboxSticky(), 2000);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -15,10 +15,9 @@ helper.contentWindow = () => $('#iframe-container iframe')[0].contentWindow;
|
||||||
*/
|
*/
|
||||||
helper.showChat = () => {
|
helper.showChat = () => {
|
||||||
const chaticon = helper.chatIcon();
|
const chaticon = helper.chatIcon();
|
||||||
if (chaticon.hasClass('visible')) {
|
if (!chaticon.hasClass('visible')) return;
|
||||||
chaticon.click();
|
chaticon.click();
|
||||||
return helper.waitForPromise(() => !chaticon.hasClass('visible'), 2000);
|
return helper.waitForPromise(() => !chaticon.hasClass('visible'), 2000);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,10 +26,9 @@ helper.showChat = () => {
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
helper.hideChat = () => {
|
helper.hideChat = () => {
|
||||||
if (helper.isChatboxShown() && !helper.isChatboxSticky()) {
|
if (!helper.isChatboxShown() || helper.isChatboxSticky()) return;
|
||||||
helper.titlecross().click();
|
helper.titlecross().click();
|
||||||
return helper.waitForPromise(() => !helper.isChatboxShown(), 2000);
|
return helper.waitForPromise(() => !helper.isChatboxShown(), 2000);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -132,9 +130,8 @@ helper.isSettingsShown = () => helper.padChrome$('#settings').hasClass('popup-sh
|
||||||
* @returns {HTMLElement} timer
|
* @returns {HTMLElement} timer
|
||||||
*/
|
*/
|
||||||
helper.timesliderTimer = () => {
|
helper.timesliderTimer = () => {
|
||||||
if (typeof helper.contentWindow().$ === 'function') {
|
if (typeof helper.contentWindow().$ !== 'function') return;
|
||||||
return helper.contentWindow().$('#timer');
|
return helper.contentWindow().$('#timer');
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -143,9 +140,8 @@ helper.timesliderTimer = () => {
|
||||||
* @returns {HTMLElement} timer
|
* @returns {HTMLElement} timer
|
||||||
*/
|
*/
|
||||||
helper.timesliderTimerTime = () => {
|
helper.timesliderTimerTime = () => {
|
||||||
if (helper.timesliderTimer()) {
|
if (!helper.timesliderTimer()) return;
|
||||||
return helper.timesliderTimer().text();
|
return helper.timesliderTimer().text();
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue