-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(android): Add support for unusual import statements (#440)
- Loading branch information
Showing
3 changed files
with
71 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
//@ts-ignore | ||
import { getLastImportLineLocation } from '../../src/android/code-tools'; | ||
|
||
describe('code-tools', () => { | ||
describe('getLastImportLineLocation', () => { | ||
it('returns proper line index', () => { | ||
const code = `import a.b.c;\n` + `//<insert-location>\n` + `class X {}`; | ||
expect(getLastImportLineLocation(code)).toBe( | ||
code.indexOf('//<insert-location>'), | ||
); | ||
}); | ||
|
||
it('returns proper line index when static import is used', () => { | ||
const code = | ||
`import static a.b.c;\n` + `//<insert-location>\n` + `class X {}`; | ||
expect(getLastImportLineLocation(code)).toBe( | ||
code.indexOf('//<insert-location>'), | ||
); | ||
}); | ||
|
||
it('returns proper line index when wildcard import is used', () => { | ||
const code = `import a.b.*\n` + `//<insert-location>\n` + `class X {}`; | ||
expect(getLastImportLineLocation(code)).toBe( | ||
code.indexOf('//<insert-location>'), | ||
); | ||
}); | ||
|
||
it('returns proper line index when alias import is used', () => { | ||
const code = | ||
`import static a.b.c as d\n` + `//<insert-location>\n` + `class X {}`; | ||
expect(getLastImportLineLocation(code)).toBe( | ||
code.indexOf('//<insert-location>'), | ||
); | ||
}); | ||
|
||
it('returns proper line index when multiple imports are present', () => { | ||
const code = | ||
`import static a.b.c as d\n` + | ||
`import a.b.*\n` + | ||
`import static a.b.c;\n` + | ||
`import a.b.c;\n` + | ||
`//<insert-location>\n` + | ||
`class X {}`; | ||
expect(getLastImportLineLocation(code)).toBe( | ||
code.indexOf('//<insert-location>'), | ||
); | ||
}); | ||
}); | ||
}); |