Skip to content

Commit be1ec9a

Browse files
committed
test: verify locally derived completion
Related to #57
1 parent 0cb8013 commit be1ec9a

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

test/spec/autocompletion/pathExpression.spec.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,48 @@ describe('autocompletion - pathExpression', function() {
348348

349349
});
350350

351+
352+
describe('should complete locally derived', function() {
353+
354+
it('context key', function() {
355+
356+
// given
357+
const triggerCompletion = setup('{ foo + bar: 1 }.foo');
358+
359+
// when
360+
const completion = triggerCompletion();
361+
362+
// then
363+
expect(completion).to.exist;
364+
expect(completion.from).to.eql(17);
365+
expect(completion.options).to.have.length(1);
366+
expect(completion.options[0]).to.eql({
367+
label: 'foo + bar',
368+
type: 'variable'
369+
});
370+
});
371+
372+
373+
it('nested context key', function() {
374+
375+
// given
376+
const triggerCompletion = setup('{ foo + bar: { a: 1 } }.foo+bar.');
377+
378+
// when
379+
const completion = triggerCompletion();
380+
381+
// then
382+
expect(completion).to.exist;
383+
expect(completion.from).to.eql(33);
384+
expect(completion.options).to.have.length(1);
385+
expect(completion.options[0]).to.eql({
386+
label: '1',
387+
type: 'variable'
388+
});
389+
});
390+
391+
});
392+
351393
});
352394

353395

test/spec/autocompletion/variable.spec.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,39 @@ describe('autocompletion - variable', function() {
146146
expect(completion.options).to.have.length(1);
147147
});
148148

149+
150+
describe('should complete locally derived', function() {
151+
152+
it('context entry', function() {
153+
154+
// given
155+
const triggerCompletion = setup('{ foo + bar: 1, baz: f }.foo', [ {
156+
name: 'foo',
157+
info: 'info',
158+
detail: 'detail'
159+
} ]);
160+
161+
// when
162+
const completion = triggerCompletion({ pos: 22 });
163+
164+
// then
165+
expect(completion).to.exist;
166+
expect(completion.from).to.eql(21);
167+
expect(completion.options).to.have.length(2);
168+
expect(completion.options[0]).to.eql({
169+
label: 'foo + bar',
170+
type: 'variable'
171+
});
172+
173+
expect(completion.options[1]).to.eql({
174+
name: 'foo',
175+
info: 'info',
176+
detail: 'detail'
177+
});
178+
});
179+
180+
});
181+
149182
});
150183

151184

0 commit comments

Comments
 (0)