Skip to content

Commit a269e0f

Browse files
committed
refactor: use fluent assertions for htmx response tests
1 parent 5a6be96 commit a269e0f

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

test/Htmxor.Tests/Http/HtmxResponseTests.cs

+12-10
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ public void Location_AddsLocationHeader()
2828
response.Location("/new-location");
2929

3030
// Assert
31-
Assert.Equal("/new-location", context.Response.Headers[HtmxResponseHeaderNames.Location]);
31+
context.Response.Headers[HtmxResponseHeaderNames.Location]
32+
.Should()
33+
.Equal(["/new-location"]);
3234
}
3335

3436
[Fact]
@@ -68,7 +70,7 @@ public void PushUrl_AddsPushUrlHeader()
6870
response.PushUrl("/new-url");
6971

7072
// Assert
71-
Assert.Equal("/new-url", context.Response.Headers[HtmxResponseHeaderNames.PushUrl]);
73+
context.Response.Headers[HtmxResponseHeaderNames.PushUrl].Should().Equal(["/new-url"]);
7274
}
7375

7476
[Fact]
@@ -82,7 +84,7 @@ public void Redirect_AddsRedirectHeader()
8284
response.Redirect("/new-redirect");
8385

8486
// Assert
85-
Assert.Equal("/new-redirect", context.Response.Headers[HtmxResponseHeaderNames.Redirect]);
87+
context.Response.Headers[HtmxResponseHeaderNames.Redirect].Should().Equal(["/new-redirect"]);
8688
}
8789

8890
[Fact]
@@ -96,7 +98,7 @@ public void Refresh_AddsRefreshHeader()
9698
response.Refresh();
9799

98100
// Assert
99-
Assert.Equal("true", context.Response.Headers[HtmxResponseHeaderNames.Refresh]);
101+
context.Response.Headers[HtmxResponseHeaderNames.Refresh].Should().Equal(["true"]);
100102
}
101103

102104
[Fact]
@@ -110,7 +112,7 @@ public void ReplaceUrl_AddsReplaceUrlHeader()
110112
response.ReplaceUrl("/new-replace-url");
111113

112114
// Assert
113-
Assert.Equal("/new-replace-url", context.Response.Headers[HtmxResponseHeaderNames.ReplaceUrl]);
115+
context.Response.Headers[HtmxResponseHeaderNames.ReplaceUrl].Should().Equal(["/new-replace-url"]);
114116
}
115117

116118
[Fact]
@@ -124,7 +126,7 @@ public void PushUrl_AddsPushUrlBrowserHistoryHeader()
124126
response.PreventBrowserHistoryUpdate();
125127

126128
// Assert
127-
Assert.Equal("false", context.Response.Headers[HtmxResponseHeaderNames.PushUrl]);
129+
context.Response.Headers[HtmxResponseHeaderNames.PushUrl].Should().Equal(["false"]);
128130
}
129131

130132
[Fact]
@@ -138,7 +140,7 @@ public void ReplaceUrl_AddsReplaceUrlBrowserCUrrentUrlHeader()
138140
response.PreventBrowserCurrentUrlUpdate();
139141

140142
// Assert
141-
Assert.Equal("false", context.Response.Headers[HtmxResponseHeaderNames.ReplaceUrl]);
143+
context.Response.Headers[HtmxResponseHeaderNames.ReplaceUrl].Should().Equal(["false"]);
142144
}
143145

144146
[Fact]
@@ -152,7 +154,7 @@ public void Reswap_AddsReswapHeader()
152154
response.Reswap(SwapStyle.InnerHTML);
153155

154156
// Assert
155-
Assert.Equal("innerHTML", context.Response.Headers[HtmxResponseHeaderNames.Reswap]);
157+
context.Response.Headers[HtmxResponseHeaderNames.Reswap].Should().Equal(["innerHTML"]);
156158
}
157159

158160
[Fact]
@@ -166,7 +168,7 @@ public void Retarget_AddsRetargetHeader()
166168
response.Retarget(".new-target");
167169

168170
// Assert
169-
Assert.Equal(".new-target", context.Response.Headers[HtmxResponseHeaderNames.Retarget]);
171+
context.Response.Headers[HtmxResponseHeaderNames.Retarget].Should().Equal([".new-target"]);
170172
}
171173

172174
[Fact]
@@ -180,7 +182,7 @@ public void Reselect_AddsReselectHeader()
180182
response.Reselect(".new-selection");
181183

182184
// Assert
183-
Assert.Equal(".new-selection", context.Response.Headers[HtmxResponseHeaderNames.Reselect]);
185+
context.Response.Headers[HtmxResponseHeaderNames.Reselect].Should().Equal([".new-selection"]);
184186
}
185187

186188
[Theory]

0 commit comments

Comments
 (0)