File tree 2 files changed +21
-1
lines changed
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 1
- const COMMENTS_PATTERN = / ( ( \/ \* + [ \s \S ] * ?\* \/ ) | ( \/ \* + .* \* \/ ) | ^ \/ \/ .* ?[ \r \n ] ) [ \r \n ] * / gm;
1
+ const COMMENTS_PATTERN = / ( ( \/ \* \* + [ \s \S ] * ?\* \/ ) | ( \/ \* + .* \* \/ ) | ^ \/ \/ .* ?[ \r \n ] ) [ \r \n ] * / gm;
2
2
const BREAK_LINE = / \n / g;
3
3
4
4
const getComments = text => {
Original file line number Diff line number Diff line change @@ -74,6 +74,26 @@ describe('get only comments consumer method', () => {
74
74
expect ( result ) . toEqual ( expected ) ;
75
75
} ) ;
76
76
77
+ it ( 'should return only the JSdoc comment when we add a regex in the file pattern' , ( ) => {
78
+ const input = [ `
79
+ const pattern = './*.js';
80
+ /**
81
+ * @param {[type]}
82
+ * @param {[type]}
83
+ * @return {[type]}
84
+ */
85
+
86
+ ` ] ;
87
+ const expected = [ `/**
88
+ * @param {[type]}
89
+ * @param {[type]}
90
+ * @return {[type]}
91
+ */` ] ;
92
+ const result = getOnlyComments ( input ) ;
93
+ expect ( result ) . toHaveLength ( 1 ) ;
94
+ expect ( result ) . toEqual ( expected ) ;
95
+ } ) ;
96
+
77
97
it ( 'should return multiline and JSdoc comment' , ( ) => {
78
98
const input = [ `
79
99
/* this is a comment */
You can’t perform that action at this time.
0 commit comments