test: use jest tagged template literal
This MR suggests changing the way we write it.each
jest tests from specifying the table as an Array
to specifying the table as a Tagged Template Literal
.
This change was originally suggested by @pslaughter in !106 (comment 417787357)
This MR got separated from !106 (merged) because I'd like to have a discussion about pros and cons of using tagged template literals.
Pros
- the meaning of the variables is annotated by the table header
- Prettier supports automatic formatting
Cons
- the lenght of the line is longer than the 100 character limit (it doesn't fit on my mac screen)
- changing the longest
remote
will result in a complete change of history. Changinghttps://gitlab.company.com:8443
tohttps://gitlab.company.com:844
results in:
diff --git a/src/git/git_remote_parser.test.js b/src/git/git_remote_parser.test.js
index f7f47c8..4af1f5d 100644
--- a/src/git/git_remote_parser.test.js
+++ b/src/git/git_remote_parser.test.js
@@ -2,18 +2,18 @@ const { parseGitRemote } = require('./git_remote_parser');
describe('git_remote_parser', () => {
it.each`
- remote | host | namespace | project
- ${'git@gitlab.com:fatihacet/gitlab-vscode-extension.git'} | ${'gitlab.com'} | ${'fatihacet'} | ${'gitlab-vscode-extension'}
- ${'gitlab-ci@gitlab-mydomain.com:fatihacet/gitlab-vscode-extension.git'} | ${'gitlab-mydomain.com'} | ${'fatihacet'} | ${'gitlab-vscode-extension'}
- ${'ssh://git@gitlab.com:fatihacet/gitlab-vscode-extension.git'} | ${'gitlab.com'} | ${'fatihacet'} | ${'gitlab-vscode-extension'}
- ${'git://git@gitlab.com:fatihacet/gitlab-vscode-extension.git'} | ${'gitlab.com'} | ${'fatihacet'} | ${'gitlab-vscode-extension'}
- ${'http://git@gitlab.com/fatihacet/gitlab-vscode-extension.git'} | ${'gitlab.com'} | ${'fatihacet'} | ${'gitlab-vscode-extension'}
- ${'http://gitlab.com/fatihacet/gitlab-vscode-extension.git'} | ${'gitlab.com'} | ${'fatihacet'} | ${'gitlab-vscode-extension'}
- ${'https://git@gitlab.com/fatihacet/gitlab-vscode-extension.git'} | ${'gitlab.com'} | ${'fatihacet'} | ${'gitlab-vscode-extension'}
- ${'https://gitlab.com/fatihacet/gitlab-vscode-extension.git'} | ${'gitlab.com'} | ${'fatihacet'} | ${'gitlab-vscode-extension'}
- ${'https://gitlab.com/fatihacet/gitlab-vscode-extension'} | ${'gitlab.com'} | ${'fatihacet'} | ${'gitlab-vscode-extension'}
- ${'https://gitlab.company.com/fatihacet/gitlab-vscode-extension.git'} | ${'gitlab.company.com'} | ${'fatihacet'} | ${'gitlab-vscode-extension'}
- ${'https://gitlab.company.com:8443/fatihacet/gitlab-vscode-extension.git'} | ${'gitlab.company.com:8443'} | ${'fatihacet'} | ${'gitlab-vscode-extension'}
+ remote | host | namespace | project
+ ${'git@gitlab.com:fatihacet/gitlab-vscode-extension.git'} | ${'gitlab.com'} | ${'fatihacet'} | ${'gitlab-vscode-extension'}
+ ${'gitlab-ci@gitlab-mydomain.com:fatihacet/gitlab-vscode-extension.git'} | ${'gitlab-mydomain.com'} | ${'fatihacet'} | ${'gitlab-vscode-extension'}
+ ${'ssh://git@gitlab.com:fatihacet/gitlab-vscode-extension.git'} | ${'gitlab.com'} | ${'fatihacet'} | ${'gitlab-vscode-extension'}
+ ${'git://git@gitlab.com:fatihacet/gitlab-vscode-extension.git'} | ${'gitlab.com'} | ${'fatihacet'} | ${'gitlab-vscode-extension'}
+ ${'http://git@gitlab.com/fatihacet/gitlab-vscode-extension.git'} | ${'gitlab.com'} | ${'fatihacet'} | ${'gitlab-vscode-extension'}
+ ${'http://gitlab.com/fatihacet/gitlab-vscode-extension.git'} | ${'gitlab.com'} | ${'fatihacet'} | ${'gitlab-vscode-extension'}
+ ${'https://git@gitlab.com/fatihacet/gitlab-vscode-extension.git'} | ${'gitlab.com'} | ${'fatihacet'} | ${'gitlab-vscode-extension'}
+ ${'https://gitlab.com/fatihacet/gitlab-vscode-extension.git'} | ${'gitlab.com'} | ${'fatihacet'} | ${'gitlab-vscode-extension'}
+ ${'https://gitlab.com/fatihacet/gitlab-vscode-extension'} | ${'gitlab.com'} | ${'fatihacet'} | ${'gitlab-vscode-extension'}
+ ${'https://gitlab.company.com/fatihacet/gitlab-vscode-extension.git'} | ${'gitlab.company.com'} | ${'fatihacet'} | ${'gitlab-vscode-extension'}
+ ${'https://gitlab.company.com:844/fatihacet/gitlab-vscode-extension.git'} | ${'gitlab.company.com:8443'} | ${'fatihacet'} | ${'gitlab-vscode-extension'}
`('should parse $input', ({ remote, host, namespace, project }) => {
expect(parseGitRemote('https://gitlab.com', remote)).toEqual({ host, namespace, project });
});