|
@@ -102,43 +102,39 @@ export default function musicCardSnapshotTest() {
|
|
|
snapshot.currentTimeText = '00:12'
|
|
snapshot.currentTimeText = '00:12'
|
|
|
snapshot.durationTimeText = '05:01'
|
|
snapshot.durationTimeText = '05:01'
|
|
|
snapshot.filePath = '/storage/track.mp3'
|
|
snapshot.filePath = '/storage/track.mp3'
|
|
|
|
|
+ snapshot.isPlaying = true
|
|
|
|
|
+ snapshot.lyricText = '[00:00.00]残留'
|
|
|
|
|
+ snapshot.hasLyric = true
|
|
|
|
|
+ snapshot.lyricLine1 = '残留'
|
|
|
|
|
+ snapshot.lyricLine2 = ''
|
|
|
|
|
|
|
|
const binding = buildMusicCardBindingData(snapshot)
|
|
const binding = buildMusicCardBindingData(snapshot)
|
|
|
|
|
|
|
|
expect(binding.hasSong).assertEqual(false)
|
|
expect(binding.hasSong).assertEqual(false)
|
|
|
expect(binding.coverPath).assertEqual('')
|
|
expect(binding.coverPath).assertEqual('')
|
|
|
expect(binding.hasCoverImage).assertEqual(false)
|
|
expect(binding.hasCoverImage).assertEqual(false)
|
|
|
|
|
+ expect(binding.isPlaying).assertEqual(false)
|
|
|
expect(binding.currentPositionMs).assertEqual(0)
|
|
expect(binding.currentPositionMs).assertEqual(0)
|
|
|
expect(binding.durationMs).assertEqual(0)
|
|
expect(binding.durationMs).assertEqual(0)
|
|
|
expect(binding.currentTimeText).assertEqual('00:00')
|
|
expect(binding.currentTimeText).assertEqual('00:00')
|
|
|
expect(binding.durationTimeText).assertEqual('00:00')
|
|
expect(binding.durationTimeText).assertEqual('00:00')
|
|
|
expect(binding.filePath).assertEqual('')
|
|
expect(binding.filePath).assertEqual('')
|
|
|
|
|
+ expect(binding.hasLyric).assertEqual(false)
|
|
|
|
|
+ expect(binding.lyricLine1).assertEqual('未在播放')
|
|
|
|
|
+ expect(binding.lyricLine2).assertEqual('点击打开播放器')
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- it('buildMusicCardBindingDataKeepsSourceLyricsWhenAvailable', 0, () => {
|
|
|
|
|
|
|
+ it('buildMusicCardBindingDataDerivesLyricLinesWhenSongPlaying', 0, () => {
|
|
|
const snapshot = createEmptyMusicCardSnapshot()
|
|
const snapshot = createEmptyMusicCardSnapshot()
|
|
|
- snapshot.hasLyric = true
|
|
|
|
|
- snapshot.lyricLine1 = 'Backline 1'
|
|
|
|
|
- snapshot.lyricLine2 = 'Backline 2'
|
|
|
|
|
|
|
+ snapshot.hasSong = true
|
|
|
|
|
+ snapshot.lyricText = '[00:00.00]甲\n[00:05.00]乙'
|
|
|
|
|
+ snapshot.currentPositionMs = 6000
|
|
|
|
|
|
|
|
const binding = buildMusicCardBindingData(snapshot)
|
|
const binding = buildMusicCardBindingData(snapshot)
|
|
|
|
|
|
|
|
expect(binding.hasLyric).assertEqual(true)
|
|
expect(binding.hasLyric).assertEqual(true)
|
|
|
- expect(binding.lyricLine1).assertEqual('Backline 1')
|
|
|
|
|
- expect(binding.lyricLine2).assertEqual('Backline 2')
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
- it('buildMusicCardBindingDataFallsBackWhenLyricLinesEmpty', 0, () => {
|
|
|
|
|
- const snapshot = createEmptyMusicCardSnapshot()
|
|
|
|
|
- snapshot.hasLyric = true
|
|
|
|
|
- snapshot.lyricLine1 = ''
|
|
|
|
|
- snapshot.lyricLine2 = ''
|
|
|
|
|
-
|
|
|
|
|
- const binding = buildMusicCardBindingData(snapshot)
|
|
|
|
|
-
|
|
|
|
|
- expect(binding.hasLyric).assertEqual(false)
|
|
|
|
|
- expect(binding.lyricLine1).assertEqual('未在播放')
|
|
|
|
|
- expect(binding.lyricLine2).assertEqual('点击打开播放器')
|
|
|
|
|
|
|
+ expect(binding.lyricLine1).assertEqual('乙')
|
|
|
|
|
+ expect(binding.lyricLine2).assertEqual('')
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|