Skip to content

Commit

Permalink
Compare full html document
Browse files Browse the repository at this point in the history
  • Loading branch information
timyates committed Dec 12, 2023
1 parent 634df1c commit 2ffc292
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,23 @@ class MessageControllerTest {
@Test
void contentNegotiation(@Client("/") HttpClient httpClient) { // <2>
BlockingHttpClient client = httpClient.toBlocking();
String expected = """

String expectedJson = """
{"message":"Hello World"}""";
String json = assertDoesNotThrow(() -> client.retrieve(HttpRequest.GET("/")
.accept(MediaType.APPLICATION_JSON))); // <3>
assertEquals(expected, json);
assertEquals(expectedJson, json);

String expectedHtml = """
<!DOCTYPE html>
<html lang="en">
<body>
<h1>Hello World</h1>
</body>
</html>
""";
String html = assertDoesNotThrow(() -> client.retrieve(HttpRequest.GET("/")
.accept(MediaType.TEXT_HTML)));
assertTrue(html.contains("<!DOCTYPE html>"));
assertTrue(html.contains("<h1>Hello World</h1>"));
assertEquals(expectedHtml, html);
}
}

0 comments on commit 2ffc292

Please sign in to comment.