-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathlistsmodeltest.cpp
39 lines (31 loc) · 1.1 KB
/
listsmodeltest.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
// SPDX-FileCopyrightText: 2023 Joshua Goins <[email protected]>
// SPDX-License-Identifier: GPL-3.0-or-later
#include "account/listsmodel.h"
#include "account/accountmanager.h"
#include "autotests/helperreply.h"
#include "autotests/mockaccount.h"
#include <QtTest/QtTest>
class ListsModelTest : 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/lists"));
account->registerGet(url, new TestReply(QStringLiteral("lists.json"), account));
ListsModel listsModel;
QCOMPARE(listsModel.rowCount({}), 2);
QCOMPARE(listsModel.data(listsModel.index(0, 0), ListsModel::IdRole).toInt(), 12249);
QCOMPARE(listsModel.data(listsModel.index(0, 0), ListsModel::TitleRole).toString(), QStringLiteral("Friends"));
}
private:
MockAccount *account = nullptr;
};
QTEST_MAIN(ListsModelTest)
#include "listsmodeltest.moc"