summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_config.cpp35
-rw-r--r--tests/test_mainwindow.cpp3
2 files changed, 35 insertions, 3 deletions
diff --git a/tests/test_config.cpp b/tests/test_config.cpp
index dd34e4f..70e3705 100644
--- a/tests/test_config.cpp
+++ b/tests/test_config.cpp
@@ -129,6 +129,8 @@ private slots:
void theDraftsFilterIsFlatLikeSent();
void theTrashFilterComposesPerAccount();
void theTrashFilterMatchesNothingWithoutAFolder();
+ void theSpamFilterComposesPerAccount();
+ void theSpamFilterMatchesNothingWithoutAFolder();
void anAccountWithoutASendCommandIsReceiveOnly();
void composeSettingsDefaultWhenTheSectionIsAbsent();
void aZeroSendDelayIsHonouredRatherThanTreatedAsUnset();
@@ -1198,6 +1200,34 @@ void TestConfig::theTrashFilterMatchesNothingWithoutAFolder()
QCOMPARE(config.resolvedQuery(trash, QString()), Config::matchNothingQuery());
}
+void TestConfig::theSpamFilterComposesPerAccount()
+{
+ QTemporaryDir dir;
+ Config config;
+ config.load(writeIni(dir, QStringLiteral(
+ "[account.work]\nmaildir=work\nspam=Spam\n"
+ "\n[account.personal]\nmaildir=personal\nspam=[Provider]/Spam\n")));
+ const SavedQuery spam = Config::builtinFilter(QStringLiteral("spam"));
+ QVERIFY(spam.isGenerated());
+ QVERIFY2(!spam.flat, "spam must be threaded, like trash");
+ const QString all = config.resolvedQuery(spam, QString());
+ QVERIFY(all.contains(QStringLiteral("path:\"work/Spam/**\"")));
+ QVERIFY(all.contains(QStringLiteral("path:\"personal/[Provider]/Spam/**\"")));
+ const QString scoped = config.resolvedQuery(spam, QStringLiteral("work"));
+ QCOMPARE(scoped, QStringLiteral("path:\"work/Spam/**\""));
+ QVERIFY(!scoped.contains(QStringLiteral("personal")));
+}
+
+void TestConfig::theSpamFilterMatchesNothingWithoutAFolder()
+{
+ QTemporaryDir dir;
+ Config config;
+ config.load(writeIni(dir, QStringLiteral(
+ "[account.work]\nmaildir=work\n")));
+ const SavedQuery spam = Config::builtinFilter(QStringLiteral("spam"));
+ QCOMPARE(config.resolvedQuery(spam, QString()), Config::matchNothingQuery());
+}
+
void TestConfig::sentQueryComposesWithScopedQuery()
{
// A Sent view under one account must not show another account's sent mail.
@@ -1628,7 +1658,7 @@ void TestConfig::everyBuiltinFilterIsAKnownGenerator()
Config config;
const QList<SavedQuery> filters = config.builtinFilters();
- QCOMPARE(filters.size(), 6);
+ QCOMPARE(filters.size(), 7);
QStringList names;
for (const SavedQuery &filter : filters) {
@@ -1651,7 +1681,8 @@ void TestConfig::everyBuiltinFilterIsAKnownGenerator()
QStringLiteral("Important"),
QStringLiteral("Sent"),
QStringLiteral("Drafts"),
- QStringLiteral("Trash") }));
+ QStringLiteral("Trash"),
+ QStringLiteral("Spam") }));
}
void TestConfig::aFilterAcrossAllAccountsIsTheUnscopedQuery()
diff --git a/tests/test_mainwindow.cpp b/tests/test_mainwindow.cpp
index b7f7846..9a38a95 100644
--- a/tests/test_mainwindow.cpp
+++ b/tests/test_mainwindow.cpp
@@ -11008,12 +11008,13 @@ void TestMainWindow::everyBuiltinFilterButtonCarriesAnIconAndItsText()
});
// A trash key too, or the Trash filter finds nothing and is skipped from
// the row entirely (item 103), leaving no trashButton for this loop to
- // find. Drafts behaves the same way since item 138.
+ // find. Drafts and Spam behave the same way since item 138.
{
QSettings s(path, QSettings::IniFormat);
s.beginGroup(QStringLiteral("account.work"));
s.setValue(QStringLiteral("trash"), QStringLiteral("Trash"));
s.setValue(QStringLiteral("drafts"), QStringLiteral("Drafts"));
+ s.setValue(QStringLiteral("spam"), QStringLiteral("Spam"));
s.endGroup();
}
Config config;