-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4a1905
commit f175cba
Showing
6 changed files
with
241 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
using Bunit; | ||
|
||
using Blashing.Core.Components.List; | ||
|
||
namespace Blashing.Core.Tests; | ||
|
||
public class ListWidgetTest : TestContext | ||
{ | ||
[Fact] | ||
public void TextWidgetMarkupShouldContainPassedInValues() | ||
{ | ||
var title = "a"; | ||
var moreInfo = "c"; | ||
var updatedAtMessage = "d"; | ||
var items = new List<(string label, string value)>() { ("a", "b"), ("c", "d") }; | ||
|
||
var cut = RenderComponent<ListWidget>(parameters => parameters | ||
.Add(p => p.Title, title) | ||
.Add(p => p.MoreInfo, moreInfo) | ||
.Add(p => p.UpdatedAtMessage, updatedAtMessage) | ||
.Add(p => p.Items, items) | ||
); | ||
|
||
// var widget = @" | ||
// <div class=""widget-list""> | ||
// <h1 class=""title"">List Title</h1> | ||
// <ol> | ||
// <li> | ||
// <span class=""label"">a</span> | ||
// <span class=""value"">b</span> | ||
// </li> | ||
// <li> | ||
// <span class=""label"">c</span> | ||
// <span class=""value"">d</span> | ||
// </li> | ||
// </ol> | ||
// <ul class=""list-nostyle""> | ||
// <li> | ||
// <span class=""label"">a</span> | ||
// <span class=""value"">b</span> | ||
// </li> | ||
// <li> | ||
// <span class=""label"">c</span> | ||
// <span class=""value"">d</span> | ||
// </li> | ||
// </ul> | ||
// <p class=""more-info"">List Title More Info</p> | ||
// <p class=""updated-at"">24 June 2023</p> | ||
// </div>"; | ||
|
||
var expectedTitleMarkup = $"<h1 class=\"title\">{title}</h1>"; | ||
cut.FindAll("h1")[0].MarkupMatches(expectedTitleMarkup); | ||
|
||
var expectedMoreInfoMarkup = $"<p class=\"more-info\">{moreInfo}</p>"; | ||
cut.FindAll("p")[0].MarkupMatches(expectedMoreInfoMarkup); | ||
|
||
var expectedUpdatedAtMessageMarkup = $"<p class=\"updated-at\">{updatedAtMessage}</p>"; | ||
cut.FindAll("p")[1].MarkupMatches(expectedUpdatedAtMessageMarkup); | ||
} | ||
|
||
[Fact] | ||
public void TextWidgetShouldContainPassedInValues() | ||
{ | ||
var title = "a"; | ||
var moreInfo = "c"; | ||
var updatedAtMessage = "d"; | ||
var items = new List<(string label, string value)>() { ("a", "b"), ("c", "d") }; | ||
|
||
var cut = RenderComponent<ListWidget>(parameters => parameters | ||
.Add(p => p.Title, title) | ||
.Add(p => p.MoreInfo, moreInfo) | ||
.Add(p => p.UpdatedAtMessage, updatedAtMessage) | ||
.Add(p => p.Items, items) | ||
); | ||
|
||
var textWidget = cut.Instance; | ||
Assert.Equal(textWidget.Title, title); | ||
Assert.Equal(textWidget.MoreInfo, moreInfo); | ||
Assert.Equal(textWidget.UpdatedAtMessage, updatedAtMessage); | ||
Assert.Equal(textWidget.Items, items); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<div class="widget-list"> | ||
<h1 class="title">@Title</h1> | ||
|
||
<ol> | ||
@foreach (var item in Items) | ||
{ | ||
<li> | ||
<span class="label">@item.label</span> | ||
<span class="value">@item.value</span> | ||
</li> | ||
} | ||
</ol> | ||
|
||
<ul class="list-nostyle"> | ||
@foreach (var item in Items) | ||
{ | ||
<li> | ||
<span class="label">@item.label</span> | ||
<span class="value">@item.value</span> | ||
</li> | ||
} | ||
</ul> | ||
|
||
<p class="more-info">@MoreInfo</p> | ||
<p class="updated-at">@UpdatedAtMessage</p> | ||
</div> | ||
|
||
@code { | ||
[Parameter] | ||
public string? Title { get; set; } | ||
|
||
[Parameter] | ||
public string? MoreInfo { get; set; } | ||
|
||
[Parameter] | ||
public string? UpdatedAtMessage { get; set; } | ||
|
||
[Parameter] | ||
public List<(string label, string value)>? Items { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
.widget-list { | ||
background-color: #12b0c5; | ||
vertical-align: top; | ||
} | ||
|
||
.title { | ||
color: rgba(255, 255, 255, 0.7); | ||
} | ||
|
||
ol, ul { | ||
margin: 0 15px; | ||
text-align: left; | ||
color: rgba(255, 255, 255, 0.7); | ||
} | ||
|
||
ol { | ||
list-style-position: inside; | ||
} | ||
|
||
li { | ||
margin-bottom: 5px; | ||
} | ||
|
||
.list-nostyle { | ||
list-style: none; | ||
} | ||
|
||
.label { | ||
color: rgba(255, 255, 255, 0.7); | ||
} | ||
|
||
.value { | ||
float: right; | ||
margin-left: 12px; | ||
font-weight: 600; | ||
color: #fff; | ||
} | ||
|
||
.updated-at { | ||
color: rgba(0, 0, 0, 0.3); | ||
} | ||
|
||
.more-info { | ||
color: rgba(255, 255, 255, 0.7); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// ---------------------------------------------------------------------------- | ||
// Sass declarations | ||
// ---------------------------------------------------------------------------- | ||
$background-color: #12b0c5; | ||
$value-color: #fff; | ||
|
||
$title-color: rgba(255, 255, 255, 0.7); | ||
$label-color: rgba(255, 255, 255, 0.7); | ||
$moreinfo-color: rgba(255, 255, 255, 0.7); | ||
|
||
// ---------------------------------------------------------------------------- | ||
// Widget-list styles | ||
// ---------------------------------------------------------------------------- | ||
.widget-list { | ||
|
||
background-color: $background-color; | ||
vertical-align: top; | ||
|
||
.title { | ||
color: $title-color; | ||
} | ||
|
||
ol, ul { | ||
margin: 0 15px; | ||
text-align: left; | ||
color: $label-color; | ||
} | ||
|
||
ol { | ||
list-style-position: inside; | ||
} | ||
|
||
li { | ||
margin-bottom: 5px; | ||
} | ||
|
||
.list-nostyle { | ||
list-style: none; | ||
} | ||
|
||
.label { | ||
color: $label-color; | ||
} | ||
|
||
.value { | ||
float: right; | ||
margin-left: 12px; | ||
font-weight: 600; | ||
color: $value-color; | ||
} | ||
|
||
.updated-at { | ||
color: rgba(0, 0, 0, 0.3); | ||
} | ||
|
||
.more-info { | ||
color: $moreinfo-color; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters