Просмотр исходного кода

add test case of extractedArchiveDirName

Ryu Sato 2 лет назад
Родитель
Сommit
1ece30f3b3
1 измененных файлов с 31 добавлено и 12 удалено
  1. 31 12
      apps/app/src/features/growi-plugin/server/models/vo/github-url.spec.ts

+ 31 - 12
apps/app/src/features/growi-plugin/server/models/vo/github-url.spec.ts

@@ -69,19 +69,38 @@ describe('archiveUrl()', () => {
 
 describe('extractedArchiveDirName()', () => {
 
-  it.concurrent.each`
-    branchName
-    ${'a"\'!,;-=@`]<>|&{}()$%+#/b'}
-    ${'a---b'}
-  `("'$branchName'", ({ branchName }) => {
-    // setup
-    const githubUrl = new GitHubUrl('https://github.com/org/repos', branchName);
-
-    // when
-    const { extractedArchiveDirName } = githubUrl;
+  describe('certain characters in the branch name are converted to slashes, and if they are consecutive, they become a single hyphen', () => {
+    it.concurrent.each`
+      branchName
+      ${'a"\'!,;-=@`]<>|&{}()$%+#/b'}
+      ${'a---b'}
+    `("'$branchName'", ({ branchName }) => {
+      // setup
+      const githubUrl = new GitHubUrl('https://github.com/org/repos', branchName);
+
+      // when
+      const { extractedArchiveDirName } = githubUrl;
+
+      // then
+      expect(extractedArchiveDirName).toEqual('a-b');
+    });
+  });
 
-    // then
-    expect(extractedArchiveDirName).toEqual('a-b');
+  describe('when no certain characters in the branch name', () => {
+    it.concurrent.each`
+      branchName
+      ${'a.b'}
+      ${'a_b'}
+    `("'$branchName'", ({ branchName }) => {
+      // setup
+      const githubUrl = new GitHubUrl('https://github.com/org/repos', branchName);
+
+      // when
+      const { extractedArchiveDirName } = githubUrl;
+
+      // then
+      expect(extractedArchiveDirName).toEqual(branchName);
+    });
   });
 
 });