Skip to content

Commit

Permalink
add test for triggerCharacters
Browse files Browse the repository at this point in the history
  • Loading branch information
mkslanc committed May 2, 2023
1 parent f775661 commit 3eba092
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/autocomplete_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,45 @@ module.exports = {
editor.container.remove();
done();
}, 10);
},
"test: trigger autocomplete for specific characters": function (done) {
var editor = initEditor("document");

editor.completers = [
{
getCompletions: function (editor, session, pos, prefix, callback) {
var completions = [
{
caption: "append",
value: "append"
}, {
caption: "all",
value: "all"
}
];
callback(null, completions);
},
triggerCharacters: ["."]
}
];

editor.moveCursorTo(0, 8);
sendKey(".");
var popup = editor.completer.popup;
check(function () {
assert.equal(popup.data.length, 2);
editor.onCommandKey(null, 0, 13);
assert.equal(editor.getValue(), "document.all");
done();
});

function check(callback) {
popup = editor.completer.popup;
popup.renderer.on("afterRender", function wait() {
popup.renderer.off("afterRender", wait);
callback();
});
}
}
};

Expand Down

0 comments on commit 3eba092

Please sign in to comment.