File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
LinkDotNet.Blog.UnitTests/Web/Shared/Skills
LinkDotNet.Blog.Web/Shared/Skills Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ public void ShouldRenderImageAndText()
19
19
20
20
cut . Find ( "span" ) . TextContent . Should ( ) . Contain ( "C#" ) ;
21
21
cut . Find ( "img" ) . Attributes . Single ( a => a . Name == "src" ) . Value . Should ( ) . Be ( "test" ) ;
22
+ cut . FindAll ( "button" ) . Should ( ) . HaveCount ( 0 ) ;
22
23
}
23
24
24
25
[ Fact ]
@@ -31,5 +32,21 @@ public void ShouldNotRenderImageWhenNotAvailable()
31
32
32
33
cut . FindAll ( "img" ) . Should ( ) . HaveCount ( 0 ) ;
33
34
}
35
+
36
+ [ Fact ]
37
+ public void ShouldInvokeDeleteEvent ( )
38
+ {
39
+ var skill = new SkillBuilder ( ) . Build ( ) ;
40
+ var wasInvoked = false ;
41
+ var cut = RenderComponent < SkillTag > ( p => p
42
+ . Add (
43
+ s => s . Skill , skill )
44
+ . Add ( s => s . IsAuthenticated , true )
45
+ . Add ( s => s . DeleteSkill , ( ) => wasInvoked = true ) ) ;
46
+
47
+ cut . Find ( "button" ) . Click ( ) ;
48
+
49
+ wasInvoked . Should ( ) . BeTrue ( ) ;
50
+ }
34
51
}
35
52
}
Original file line number Diff line number Diff line change 6
6
<img src =" @Skill.IconUrl" alt =" icon" />
7
7
}
8
8
@Skill.Name
9
+
10
+ @if (IsAuthenticated )
11
+ {
12
+ <button type =" button" class =" btn btn-default" aria-label =" Delete Skill" @onclick =" () => DeleteSkill.InvokeAsync()" >
13
+ <i class =" fas fa-trash-alt" aria-hidden =" true" ></i >
14
+ </button >
15
+ }
9
16
</span >
10
17
11
18
@code {
12
19
[Parameter ]
13
20
public Skill Skill { get ; set ; }
21
+
22
+ [Parameter ]
23
+ public bool IsAuthenticated { get ; set ; }
24
+
25
+ [Parameter ]
26
+ public EventCallback DeleteSkill { get ; set ; }
14
27
}
You can’t perform that action at this time.
0 commit comments