@@ -41,6 +41,20 @@ describe('isFileStrict', () => {
4141 expect ( result ) . toBe ( true ) ;
4242 } ) ;
4343
44+ it ( 'should return true when strict comment is present and file is excluded' , ( ) => {
45+ // given
46+ isCommentPresent . mockImplementation ( ( comment ) => comment === '@ts-strict' ) ;
47+ const config : Config = {
48+ exclude : [ filePath ] ,
49+ } ;
50+
51+ // when
52+ const result = isFileStrict ( { filePath, isCommentPresent, config } ) ;
53+
54+ // then
55+ expect ( result ) . toBe ( true ) ;
56+ } ) ;
57+
4458 it ( 'should return false when both strict and ignore update-strict-comments are present' , ( ) => {
4559 // given
4660 isCommentPresent . mockImplementation (
@@ -110,6 +124,20 @@ describe('isFileStrict', () => {
110124 expect ( result ) . toBe ( false ) ;
111125 } ) ;
112126
127+ it ( 'should return false when file is on path and in exclude' , ( ) => {
128+ // given
129+ const config : Config = {
130+ paths : [ 'otherFilePath' , filePath , 'otherFilePath' ] ,
131+ exclude : [ filePath ] ,
132+ } ;
133+
134+ // when
135+ const result = isFileStrict ( { filePath, isCommentPresent, config } ) ;
136+
137+ // then
138+ expect ( result ) . toBe ( false ) ;
139+ } ) ;
140+
113141 it ( 'should return true when path config is empty' , ( ) => {
114142 // given
115143 const config : Config = {
@@ -122,4 +150,32 @@ describe('isFileStrict', () => {
122150 // then
123151 expect ( result ) . toBe ( true ) ;
124152 } ) ;
153+
154+ it ( 'should return false when path config is empty and file is excluded' , ( ) => {
155+ // given
156+ const config : Config = {
157+ paths : [ ] ,
158+ exclude : [ filePath ] ,
159+ } ;
160+
161+ // when
162+ const result = isFileStrict ( { filePath, isCommentPresent, config } ) ;
163+
164+ // then
165+ expect ( result ) . toBe ( false ) ;
166+ } ) ;
167+
168+ it ( 'should return true when path config is empty and different file is excluded (check for false-positive)' , ( ) => {
169+ // given
170+ const config : Config = {
171+ paths : [ ] ,
172+ exclude : [ 'otherFile' ] ,
173+ } ;
174+
175+ // when
176+ const result = isFileStrict ( { filePath, isCommentPresent, config } ) ;
177+
178+ // then
179+ expect ( result ) . toBe ( true ) ;
180+ } ) ;
125181} ) ;
0 commit comments