From 90ecae9491a5960940e257acb1bb08a295b6b64f Mon Sep 17 00:00:00 2001 From: Lambert Lee <33386249+azlis@users.noreply.github.com> Date: Fri, 27 Jan 2023 20:09:07 +0800 Subject: [PATCH] test: add menu unit test improve code coverage (#401) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: rename action name * doc: 增加注释 * test: add IsDisabled unit test * test: update IsDisabled unit test Co-authored-by: Argo Zhang Co-authored-by: lambert lee --- ...rom_issue.yml => auto_sync_from_issue.yml} | 2 +- .github/workflows/build.yml | 2 +- .github/workflows/deploy.yml | 2 +- .github/workflows/docker.yml | 2 +- .github/workflows/pack.yml | 2 +- .github/workflows/publish.yml | 2 +- BootstrapBlazor.sln | 2 +- .../Components/Menu/SubMenu.razor.cs | 2 +- test/UnitTest/Components/MenuTest.cs | 35 +++++++++++++++++++ 9 files changed, 43 insertions(+), 8 deletions(-) rename .github/workflows/{sync_from_issue.yml => auto_sync_from_issue.yml} (99%) diff --git a/.github/workflows/sync_from_issue.yml b/.github/workflows/auto_sync_from_issue.yml similarity index 99% rename from .github/workflows/sync_from_issue.yml rename to .github/workflows/auto_sync_from_issue.yml index 2b7409d11..999fbaec4 100644 --- a/.github/workflows/sync_from_issue.yml +++ b/.github/workflows/auto_sync_from_issue.yml @@ -1,4 +1,4 @@ -name: sync issue to PR(bot) +name: auto sync issue to PR(bot) on: pull_request: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 39fb5bb49..6f56d9c4b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build Project +name: buid project on: push: diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a99a5725f..6cb0d1bb1 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,4 +1,4 @@ -name: Deploy To Huawei VM +name: deploy to Huawei VM on: push: diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 491fde74a..5f8fc3773 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,4 +1,4 @@ -name: Docker Image CI +name: build docker image on: push: diff --git a/.github/workflows/pack.yml b/.github/workflows/pack.yml index 7580fecc6..1e404db85 100644 --- a/.github/workflows/pack.yml +++ b/.github/workflows/pack.yml @@ -1,4 +1,4 @@ -name: Package to Nuget +name: build nuget package on: push: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1cbbab333..1e29e860f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,4 +1,4 @@ -name: Deploy To Pages +name: deploy to github pages on: push: diff --git a/BootstrapBlazor.sln b/BootstrapBlazor.sln index d8ef242e3..84717b5b1 100644 --- a/BootstrapBlazor.sln +++ b/BootstrapBlazor.sln @@ -42,12 +42,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "github", "github", "{F07542 .github\workflows\auto_comment_issue.yml = .github\workflows\auto_comment_issue.yml .github\workflows\auto_pull_request_checks.yml = .github\workflows\auto_pull_request_checks.yml .github\workflows\build.yml = .github\workflows\build.yml + .github\workflows\auto_sync_from_issue.yml = .github\workflows\auto_sync_from_issue.yml .github\workflows\deploy.yml = .github\workflows\deploy.yml .github\workflows\docker.yml = .github\workflows\docker.yml .github\workflows\pack.yml = .github\workflows\pack.yml .github\workflows\publish.yml = .github\workflows\publish.yml .github\workflows\release.yml = .github\workflows\release.yml - .github\workflows\sync_from_issue.yml = .github\workflows\sync_from_issue.yml EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{9437A6C6-CF87-4B75-916B-C1EF558BD8EF}" diff --git a/src/BootstrapBlazor/Components/Menu/SubMenu.razor.cs b/src/BootstrapBlazor/Components/Menu/SubMenu.razor.cs index 8226facf5..868a21a09 100644 --- a/src/BootstrapBlazor/Components/Menu/SubMenu.razor.cs +++ b/src/BootstrapBlazor/Components/Menu/SubMenu.razor.cs @@ -47,7 +47,7 @@ public sealed partial class SubMenu private IStringLocalizer? Localizer { get; set; } /// - /// + /// 获得 样式字符串 /// /// /// diff --git a/test/UnitTest/Components/MenuTest.cs b/test/UnitTest/Components/MenuTest.cs index 068460bbf..7743bc6c3 100644 --- a/test/UnitTest/Components/MenuTest.cs +++ b/test/UnitTest/Components/MenuTest.cs @@ -227,6 +227,41 @@ public class MenuTest : BootstrapBlazorTestBase Assert.Contains("is-collapsed", cut.Markup); } + [Fact] + public void IsDisabled_Ok() + { + var items = new List() + { + new("Menu1") + { + Icon = "fa-solid fa-font-awesome", + Url = "https://www.blazor.zone", + Items = new List() + { + new("Menu2") + { + Icon = "fa-solid fa-fw fa-font-awesome", + Items = new List() + { + new("Menu3") + { + IsActive = true, + IsDisabled = true, + Icon = "fa-solid fa-fw fa-font-awesome" + } + } + } + } + }, + }; + var cut = Context.RenderComponent(pb => + { + pb.Add(m => m.Items, items); + }); + Assert.Contains("disabled", cut.Markup); + Assert.DoesNotContain("active", cut.Markup); + } + [Fact] public void IsAccordion_Ok() {