Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/theme-language-server-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"build:ci": "pnpm build",
"build:ts": "tsc -b src/tsconfig.build.json",
"dev": "tsc -b src --watch",
"test": "vitest",
"test": "vitest --root ../.. --run packages/theme-language-server-common/src --exclude \"dist/**\"",
"type-check": "tsc --noEmit -p src/tsconfig.json"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ import { createLiquidCompletionParams } from './LiquidCompletionParams';
describe('Module: LiquidCompletionParams', async () => {
describe('createLiquidCompletionParams', async () => {
describe('parsed LiquidHTML template', async () => {
it('returns an undefined completionContext when the template is unsalvageable', () => {
it('recovers a completion context from otherwise-unsalvageable input', () => {
const context = '{{ }}%}%{%}%$}}{#$%}{% ren█ %}';
const { completionContext } = createLiquidParamsFromContext(context);
expect(completionContext).not.to.exist;
expect(completionContext).to.exist;

const { node } = completionContext!;
expectPath(node, 'type').to.eql('LiquidTag');
expectPath(node, 'name').to.eql('ren');
});

describe('completionContext.partialAst', async () => {
it('returns an ast of the file up to the cursor position', async () => {
it('returns an ast of the full file', async () => {
const context = '{{ "hey" }}\n\n{{ product.id }}{% ren█ %}{% echo "not in the AST" %}';

const { completionContext } = createLiquidParamsFromContext(context);
Expand Down Expand Up @@ -42,7 +46,7 @@ describe('Module: LiquidCompletionParams', async () => {
expectPath(partialAst, 'children.2.markup').to.eql('');
expectPath(partialAst, 'children.2.type').to.eql('LiquidTag');

expectPath(partialAst, 'children.3').not.to.exist;
expectPath(partialAst, 'children.3.type').to.eql('LiquidTag');
});
});

Expand All @@ -58,7 +62,7 @@ describe('Module: LiquidCompletionParams', async () => {
expectPath(node, 'markup').to.eql('');
expectPath(node, 'type').to.eql('LiquidTag');
expectPath(node, 'position.start').to.eql(29);
expectPath(node, 'position.end').to.eql(37);
expectPath(node, 'position.end').to.eql(38);
});

it('returns the node under the cursor on nested contexts', async () => {
Expand Down
Loading
Loading