Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] JumpToDefinition: Improvements #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
41 changes: 41 additions & 0 deletions test/features/jumpToDefinition.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,34 @@ describe('jump to definition', function() {
});
});

describe('when the definition is a static property', function() {
it('finds the definition for a function static property within the function', function() {
mockfs({
'static.js': 'function foo() {\nfoo.bar = 1;\nconsole.log(foo.bar);}'
});

const result = jumpToDefinition({
filename: 'static.js',
clickPosition: '3,17'
});

assert.equal(result, 'static.js:2:4');
});

it('finds the definition for a function static property outside of the function', function() {
mockfs({
'static.js': 'function foo() {\nfoo.bar = 1;}\nconsole.log(foo.bar);'
});

const result = jumpToDefinition({
filename: 'static.js',
clickPosition: '3,17'
});

assert.equal(result, 'static.js:2:4');
});
});

describe('when the definition is a member of an object', function() {
it('finds the definition of a function property', function() {
mockfs({
Expand All @@ -202,6 +230,19 @@ describe('jump to definition', function() {

assert.equal(result, 'property.js:2:1');
});

it('finds the definition of the property of a property of an object', function() {
mockfs({
'nested.js': 'var obj = {\nfoo: {\nbar: 1}};\nconsole.log(obj.foo.bar);'
});

const result = jumpToDefinition({
filename: 'nested.js',
clickPosition: '4,21'
});

assert.equal(result, 'nested.js:3:1');
});
});
});

Expand Down