Skip to content

Commit f62b78d

Browse files
committed
Write unit tests for SongListViewModel
1 parent 3888f02 commit f62b78d

5 files changed

Lines changed: 474 additions & 0 deletions

File tree

android/app/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@ android {
260260
implementation(libs.firebase.crashlytics)
261261

262262
// Testing
263+
testImplementation(libs.kotest)
264+
testImplementation(libs.mockk)
265+
testImplementation(libs.kotlinx.coroutinesTest)
263266
androidTestImplementation(libs.androidx.runner)
264267
androidTestImplementation(libs.androidx.rules)
265268
androidTestImplementation(libs.androidx.core.ktx)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.simplecityapps
2+
3+
import com.simplecityapps.shuttle.model.MediaProviderType
4+
import com.simplecityapps.shuttle.model.Song
5+
import kotlinx.datetime.Instant
6+
import kotlinx.datetime.LocalDate
7+
8+
fun createSong(
9+
id: Long = 1,
10+
name: String = "song-name",
11+
albumArtist: String = "album-artist",
12+
album: String = "album-name",
13+
track: Int = 1,
14+
duration: Int = 1,
15+
date: LocalDate = LocalDate(2024, 2, 11),
16+
playCount: Int = 0,
17+
lastPlayed: Instant? = Instant.fromEpochSeconds(1),
18+
lastCompleted: Instant? = Instant.fromEpochSeconds(1),
19+
mediaProvider: MediaProviderType = MediaProviderType.Shuttle,
20+
) = Song(
21+
id = id,
22+
name = name,
23+
albumArtist = albumArtist,
24+
artists = emptyList(),
25+
album = album,
26+
track = track,
27+
disc = 1,
28+
duration = duration,
29+
date = date,
30+
genres = emptyList(),
31+
path = "/path/to/song",
32+
size = 1,
33+
mimeType = "ogg",
34+
lastModified = Instant.fromEpochSeconds(1),
35+
lastPlayed = lastPlayed,
36+
lastCompleted = lastCompleted,
37+
playCount = playCount,
38+
playbackPosition = 1,
39+
blacklisted = false,
40+
externalId = null,
41+
mediaProvider = mediaProvider,
42+
replayGainTrack = null,
43+
replayGainAlbum = null,
44+
lyrics = null,
45+
grouping = null,
46+
bitRate = null,
47+
bitDepth = null,
48+
sampleRate = null,
49+
channelCount = null,
50+
)

0 commit comments

Comments
 (0)