Skip to content

Commit

Permalink
test: verify locally derived completion
Browse files Browse the repository at this point in the history
Related to #57
  • Loading branch information
nikku committed Jun 16, 2024
1 parent 0cb8013 commit be1ec9a
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/spec/autocompletion/pathExpression.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,48 @@ describe('autocompletion - pathExpression', function() {

});


describe('should complete locally derived', function() {

it('context key', function() {

// given
const triggerCompletion = setup('{ foo + bar: 1 }.foo');

// when
const completion = triggerCompletion();

// then
expect(completion).to.exist;
expect(completion.from).to.eql(17);
expect(completion.options).to.have.length(1);
expect(completion.options[0]).to.eql({
label: 'foo + bar',
type: 'variable'
});
});


it('nested context key', function() {

// given
const triggerCompletion = setup('{ foo + bar: { a: 1 } }.foo+bar.');

// when
const completion = triggerCompletion();

// then
expect(completion).to.exist;
expect(completion.from).to.eql(33);
expect(completion.options).to.have.length(1);
expect(completion.options[0]).to.eql({
label: '1',
type: 'variable'
});
});

});

});


Expand Down
33 changes: 33 additions & 0 deletions test/spec/autocompletion/variable.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,39 @@ describe('autocompletion - variable', function() {
expect(completion.options).to.have.length(1);
});


describe('should complete locally derived', function() {

it('context entry', function() {

// given
const triggerCompletion = setup('{ foo + bar: 1, baz: f }.foo', [ {
name: 'foo',
info: 'info',
detail: 'detail'
} ]);

// when
const completion = triggerCompletion({ pos: 22 });

// then
expect(completion).to.exist;
expect(completion.from).to.eql(21);
expect(completion.options).to.have.length(2);
expect(completion.options[0]).to.eql({
label: 'foo + bar',
type: 'variable'
});

expect(completion.options[1]).to.eql({
name: 'foo',
info: 'info',
detail: 'detail'
});
});

});

});


Expand Down

0 comments on commit be1ec9a

Please sign in to comment.