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 3de5a3c
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",

Check failure on line 259 in src/autocomplete_test.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Unexpected trailing comma
}, {
caption: "all",
value: "all",

Check failure on line 262 in src/autocomplete_test.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Unexpected trailing comma
}
];
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()

Check failure on line 278 in src/autocomplete_test.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Missing semicolon
});

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 3de5a3c

Please sign in to comment.