Skip to content

Commit

Permalink
Style changes
Browse files Browse the repository at this point in the history
  • Loading branch information
afcapel committed Dec 9, 2021
1 parent 80d4828 commit 3003484
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 75 deletions.
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import json from "@rollup/plugin-json"
import filesize from "rollup-plugin-filesize"
import includePaths from "rollup-plugin-includepaths"
import commonjs from "rollup-plugin-commonjs"
import { babel } from '@rollup/plugin-babel'
import { babel } from "@rollup/plugin-babel"
import nodeResolve from "rollup-plugin-node-resolve"

import { version } from "./package.json"
Expand Down
54 changes: 6 additions & 48 deletions src/test/system/basic_input_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,44 +32,16 @@ testGroup("Basic input", { template: "editor_empty" }, () => {

test("pressing escape in Safari", (expectDocument) =>
typeCharacters("a", () => {
if (
triggerEvent(document.activeElement, "keydown", {
charCode: 0,
keyCode: 27,
which: 27,
key: "Escape",
code: "Escape",
})
) {
triggerEvent(document.activeElement, "keypress", {
charCode: 27,
keyCode: 27,
which: 27,
key: "Escape",
code: "Escape",
})
if (triggerEvent(document.activeElement, "keydown", { charCode: 0, keyCode: 27, which: 27, key: "Escape", code: "Escape" })) {
triggerEvent(document.activeElement, "keypress", { charCode: 27, keyCode: 27, which: 27, key: "Escape", code: "Escape" })
}
defer(() => expectDocument("a\n"))
}))

test("pressing escape in Firefox", (expectDocument) =>
typeCharacters("a", () => {
if (
triggerEvent(document.activeElement, "keydown", {
charCode: 0,
keyCode: 27,
which: 27,
key: "Escape",
code: "Escape",
})
) {
triggerEvent(document.activeElement, "keypress", {
charCode: 0,
keyCode: 27,
which: 0,
key: "Escape",
code: "Escape",
})
if (triggerEvent(document.activeElement, "keydown", { charCode: 0, keyCode: 27, which: 27, key: "Escape", code: "Escape" })) {
triggerEvent(document.activeElement, "keypress", { charCode: 0, keyCode: 27, which: 0, key: "Escape", code: "Escape" })
}
defer(() => expectDocument("a\n"))
}))
Expand Down Expand Up @@ -119,22 +91,8 @@ testGroup("Basic input", { template: "editor_empty" }, () => {
testIf(config.input.getLevel() === 0, "inserting ó with control + alt + o (AltGr)", (expectDocument) =>
typeCharacters("ab", () =>
moveCursor("left", () => {
if (
triggerEvent(document.activeElement, "keydown", {
charCode: 0,
keyCode: 79,
which: 79,
altKey: true,
ctrlKey: true,
})
) {
triggerEvent(document.activeElement, "keypress", {
charCode: 243,
keyCode: 243,
which: 243,
altKey: true,
ctrlKey: true,
})
if (triggerEvent(document.activeElement, "keydown", { charCode: 0, keyCode: 79, which: 79, altKey: true, ctrlKey: true })) {
triggerEvent(document.activeElement, "keypress", { charCode: 243, keyCode: 243, which: 243, altKey: true, ctrlKey: true })
insertNode(document.createTextNode("ó"))
}

Expand Down
34 changes: 15 additions & 19 deletions src/test/system/composition_input_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,31 +147,27 @@ testGroup("Composition input", { template: "editor_empty" }, () => {
})
})

testIf(
config.browser.composesExistingText,
"composition events from cursor movement are ignored",
(expectDocument) => {
const element = getEditorElement()
element.editor.insertString("ab ")

element.editor.setSelectedRange(0)
triggerEvent(element, "compositionstart", { data: "" })
testIf(config.browser.composesExistingText, "composition events from cursor movement are ignored", (expectDocument) => {
const element = getEditorElement()
element.editor.insertString("ab ")

element.editor.setSelectedRange(0)
triggerEvent(element, "compositionstart", { data: "" })
triggerEvent(element, "compositionupdate", { data: "ab" })
defer(() => {
element.editor.setSelectedRange(1)
triggerEvent(element, "compositionupdate", { data: "ab" })
defer(() => {
element.editor.setSelectedRange(1)
element.editor.setSelectedRange(2)
triggerEvent(element, "compositionupdate", { data: "ab" })
defer(() => {
element.editor.setSelectedRange(2)
triggerEvent(element, "compositionupdate", { data: "ab" })
defer(() => {
element.editor.setSelectedRange(3)
triggerEvent(element, "compositionend", { data: "ab" })
defer(() => expectDocument("ab \n"))
})
element.editor.setSelectedRange(3)
triggerEvent(element, "compositionend", { data: "ab" })
defer(() => expectDocument("ab \n"))
})
})
}
)
})
})

// Simulates compositions in Firefox where the final composition data is
// dispatched as both compositionupdate and compositionend.
Expand Down
8 changes: 1 addition & 7 deletions src/test/test_helpers/selection_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,7 @@ export const expandSelection = (options, callback) =>

return (expand = () =>
defer(() => {
if (
triggerEvent(document.activeElement, "keydown", {
keyCode: keyCodes[direction],
key: keys[direction],
shiftKey: true,
})
) {
if (triggerEvent(document.activeElement, "keydown", { keyCode: keyCodes[direction], key: keys[direction], shiftKey: true })) {
getComposition().expandSelectionInDirection(direction === "left" ? "backward" : "forward")
}

Expand Down

0 comments on commit 3003484

Please sign in to comment.