Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit ddc6620

Browse files
committed
Check that /blob/ URLs can be opened
Also check that changing from a valid repository/blob URL to an invalid URL causes the Clone/Open buttons to become inactive.
1 parent e96f0b8 commit ddc6620

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/GitHub.App.UnitTests/ViewModels/Dialog/Clone/RepositorySelectViewModelTests.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ public async Task Filter(string filter, string owner, string name, string url, i
5757
[TestCase("filter", null)]
5858
[TestCase("https://github.com", null)]
5959
[TestCase("https://github.com/github/VisualStudio", "https://github.com/github/VisualStudio")]
60+
[TestCase("https://github.com/github/VisualStudio/blob/master/README.md", "https://github.com/github/VisualStudio/blob/master/README.md")]
61+
[TestCase("https://github.com/github/VisualStudio/pull/2208", null)]
6062
public void Set_Repository_When_Filter_Is_Url(string url, string expectUrl)
6163
{
6264
var expectCloneUrl = expectUrl != null ? new UriString(expectUrl) : null;
@@ -69,6 +71,24 @@ public void Set_Repository_When_Filter_Is_Url(string url, string expectUrl)
6971

7072
Assert.That(target.Repository?.CloneUrl, Is.EqualTo(expectCloneUrl));
7173
}
74+
75+
[TestCase("filter;https://github.com/github/VisualStudio", "https://github.com/github/VisualStudio")]
76+
[TestCase("https://github.com/github/VisualStudio;filter", null)]
77+
public void Change_Filters(string filters, string expectUrl)
78+
{
79+
var expectCloneUrl = expectUrl != null ? new UriString(expectUrl) : null;
80+
var repositoryCloneService = CreateRepositoryCloneService();
81+
var gitHubContextService = new GitHubContextService(Substitute.For<IGitHubServiceProvider>(),
82+
Substitute.For<IGitService>(), Substitute.For<IVSServices>());
83+
var target = new RepositorySelectViewModel(repositoryCloneService, gitHubContextService);
84+
85+
foreach (var filter in filters.Split(';'))
86+
{
87+
target.Filter = filter;
88+
}
89+
90+
Assert.That(target.Repository?.CloneUrl, Is.EqualTo(expectCloneUrl));
91+
}
7292
}
7393

7494
static IGitHubContextService CreateGitHubContextService()

0 commit comments

Comments
 (0)