-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Emoji and Emoji Undo * Emoji Undo and tests * Fix undo and add tests * Clean up * Add test and clean up * Fix test * Add crlf auto for hybrid environment * Clean up * Fix key down * Clean up * Clean up * Support macOS * Update entry * Clean up * Clean up * Clean up * Clean up * Add test * Fix ESLint * Clean up * Fix test Co-authored-by: William Wong <compulim@hotmail.com> Co-authored-by: William Wong <compulim@users.noreply.github.com>
- Loading branch information
1 parent
c90377d
commit 246ad4f
Showing
35 changed files
with
1,485 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+5.88 KB
...custom-js-emoji-should-be-enabled-and-customizable-through-emoji-set-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.55 KB
...tyle-options-emoji-set-default-js-emoji-should-be-enabled-by-default-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.41 KB
...-disabled-js-emoji-should-be-disabled-when-emoji-set-is-set-to-false-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.55 KB
...set-enabled-js-emoji-should-be-enabled-when-emoji-set-is-set-to-true-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { Key } from 'selenium-webdriver'; | ||
|
||
import { timeouts } from './constants.json'; | ||
import getSendBoxTextBox from './setup/elements/getSendBoxTextBox.js'; | ||
|
||
// selenium-webdriver API doc: | ||
// https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_WebDriver.html | ||
|
||
jest.setTimeout(timeouts.test); | ||
|
||
describe('Emoji', () => { | ||
let driver; | ||
|
||
async function expectTextBox(value, selectionStart, selectionEnd) { | ||
const textBox = await getSendBoxTextBox(driver); | ||
|
||
// To improve test reliability, we will wait up to 500 ms for the expectation. | ||
const getActual = () => | ||
driver.executeScript( | ||
({ selectionEnd, selectionStart, value }) => ({ selectionEnd, selectionStart, value }), | ||
textBox | ||
); | ||
|
||
await driver | ||
.wait(async () => { | ||
const actual = await getActual(); | ||
|
||
return ( | ||
actual.selectionEnd === selectionEnd && actual.selectionStart == selectionStart && actual.value === value | ||
); | ||
}, timeouts.ui) | ||
.catch(() => {}); | ||
|
||
const resultTask = getActual(); | ||
|
||
await expect(resultTask).resolves.toHaveProperty('value', value); | ||
await expect(resultTask).resolves.toHaveProperty('selectionStart', selectionStart); | ||
await expect(resultTask).resolves.toHaveProperty('selectionEnd', selectionEnd); | ||
} | ||
|
||
function sendKeyChord(modifier, key) { | ||
return driver.actions().keyDown(modifier).sendKeys(key).keyUp(modifier).perform(); | ||
} | ||
|
||
function sendControlKey(key) { | ||
return sendKeyChord(Key.CONTROL, key); | ||
} | ||
|
||
function sendUndoKey() { | ||
return sendControlKey('z'); | ||
} | ||
|
||
test('disabled', async () => { | ||
driver = (await setupWebDriver({ props: { styleOptions: { emojiSet: false } } })).driver; | ||
|
||
const textBox = await getSendBoxTextBox(driver); | ||
|
||
await driver.executeScript(textBox => textBox.focus(), textBox); | ||
await driver.actions().sendKeys(':)').perform(); | ||
|
||
await expectTextBox(':)', 2, 2); | ||
|
||
await sendUndoKey(); | ||
|
||
await expectTextBox('', 0, 0); | ||
}); | ||
|
||
test('with only "100" is enabled', async () => { | ||
driver = (await setupWebDriver({ props: { styleOptions: { emojiSet: { '100': '💯' } } } })).driver; | ||
|
||
const textBox = await getSendBoxTextBox(driver); | ||
|
||
await driver.executeScript(textBox => textBox.focus(), textBox); | ||
await driver.actions().sendKeys(':) 100 :)').perform(); | ||
|
||
await expectTextBox(':) 💯 :)', 8, 8); | ||
}); | ||
|
||
test('with conflicting emoticon 1', async () => { | ||
driver = (await setupWebDriver({ props: { styleOptions: { emojiSet: { ':o': '😲', ':o)': '🤡' } } } })).driver; | ||
|
||
const textBox = await getSendBoxTextBox(driver); | ||
|
||
await driver.executeScript(textBox => textBox.focus(), textBox); | ||
await driver.actions().sendKeys(':o)').perform(); | ||
|
||
await expectTextBox('😲)', 3, 3); | ||
}); | ||
|
||
test('with conflicting emoticon 2', async () => { | ||
driver = (await setupWebDriver({ props: { styleOptions: { emojiSet: { ':o)': '🤡', ':o': '😲' } } } })).driver; | ||
|
||
const textBox = await getSendBoxTextBox(driver); | ||
|
||
await driver.executeScript(textBox => textBox.focus(), textBox); | ||
await driver.actions().sendKeys(':o)').perform(); | ||
|
||
await expectTextBox('😲)', 3, 3); | ||
}); | ||
}); |
Oops, something went wrong.