mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
refactor: move MessageBuilder snapshot test to IrcMessageHandler (#5654)
This commit is contained in:
parent
800f6df2cf
commit
a8d60b0b05
|
@ -103,7 +103,7 @@
|
||||||
- Dev: Added more tests for input completion. (#5604)
|
- Dev: Added more tests for input completion. (#5604)
|
||||||
- Dev: Refactored legacy Unicode zero-width-joiner replacement. (#5594)
|
- Dev: Refactored legacy Unicode zero-width-joiner replacement. (#5594)
|
||||||
- Dev: The JSON output when copying a message (<kbd>SHIFT</kbd> + right-click) is now more extensive. (#5600)
|
- Dev: The JSON output when copying a message (<kbd>SHIFT</kbd> + right-click) is now more extensive. (#5600)
|
||||||
- Dev: Added more tests for message building. (#5598)
|
- Dev: Added more tests for message building. (#5598, #5654)
|
||||||
- Dev: Twitch messages are now sent using Twitch's Helix API instead of IRC by default. (#5607)
|
- Dev: Twitch messages are now sent using Twitch's Helix API instead of IRC by default. (#5607)
|
||||||
- Dev: `GIFTimer` is no longer initialized in tests. (#5608)
|
- Dev: `GIFTimer` is no longer initialized in tests. (#5608)
|
||||||
- Dev: Emojis now use flags instead of a set of strings for capabilities. (#5616)
|
- Dev: Emojis now use flags instead of a set of strings for capabilities. (#5616)
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
class TestMessageBuilderP;
|
class TestIrcMessageHandlerP;
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
@ -464,7 +464,7 @@ private:
|
||||||
friend class MessageBuilder;
|
friend class MessageBuilder;
|
||||||
friend class IrcMessageHandler;
|
friend class IrcMessageHandler;
|
||||||
friend class Commands_E2E_Test;
|
friend class Commands_E2E_Test;
|
||||||
friend class ::TestMessageBuilderP;
|
friend class ::TestIrcMessageHandlerP;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -22,7 +22,7 @@ set(test_SOURCES
|
||||||
${CMAKE_CURRENT_LIST_DIR}/src/UtilTwitch.cpp
|
${CMAKE_CURRENT_LIST_DIR}/src/UtilTwitch.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/src/IrcHelpers.cpp
|
${CMAKE_CURRENT_LIST_DIR}/src/IrcHelpers.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/src/TwitchPubSubClient.cpp
|
${CMAKE_CURRENT_LIST_DIR}/src/TwitchPubSubClient.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/src/MessageBuilder.cpp
|
${CMAKE_CURRENT_LIST_DIR}/src/IrcMessageHandler.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/src/HighlightController.cpp
|
${CMAKE_CURRENT_LIST_DIR}/src/HighlightController.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/src/FormatTime.cpp
|
${CMAKE_CURRENT_LIST_DIR}/src/FormatTime.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/src/LimitedQueue.cpp
|
${CMAKE_CURRENT_LIST_DIR}/src/LimitedQueue.cpp
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "messages/MessageBuilder.hpp"
|
#include "providers/twitch/IrcMessageHandler.hpp"
|
||||||
|
|
||||||
#include "common/Literals.hpp"
|
#include "common/Literals.hpp"
|
||||||
#include "controllers/accounts/AccountController.hpp"
|
#include "controllers/accounts/AccountController.hpp"
|
||||||
|
@ -20,7 +20,6 @@
|
||||||
#include "providers/seventv/SeventvBadges.hpp"
|
#include "providers/seventv/SeventvBadges.hpp"
|
||||||
#include "providers/twitch/api/Helix.hpp"
|
#include "providers/twitch/api/Helix.hpp"
|
||||||
#include "providers/twitch/ChannelPointReward.hpp"
|
#include "providers/twitch/ChannelPointReward.hpp"
|
||||||
#include "providers/twitch/IrcMessageHandler.hpp"
|
|
||||||
#include "providers/twitch/TwitchAccount.hpp"
|
#include "providers/twitch/TwitchAccount.hpp"
|
||||||
#include "providers/twitch/TwitchBadge.hpp"
|
#include "providers/twitch/TwitchBadge.hpp"
|
||||||
#include "providers/twitch/TwitchBadges.hpp"
|
#include "providers/twitch/TwitchBadges.hpp"
|
||||||
|
@ -56,7 +55,7 @@ namespace {
|
||||||
/// to generate an initial snapshot. Make sure to verify the output!
|
/// to generate an initial snapshot. Make sure to verify the output!
|
||||||
constexpr bool UPDATE_SNAPSHOTS = false;
|
constexpr bool UPDATE_SNAPSHOTS = false;
|
||||||
|
|
||||||
const QString IRC_CATEGORY = u"MessageBuilder/IRC"_s;
|
const QString IRC_CATEGORY = u"IrcMessageHandler"_s;
|
||||||
|
|
||||||
class MockApplication : public mock::BaseApplication
|
class MockApplication : public mock::BaseApplication
|
||||||
{
|
{
|
||||||
|
@ -447,12 +446,12 @@ QT_WARNING_POP
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
class TestMessageBuilderP : public ::testing::TestWithParam<QString>
|
class TestIrcMessageHandlerP : public ::testing::TestWithParam<QString>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void SetUp() override
|
void SetUp() override
|
||||||
{
|
{
|
||||||
auto param = TestMessageBuilderP::GetParam();
|
auto param = TestIrcMessageHandlerP::GetParam();
|
||||||
this->snapshot = testlib::Snapshot::read(IRC_CATEGORY, param);
|
this->snapshot = testlib::Snapshot::read(IRC_CATEGORY, param);
|
||||||
|
|
||||||
this->mockApplication =
|
this->mockApplication =
|
||||||
|
@ -558,7 +557,7 @@ public:
|
||||||
/// `IrcMesssageHandler` to ensure the correct (or: "real") arguments to build
|
/// `IrcMesssageHandler` to ensure the correct (or: "real") arguments to build
|
||||||
/// messages.
|
/// messages.
|
||||||
///
|
///
|
||||||
/// Tests are contained in `tests/snapshots/MessageBuilder/IRC`. Fixtures
|
/// Tests are contained in `tests/snapshots/IrcMessageHandler`. Fixtures
|
||||||
/// consist of an object with the keys `input`, `output`, `settings` (optional),
|
/// consist of an object with the keys `input`, `output`, `settings` (optional),
|
||||||
/// and `params` (optional).
|
/// and `params` (optional).
|
||||||
///
|
///
|
||||||
|
@ -569,7 +568,7 @@ public:
|
||||||
/// - `prevMessages`: An array of past messages (used for replies)
|
/// - `prevMessages`: An array of past messages (used for replies)
|
||||||
/// - `findAllUsernames`: A boolean controlling the equally named setting
|
/// - `findAllUsernames`: A boolean controlling the equally named setting
|
||||||
/// (default: false)
|
/// (default: false)
|
||||||
TEST_P(TestMessageBuilderP, Run)
|
TEST_P(TestIrcMessageHandlerP, Run)
|
||||||
{
|
{
|
||||||
auto channel = makeMockTwitchChannel(u"pajlada"_s, *snapshot);
|
auto channel = makeMockTwitchChannel(u"pajlada"_s, *snapshot);
|
||||||
|
|
||||||
|
@ -608,10 +607,10 @@ TEST_P(TestMessageBuilderP, Run)
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
IrcMessage, TestMessageBuilderP,
|
IrcMessage, TestIrcMessageHandlerP,
|
||||||
testing::ValuesIn(testlib::Snapshot::discover(IRC_CATEGORY)));
|
testing::ValuesIn(testlib::Snapshot::discover(IRC_CATEGORY)));
|
||||||
|
|
||||||
TEST(TestMessageBuilderP, Integrity)
|
TEST(TestIrcMessageHandlerP, Integrity)
|
||||||
{
|
{
|
||||||
ASSERT_FALSE(UPDATE_SNAPSHOTS); // make sure fixtures are actually tested
|
ASSERT_FALSE(UPDATE_SNAPSHOTS); // make sure fixtures are actually tested
|
||||||
}
|
}
|
Loading…
Reference in a new issue