@@ -776,13 +776,39 @@ describe('when calling getTokenOrCommentAfter', () => {
776776 getTokenOrCommentAfter ;
777777} ) ;
778778
779+ // https://github.com/eslint/eslint/blob/v9.39.1/tests/lib/languages/js/source-code/token-store.js#L1604-L1672
779780describe ( 'when calling getFirstToken & getTokenAfter' , ( ) => {
780- /* oxlint-disable-next-line no-disabled-tests expect-expect */
781- it ( 'is to be implemented' ) ;
782- /* oxlint-disable-next-line no-unused-expressions */
783- getFirstToken ;
784- /* oxlint-disable-next-line no-unused-expressions */
785- getTokenAfter ;
781+ it ( 'should retrieve all tokens and comments in the node' , ( ) => {
782+ sourceText = '(function(a, /*b,*/ c){})' ;
783+ const tokens = [ ] ;
784+ // TODO: replace this verbatim range with `ast`
785+ let token = getFirstToken ( { range : [ 0 , 25 ] } as Node ) ;
786+
787+ while ( token ) {
788+ tokens . push ( token ) ;
789+ token = getTokenAfter ( token , {
790+ includeComments : true ,
791+ } ) ;
792+ }
793+
794+ expect ( tokens . map ( ( token ) => token . value ) ) . toEqual ( [ '(' , 'function' , '(' , 'a' , ',' , 'b,' , 'c' , ')' , '{' , '}' , ')' ] ) ;
795+ } ) ;
796+
797+ it ( 'should retrieve all tokens and comments in the node (no spaces)' , ( ) => {
798+ sourceText = '(function(a,/*b,*/c){})' ;
799+ const tokens = [ ] ;
800+ // TODO: replace this verbatim range with `ast`
801+ let token = getFirstToken ( { range : [ 0 , 23 ] } as Node ) ;
802+
803+ while ( token ) {
804+ tokens . push ( token ) ;
805+ token = getTokenAfter ( token , {
806+ includeComments : true ,
807+ } ) ;
808+ }
809+
810+ expect ( tokens . map ( ( token ) => token . value ) ) . toEqual ( [ '(' , 'function' , '(' , 'a' , ',' , 'b,' , 'c' , ')' , '{' , '}' , ')' ] ) ;
811+ } ) ;
786812} ) ;
787813
788814describe ( 'when calling getLastToken & getTokenBefore' , ( ) => {
0 commit comments