@@ -20,7 +20,7 @@ function testManyCases(filename, chosenCases, errorMessage) {
2020
2121function testCaseWithOptions ( filename , errorMessage , options = [ ] ) {
2222 return {
23- code : 'foo()' ,
23+ code : `/* Filename ${ filename } */` ,
2424 filename,
2525 options,
2626 errors : errorMessage && [
@@ -37,22 +37,30 @@ test({
3737 testCase ( 'src/foo/fooBar.js' , 'camelCase' ) ,
3838 testCase ( 'src/foo/bar.test.js' , 'camelCase' ) ,
3939 testCase ( 'src/foo/fooBar.test.js' , 'camelCase' ) ,
40- testCase ( 'src/foo/fooBar.testUtils.js' , 'camelCase' ) ,
40+ testCase ( 'src/foo/fooBar.test-utils.js' , 'camelCase' ) ,
41+ testCase ( 'src/foo/fooBar.test_utils.js' , 'camelCase' ) ,
42+ testCase ( 'src/foo/.test_utils.js' , 'camelCase' ) ,
4143 testCase ( 'src/foo/foo.js' , 'snakeCase' ) ,
4244 testCase ( 'src/foo/foo_bar.js' , 'snakeCase' ) ,
4345 testCase ( 'src/foo/foo.test.js' , 'snakeCase' ) ,
4446 testCase ( 'src/foo/foo_bar.test.js' , 'snakeCase' ) ,
4547 testCase ( 'src/foo/foo_bar.test_utils.js' , 'snakeCase' ) ,
48+ testCase ( 'src/foo/foo_bar.test-utils.js' , 'snakeCase' ) ,
49+ testCase ( 'src/foo/.test-utils.js' , 'snakeCase' ) ,
4650 testCase ( 'src/foo/foo.js' , 'kebabCase' ) ,
4751 testCase ( 'src/foo/foo-bar.js' , 'kebabCase' ) ,
4852 testCase ( 'src/foo/foo.test.js' , 'kebabCase' ) ,
4953 testCase ( 'src/foo/foo-bar.test.js' , 'kebabCase' ) ,
5054 testCase ( 'src/foo/foo-bar.test-utils.js' , 'kebabCase' ) ,
55+ testCase ( 'src/foo/foo-bar.test_utils.js' , 'kebabCase' ) ,
56+ testCase ( 'src/foo/.test_utils.js' , 'kebabCase' ) ,
5157 testCase ( 'src/foo/Foo.js' , 'pascalCase' ) ,
5258 testCase ( 'src/foo/FooBar.js' , 'pascalCase' ) ,
53- testCase ( 'src/foo/Foo.Test.js' , 'pascalCase' ) ,
54- testCase ( 'src/foo/FooBar.Test.js' , 'pascalCase' ) ,
55- testCase ( 'src/foo/FooBar.TestUtils.js' , 'pascalCase' ) ,
59+ testCase ( 'src/foo/Foo.test.js' , 'pascalCase' ) ,
60+ testCase ( 'src/foo/FooBar.test.js' , 'pascalCase' ) ,
61+ testCase ( 'src/foo/FooBar.test-utils.js' , 'pascalCase' ) ,
62+ testCase ( 'src/foo/FooBar.test_utils.js' , 'pascalCase' ) ,
63+ testCase ( 'src/foo/.test_utils.js' , 'pascalCase' ) ,
5664 testCase ( 'spec/iss47Spec.js' , 'camelCase' ) ,
5765 testCase ( 'spec/iss47Spec100.js' , 'camelCase' ) ,
5866 testCase ( 'spec/i18n.js' , 'camelCase' ) ,
6573 testCase ( 'spec/iss47_100spec.js' , 'snakeCase' ) ,
6674 testCase ( 'spec/i18n.js' , 'snakeCase' ) ,
6775 testCase ( 'spec/Iss47Spec.js' , 'pascalCase' ) ,
68- testCase ( 'spec/Iss47.100Spec .js' , 'pascalCase' ) ,
76+ testCase ( 'spec/Iss47.100spec .js' , 'pascalCase' ) ,
6977 testCase ( 'spec/I18n.js' , 'pascalCase' ) ,
7078 testCase ( undefined , 'camelCase' ) ,
7179 testCase ( undefined , 'snakeCase' ) ,
@@ -238,6 +246,31 @@ test({
238246 ...[ 'index.js' , 'index.mjs' , 'index.cjs' , 'index.ts' , 'index.tsx' , 'index.vue' ] . flatMap (
239247 filename => [ 'camelCase' , 'snakeCase' , 'kebabCase' , 'pascalCase' ] . map ( chosenCase => testCase ( filename , chosenCase ) ) ,
240248 ) ,
249+ testCaseWithOptions ( 'index.tsx' , undefined , [ { case : 'pascalCase' , multipleFileExtensions : false } ] ) ,
250+ testCaseWithOptions ( 'src/index.tsx' , undefined , [ { case : 'pascalCase' , multipleFileExtensions : false } ] ) ,
251+ testCaseWithOptions ( 'src/foo/fooBar.test.js' , undefined , [ { case : 'camelCase' , multipleFileExtensions : false } ] ) ,
252+ testCaseWithOptions ( 'src/foo/fooBar.testUtils.js' , undefined , [ { case : 'camelCase' , multipleFileExtensions : false } ] ) ,
253+ testCaseWithOptions ( 'src/foo/foo_bar.test_utils.js' , undefined , [ { case : 'snakeCase' , multipleFileExtensions : false } ] ) ,
254+ testCaseWithOptions ( 'src/foo/foo.test.js' , undefined , [ { case : 'kebabCase' , multipleFileExtensions : false } ] ) ,
255+ testCaseWithOptions ( 'src/foo/foo-bar.test.js' , undefined , [ { case : 'kebabCase' , multipleFileExtensions : false } ] ) ,
256+ testCaseWithOptions ( 'src/foo/foo-bar.test-utils.js' , undefined , [ { case : 'kebabCase' , multipleFileExtensions : false } ] ) ,
257+ testCaseWithOptions ( 'src/foo/Foo.Test.js' , undefined , [ { case : 'pascalCase' , multipleFileExtensions : false } ] ) ,
258+ testCaseWithOptions ( 'src/foo/FooBar.Test.js' , undefined , [ { case : 'pascalCase' , multipleFileExtensions : false } ] ) ,
259+ testCaseWithOptions ( 'src/foo/FooBar.TestUtils.js' , undefined , [ { case : 'pascalCase' , multipleFileExtensions : false } ] ) ,
260+ testCaseWithOptions ( 'spec/Iss47.100Spec.js' , undefined , [ { case : 'pascalCase' , multipleFileExtensions : false } ] ) ,
261+ // Multiple filename parts - multiple file extensions
262+ testCaseWithOptions ( 'src/foo/fooBar.Test.js' , undefined , [ { case : 'camelCase' } ] ) ,
263+ testCaseWithOptions ( 'test/foo/fooBar.testUtils.js' , undefined , [ { case : 'camelCase' } ] ) ,
264+ testCaseWithOptions ( 'test/foo/.testUtils.js' , undefined , [ { case : 'camelCase' } ] ) ,
265+ testCaseWithOptions ( 'test/foo/foo_bar.Test.js' , undefined , [ { case : 'snakeCase' } ] ) ,
266+ testCaseWithOptions ( 'test/foo/foo_bar.Test_Utils.js' , undefined , [ { case : 'snakeCase' } ] ) ,
267+ testCaseWithOptions ( 'test/foo/.Test_Utils.js' , undefined , [ { case : 'snakeCase' } ] ) ,
268+ testCaseWithOptions ( 'test/foo/foo-bar.Test.js' , undefined , [ { case : 'kebabCase' } ] ) ,
269+ testCaseWithOptions ( 'test/foo/foo-bar.Test-Utils.js' , undefined , [ { case : 'kebabCase' } ] ) ,
270+ testCaseWithOptions ( 'test/foo/.Test-Utils.js' , undefined , [ { case : 'kebabCase' } ] ) ,
271+ testCaseWithOptions ( 'test/foo/FooBar.Test.js' , undefined , [ { case : 'pascalCase' } ] ) ,
272+ testCaseWithOptions ( 'test/foo/FooBar.TestUtils.js' , undefined , [ { case : 'pascalCase' } ] ) ,
273+ testCaseWithOptions ( 'test/foo/.TestUtils.js' , undefined , [ { case : 'pascalCase' } ] ) ,
241274 ] ,
242275 invalid : [
243276 testCase (
@@ -258,7 +291,7 @@ test({
258291 testCase (
259292 'test/foo/foo_bar.test_utils.js' ,
260293 'camelCase' ,
261- 'Filename is not in camel case. Rename it to `fooBar.testUtils .js`.' ,
294+ 'Filename is not in camel case. Rename it to `fooBar.test_utils .js`.' ,
262295 ) ,
263296 testCase (
264297 'test/foo/fooBar.js' ,
@@ -273,7 +306,7 @@ test({
273306 testCase (
274307 'test/foo/fooBar.testUtils.js' ,
275308 'snakeCase' ,
276- 'Filename is not in snake case. Rename it to `foo_bar.test_utils .js`.' ,
309+ 'Filename is not in snake case. Rename it to `foo_bar.testUtils .js`.' ,
277310 ) ,
278311 testCase (
279312 'test/foo/fooBar.js' ,
@@ -288,7 +321,7 @@ test({
288321 testCase (
289322 'test/foo/fooBar.testUtils.js' ,
290323 'kebabCase' ,
291- 'Filename is not in kebab case. Rename it to `foo-bar.test-utils .js`.' ,
324+ 'Filename is not in kebab case. Rename it to `foo-bar.testUtils .js`.' ,
292325 ) ,
293326 testCase (
294327 'test/foo/fooBar.js' ,
@@ -298,12 +331,12 @@ test({
298331 testCase (
299332 'test/foo/foo_bar.test.js' ,
300333 'pascalCase' ,
301- 'Filename is not in pascal case. Rename it to `FooBar.Test .js`.' ,
334+ 'Filename is not in pascal case. Rename it to `FooBar.test .js`.' ,
302335 ) ,
303336 testCase (
304337 'test/foo/foo-bar.test-utils.js' ,
305338 'pascalCase' ,
306- 'Filename is not in pascal case. Rename it to `FooBar.TestUtils .js`.' ,
339+ 'Filename is not in pascal case. Rename it to `FooBar.test-utils .js`.' ,
307340 ) ,
308341 testCase (
309342 'src/foo/_FOO-BAR.js' ,
@@ -547,14 +580,59 @@ test({
547580 } ,
548581 'Filename is not in camel case, pascal case, or kebab case. Rename it to `1.js`.' ,
549582 ) ,
583+ // Multiple filename parts - single file extension
584+ testCaseWithOptions (
585+ 'src/foo/foo_bar.test.js' ,
586+ 'Filename is not in camel case. Rename it to `fooBar.test.js`.' ,
587+ [ { case : 'camelCase' , multipleFileExtensions : false } ] ,
588+ ) ,
589+ testCaseWithOptions (
590+ 'test/foo/foo_bar.test_utils.js' ,
591+ 'Filename is not in camel case. Rename it to `fooBar.testUtils.js`.' ,
592+ [ { case : 'camelCase' , multipleFileExtensions : false } ] ,
593+ ) ,
594+ testCaseWithOptions (
595+ 'test/foo/fooBar.test.js' ,
596+ 'Filename is not in snake case. Rename it to `foo_bar.test.js`.' ,
597+ [ { case : 'snakeCase' , multipleFileExtensions : false } ] ,
598+ ) ,
599+ testCaseWithOptions (
600+ 'test/foo/fooBar.testUtils.js' ,
601+ 'Filename is not in snake case. Rename it to `foo_bar.test_utils.js`.' ,
602+ [ { case : 'snakeCase' , multipleFileExtensions : false } ] ,
603+ ) ,
604+ testCaseWithOptions (
605+ 'test/foo/fooBar.test.js' ,
606+ 'Filename is not in kebab case. Rename it to `foo-bar.test.js`.' ,
607+ [ { case : 'kebabCase' , multipleFileExtensions : false } ] ,
608+ ) ,
609+ testCaseWithOptions (
610+ 'test/foo/fooBar.testUtils.js' ,
611+ 'Filename is not in kebab case. Rename it to `foo-bar.test-utils.js`.' ,
612+ [ { case : 'kebabCase' , multipleFileExtensions : false } ] ,
613+ ) ,
614+ testCaseWithOptions (
615+ 'test/foo/foo_bar.test.js' ,
616+ 'Filename is not in pascal case. Rename it to `FooBar.Test.js`.' ,
617+ [ { case : 'pascalCase' , multipleFileExtensions : false } ] ,
618+ ) ,
619+ testCaseWithOptions (
620+ 'test/foo/foo-bar.test-utils.js' ,
621+ 'Filename is not in pascal case. Rename it to `FooBar.TestUtils.js`.' ,
622+ [ { case : 'pascalCase' , multipleFileExtensions : false } ] ,
623+ ) ,
550624 ] ,
551625} ) ;
552626
553627test . snapshot ( {
554628 valid : [
555629 undefined ,
556630 'src/foo.JS/bar.js' ,
631+ 'src/foo.JS/bar.spec.js' ,
632+ 'src/foo.JS/.spec.js' ,
557633 'src/foo.JS/bar' ,
634+ 'foo.SPEC.js' ,
635+ '.SPEC.js' ,
558636 ] . map ( filename => ( { code : `const filename = ${ JSON . stringify ( filename ) } ;` , filename} ) ) ,
559637 invalid : [
560638 {
@@ -575,6 +653,6 @@ test.snapshot({
575653 'foo.jS' ,
576654 'index.JS' ,
577655 'foo..JS' ,
578- ] . map ( filename => ( { code : `const filename = ${ JSON . stringify ( filename ) } ; ` , filename} ) ) ,
656+ ] . map ( filename => ( { code : `/* Filename ${ filename } */ ` , filename} ) ) ,
579657 ] ,
580658} ) ;
0 commit comments