-
-
Notifications
You must be signed in to change notification settings - Fork 425
test: add tests for useRepositoryUrl composable #2249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
aaeed30
1a301a2
09a6ac2
a388dbb
89509f7
0103106
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
|
|
||
| /** | ||
| * Tests for useRepositoryUrl composable. | ||
| * | ||
| * Regression tests for GitHub issue #2233: monorepo packages with .git suffix | ||
| * in repository.url generated broken source links like: | ||
| * https://github.com/org/repo.git/tree/HEAD/packages/foo (404) | ||
| * instead of: | ||
| * https://github.com/org/repo/tree/HEAD/packages/foo | ||
| */ | ||
| describe('useRepositoryUrl', () => { | ||
| it('should strip .git from repository URL', () => { | ||
| const { repositoryUrl } = useRepositoryUrl( | ||
| ref({ | ||
|
Check failure on line 15 in test/nuxt/composables/use-repository-url.spec.ts
|
||
| repository: { | ||
| type: 'git', | ||
| url: 'git+https://github.com/agentmarkup/agentmarkup.git', | ||
| }, | ||
| }), | ||
| ) | ||
|
|
||
| expect(repositoryUrl.value).toBe('https://github.com/agentmarkup/agentmarkup') | ||
| }) | ||
|
|
||
| it('should append /tree/HEAD/{directory} for monorepo packages without .git', () => { | ||
| const { repositoryUrl } = useRepositoryUrl( | ||
| ref({ | ||
|
Check failure on line 28 in test/nuxt/composables/use-repository-url.spec.ts
|
||
| repository: { | ||
| type: 'git', | ||
| url: 'git+https://github.com/agentmarkup/agentmarkup.git', | ||
| directory: 'packages/vite', | ||
| }, | ||
| }), | ||
| ) | ||
|
|
||
| expect(repositoryUrl.value).toBe( | ||
| 'https://github.com/agentmarkup/agentmarkup/tree/HEAD/packages/vite', | ||
| ) | ||
| }) | ||
|
|
||
| it('should return null when repository has no url', () => { | ||
| const { repositoryUrl } = useRepositoryUrl( | ||
| ref({ | ||
|
Check failure on line 44 in test/nuxt/composables/use-repository-url.spec.ts
|
||
| repository: {}, | ||
| }), | ||
| ) | ||
|
|
||
| expect(repositoryUrl.value).toBeNull() | ||
| }) | ||
|
|
||
| it('should return null when no repository field', () => { | ||
| const { repositoryUrl } = useRepositoryUrl(ref({})) | ||
|
|
||
| expect(repositoryUrl.value).toBeNull() | ||
| }) | ||
|
|
||
| it('should handle plain HTTPS URLs without .git suffix', () => { | ||
| const { repositoryUrl } = useRepositoryUrl( | ||
| ref({ | ||
|
Check failure on line 60 in test/nuxt/composables/use-repository-url.spec.ts
|
||
| repository: { | ||
| url: 'https://github.com/nuxt/ui', | ||
| }, | ||
| }), | ||
| ) | ||
|
|
||
| expect(repositoryUrl.value).toBe('https://github.com/nuxt/ui') | ||
| }) | ||
|
|
||
| it('should handle directory with trailing slash', () => { | ||
| const { repositoryUrl } = useRepositoryUrl( | ||
| ref({ | ||
|
Check failure on line 72 in test/nuxt/composables/use-repository-url.spec.ts
|
||
| repository: { | ||
| url: 'git+https://github.com/org/repo.git', | ||
| directory: 'packages/core/', | ||
| }, | ||
| }), | ||
| ) | ||
|
|
||
| expect(repositoryUrl.value).toBe('https://github.com/org/repo/tree/HEAD/packages/core/') | ||
| }) | ||
| }) | ||
Uh oh!
There was an error while loading. Please reload this page.