-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathannouncementstest.cpp
43 lines (35 loc) · 1.69 KB
/
announcementstest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstraste.com>
// SPDX-License-Identifier: GPL-3.0-or-later
#include "account/accountmanager.h"
#include "account/announcementmodel.h"
#include "autotests/helperreply.h"
#include "autotests/mockaccount.h"
#include <QtTest/QtTest>
class AnnouncementsTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase()
{
AccountManager::instance().setTestMode(true);
account = new MockAccount();
AccountManager::instance().addAccount(account);
}
void testModel()
{
QUrl url = account->apiUrl(QStringLiteral("/api/v1/announcements"));
account->registerGet(url, new TestReply(QStringLiteral("announcements.json"), account));
AnnouncementModel announcementsModel;
QCOMPARE(announcementsModel.rowCount({}), 1);
QCOMPARE(announcementsModel.data(announcementsModel.index(0, 0), AnnouncementModel::IdRole).toInt(), 8);
QCOMPARE(announcementsModel.data(announcementsModel.index(0, 0), AnnouncementModel::ContentRole).toString(),
QStringLiteral("<p>Looks like there was an issue processing audio attachments without embedded art since yesterday due to an experimental new "
"feature. That issue has now been fixed, so you may see older posts with audio from other servers pop up in your feeds now as "
"they are being finally properly processed. Sorry!</p>"));
Q_ASSERT(announcementsModel.data(announcementsModel.index(0, 0), AnnouncementModel::PublishedAtRole).toDate().isValid());
}
private:
MockAccount *account;
};
QTEST_MAIN(AnnouncementsTest)
#include "announcementstest.moc"