DEV: add (broken) test

This commit is contained in:
Renato Atilio 2024-12-17 14:27:57 -03:00
parent 867de8e841
commit 90f2cd3b8c
No known key found for this signature in database
GPG Key ID: CBF93DCB5CBCA1A5
1 changed files with 31 additions and 0 deletions

View File

@ -1,3 +1,4 @@
import { triggerKeyEvent } from "@ember/test-helpers";
import { setupTest } from "ember-qunit";
import { compile } from "handlebars";
import $ from "jquery";
@ -169,4 +170,34 @@ module("Unit | Utility | autocomplete", function (hooks) {
assert.strictEqual(element.value, "@t");
});
test("Autocomplete does not trigger with right-left arrow keys", async function (assert) {
const element = textArea();
$(element).autocomplete({
key: ":",
template,
transformComplete: (e) => e.slice(1),
dataSource: () => [":smile:"],
});
await simulateKeys(element, ":smi\t");
assert.dom(element).hasValue(":smile: ");
["ArrowLeft", "ArrowLeft", "ArrowLeft"].forEach((key) =>
["keydown", "keyup"].forEach(async (event) => {
await triggerKeyEvent(element, event, key, { code: key });
})
);
assert.strictEqual(element.selectionStart, 5);
assert.dom("#ac-testing").doesNotExist();
await simulateKey(element, "\b");
assert.dom(element).hasValue(":smil");
assert.dom("#ac-testing").exists();
});
});