From: David ‘Bombe’ Roden Date: Wed, 1 Jul 2020 20:13:57 +0000 (+0200) Subject: 🚚 Move new elements mock to test objects X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=fe880bd95f2f1bb155e890a9ffd2dc2abc86cb37;p=Sone.git 🚚 Move new elements mock to test objects --- diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/GetStatusAjaxPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/GetStatusAjaxPageTest.kt index fb06e19..651d839 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/GetStatusAjaxPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/ajax/GetStatusAjaxPageTest.kt @@ -38,10 +38,6 @@ class GetStatusAjaxPageTest: JsonPageTest("getStatus.ajax", requiresLogin = fals private val timeTextConverter = mock() private val l10nFilter = mock() - private val newElements = mock().apply { - whenever(newPosts).then { this@GetStatusAjaxPageTest.newPosts.values } - whenever(newReplies).then { this@GetStatusAjaxPageTest.newReplies.values } - } override var page: JsonPage = GetStatusAjaxPage(webInterface, elementLoader, newElements, timeTextConverter, l10nFilter, TimeZone.getTimeZone("UTC")) @Before diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/TestObjects.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/TestObjects.kt index e125c13..e8e660d 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/TestObjects.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/ajax/TestObjects.kt @@ -25,6 +25,7 @@ import net.pterodactylus.sone.test.get import net.pterodactylus.sone.test.mock import net.pterodactylus.sone.test.whenever import net.pterodactylus.sone.utils.asOptional +import net.pterodactylus.sone.web.NewElements import net.pterodactylus.sone.web.WebInterface import net.pterodactylus.sone.web.page.FreenetRequest import net.pterodactylus.util.notify.Notification @@ -49,6 +50,7 @@ open class TestObjects { val preferences = Preferences(eventBus) val updateChecker = mock() val elementLoader = mock() + val newElements = mock() val toadletContext = mock() val freenetRequest = mock() @@ -103,6 +105,9 @@ open class TestObjects { linkedElements[it.getArgument(0)] ?: LinkedElement(it.getArgument(0), loading = true) } + whenever(newElements.newPosts).then { newPosts.values } + whenever(newElements.newReplies).then { newReplies.values } + whenever(currentSone.options).thenReturn(DefaultSoneOptions()) currentSone.mock("soneId", "Sone_Id", true, 1000, idle)