Skip to content

Commit bcbc2d4

Browse files
david-allisonmikehardy
authored andcommitted
refactor: extract 'clozeClass' to 'libanki-testutils'
1 parent 990fb2f commit bcbc2d4

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

AnkiDroid/src/test/java/com/ichi2/anki/libanki/MathJaxClozeTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package com.ichi2.anki.libanki
44

55
import androidx.test.ext.junit.runners.AndroidJUnit4
66
import com.ichi2.anki.libanki.template.MathJax
7+
import com.ichi2.anki.libanki.testutils.clozeClass
78
import com.ichi2.testutils.JvmTest
89
import org.hamcrest.MatcherAssert.assertThat
910
import org.hamcrest.Matchers.containsString

AnkiDroid/src/test/java/com/ichi2/anki/libanki/NoteTypeTest.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import anki.notetypes.copy
2020
import com.ichi2.anki.backend.stripHTML
2121
import com.ichi2.anki.common.utils.annotation.KotlinCleanup
2222
import com.ichi2.anki.libanki.exception.ConfirmModSchemaException
23+
import com.ichi2.anki.libanki.testutils.clozeClass
2324
import com.ichi2.anki.libanki.testutils.ext.addNote
2425
import com.ichi2.testutils.JvmTest
2526
import org.hamcrest.MatcherAssert.assertThat
@@ -31,13 +32,9 @@ import org.junit.Assert.assertNotEquals
3132
import org.junit.Test
3233
import org.junit.runner.RunWith
3334

34-
fun clozeClass(): String = "class=\"cloze\""
35-
36-
fun clozeData(data: String): String = " data-cloze=\"${data}\""
37-
3835
@RunWith(AndroidJUnit4::class)
3936
@KotlinCleanup("improve kotlin code where possible")
40-
class NotetypeTest : JvmTest() {
37+
class NoteTypeTest : JvmTest() {
4138
@Test
4239
fun test_frontSide_field() {
4340
// #8951 - Anki Special-cases {{FrontSide}} on the front to return empty string
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright (c) 2025 David Allison <davidallisongithub@gmail.com>
3+
*
4+
* This program is free software; you can redistribute it and/or modify it under
5+
* the terms of the GNU General Public License as published by the Free Software
6+
* Foundation; either version 3 of the License, or (at your option) any later
7+
* version.
8+
*
9+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
10+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11+
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU General Public License along with
14+
* this program. If not, see <http://www.gnu.org/licenses/>.
15+
*/
16+
17+
package com.ichi2.anki.libanki.testutils
18+
19+
fun clozeClass(): String = "class=\"cloze\""

0 commit comments

Comments
 (0)