typeahead: Add unit test for typeahead_helper.compare_language().

Bringing it under test before expanding its functionality and doing
refactoring.
This commit is contained in:
Trident Pancake 2023-01-07 12:59:05 -08:00 committed by Tim Abbott
parent cb6c1c4f05
commit bab2eda283

View File

@ -18,6 +18,7 @@ const stream_data = zrequire("stream_data");
const compose_state = zrequire("compose_state");
const emoji = zrequire("emoji");
const pygments_data = zrequire("../generated/pygments_data.json");
const util = zrequire("util");
const actual_pygments_data = {...pygments_data};
const ct = zrequire("composebox_typeahead");
const th = zrequire("typeahead_helper");
@ -816,3 +817,12 @@ test("sort_slash_commands", () => {
{name: "test"},
]);
});
test("compare_language", () => {
assert.ok(th.compare_language("javascript", "haskell") < 0);
assert.ok(th.compare_language("haskell", "javascript") > 0);
// "abap" and "amdgpu" both have priority = 0 at this time, so there is a tie.
// Alphabetical order should be used to break that tie.
assert.equal(th.compare_language("abap", "amdgpu"), util.strcmp("abap", "amdgpu"));
});