From 01481abe4f75b81584f11cec16ba543e98fd21aa Mon Sep 17 00:00:00 2001
From: ijlee2 <ijlee2@users.noreply.github.com>
Date: Thu, 5 Sep 2024 10:39:21 +0200
Subject: [PATCH] bugfix: Created the barrel file for test-support

---
 src/steps/move-addon-files.ts                      | 14 +++++++++++++-
 .../src/{test-support/index.ts => test-support.ts} |  0
 tests/steps/move-addon-files/test-support.test.ts  |  2 +-
 3 files changed, 14 insertions(+), 2 deletions(-)
 rename tests/fixtures/hello-world/output/hello-world/src/{test-support/index.ts => test-support.ts} (100%)

diff --git a/src/steps/move-addon-files.ts b/src/steps/move-addon-files.ts
index 6708ed98..b13020ba 100644
--- a/src/steps/move-addon-files.ts
+++ b/src/steps/move-addon-files.ts
@@ -25,7 +25,19 @@ function moveAddonFolder(options: Options): void {
 function moveAddonTestSupportFolder(options: Options): void {
   const { locations, projectRoot } = options;
 
-  const filePaths = findFiles('addon-test-support/**/*', {
+  let filePaths = findFiles('addon-test-support/index.{js,ts}', {
+    projectRoot,
+  });
+
+  if (filePaths.length === 1) {
+    const oldPath = filePaths[0]!;
+    const newPath = `${locations.addon}/src/test-support${oldPath.endsWith('.ts') ? '.ts' : 'js'}`;
+
+    moveFiles(new Map([[oldPath, newPath]]), options);
+  }
+
+  filePaths = findFiles('addon-test-support/**/*', {
+    ignoreList: ['addon-test-support/index.{js,ts}'],
     projectRoot,
   });
 
diff --git a/tests/fixtures/hello-world/output/hello-world/src/test-support/index.ts b/tests/fixtures/hello-world/output/hello-world/src/test-support.ts
similarity index 100%
rename from tests/fixtures/hello-world/output/hello-world/src/test-support/index.ts
rename to tests/fixtures/hello-world/output/hello-world/src/test-support.ts
diff --git a/tests/steps/move-addon-files/test-support.test.ts b/tests/steps/move-addon-files/test-support.test.ts
index 9858602e..4a76198c 100644
--- a/tests/steps/move-addon-files/test-support.test.ts
+++ b/tests/steps/move-addon-files/test-support.test.ts
@@ -23,8 +23,8 @@ test('steps | move-addon-files > test-support', function () {
           components: {
             'container-query.ts': '',
           },
-          'index.ts': `export * from './components/container-query';\n`,
         },
+        'test-support.ts': `export * from './components/container-query';\n`,
       },
     },
   };