summaryrefslogtreecommitdiff
path: root/battleNetApi/tests
diff options
context:
space:
mode:
authorAotrix <[email protected]>2026-01-26 23:31:02 +0100
committerAotrix <[email protected]>2026-01-26 23:31:02 +0100
commitab280e7beef86d95335d0538fa1f6a6dfdd1125b (patch)
tree84a74caddf998a2483f62a73d181521ec0622e3b /battleNetApi/tests
parentfeac00e6819a9c9ad640a586d2fabb9e4e43f41e (diff)
added a test to count the number of cards
Diffstat (limited to 'battleNetApi/tests')
-rw-r--r--battleNetApi/tests/tests.cpp32
1 files changed, 19 insertions, 13 deletions
diff --git a/battleNetApi/tests/tests.cpp b/battleNetApi/tests/tests.cpp
index 550e2ca..611cf83 100644
--- a/battleNetApi/tests/tests.cpp
+++ b/battleNetApi/tests/tests.cpp
@@ -1,7 +1,8 @@
#include "apiUrl.hpp"
#include "hearthstoneApi.hpp"
#include <catch2/catch_test_macros.hpp>
-#include <utility>
+#include <iostream>
+#include <nlohmann/json.hpp>
TEST_CASE("Retrieve API Token", "[generateApiToken]") {
const std::string kCredentialsFile{"tests/resources/credentials.json"};
@@ -12,18 +13,23 @@ TEST_CASE("Retrieve API Token", "[generateApiToken]") {
REQUIRE(kTokenSize <= 40);
}
-// TEST_CASE("Retrieve number of cards", "[getCardsCount]") {
-// HearthstoneApiMock aHearthstoneApi;
-// const std::string kContentType{"cards"};
-// const std::string kRegion{"eu"};
-// ApiUrl aApiUrl(kContentType, kRegion);
-// aApiUrl.setLocale("fr_FR");
-// aApiUrl.setGameMode("constructed");
-// aApiUrl.setPageSize("1");
-// std::uint64_t kNumberOfCards{aHearthstoneApi.numberOfCards(aHearthstoneApi.makeApiRequest(aApiUrl()))};
-// REQUIRE(kNumberOfCards == 6033);
-// }
-//
+TEST_CASE("Retrieve number of cards", "[getCardsCount]") {
+ const std::string kCredentialsFile{"tests/resources/credentials.json"};
+ Token aToken(kCredentialsFile);
+ HearthstoneApi aHearthstoneApi(aToken);
+ const std::string kContentType{"cards"};
+ const std::string kRegion{"eu"};
+ ApiUrl aApiUrl(kContentType, kRegion);
+ aApiUrl.setLocale("fr_FR");
+ aApiUrl.setGameMode("constructed");
+ aApiUrl.setPageSize("1");
+ const json kResponse{aHearthstoneApi.makeApiRequest(aApiUrl())};
+ REQUIRE(kResponse.size() > 0);
+ REQUIRE(kResponse[0].contains("pageCount"));
+ std::uint64_t kNumberOfCards{kResponse[0]["pageCount"]};
+ REQUIRE(kNumberOfCards == 6033);
+}
+
// TEST_CASE("Retrieve cards", "[retrieveCards]") {
// HearthstoneApiMock aHearthstoneApi;
// const std::string kContentType{"cards"};