Skip to content

Commit

Permalink
make test more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas committed Sep 19, 2024
1 parent 009d5c0 commit c9fc392
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 34 deletions.
45 changes: 13 additions & 32 deletions src/language-server/__e2e__/rover.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,36 +114,17 @@ test("completion", async () => {
});

test("semantic tokens", async () => {
expect(getFullSemanticTokens(editor)).toMatchInlineSnapshot(`
[
{
"range": [
{
"character": 21,
"line": 10,
},
{
"character": 22,
"line": 10,
},
],
"tokenModifiers": [],
"tokenType": "property",
},
{
"range": [
{
"character": 32,
"line": 12,
},
{
"character": 33,
"line": 12,
},
],
"tokenModifiers": [],
"tokenType": "property",
},
]
`);
const tokens = await getFullSemanticTokens(editor);
expect(tokens[0]).toStrictEqual({
startPosition: getPosition('fields: "|a"'),
endPosition: getPosition('fields: "a|"'),
tokenType: "property",
tokenModifiers: [],
});
expect(tokens[1]).toStrictEqual({
startPosition: getPosition('fields: "|c"'),
endPosition: getPosition('fields: "c|"'),
tokenType: "property",
tokenModifiers: [],
});
});
8 changes: 6 additions & 2 deletions src/language-server/__e2e__/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ function decodeSemanticTokens(
) {
const tokenArr = Array.from(tokens.data);
const decodedTokens: {
range: vscode.Range;
startPosition: vscode.Position;
endPosition: vscode.Position;
tokenType: string;
tokenModifiers: string[];
}[] = [];
Expand All @@ -223,8 +224,11 @@ function decodeSemanticTokens(
for (let modifiers = tokenModifiers; modifiers > 0; modifiers >>= 1) {
decodedModifiers.push(legend.tokenModifiers[modifiers & 0xf]);
}
const startPosition = new vscode.Position(line, start);
const endPosition = startPosition.translate(0, length);
decodedTokens.push({
range: new vscode.Range(line, start, line, start + length),
startPosition,
endPosition,
tokenType: legend.tokenTypes[tokenType],
tokenModifiers: decodedModifiers,
});
Expand Down

0 comments on commit c9fc392

Please sign in to comment.