diff --git a/mopidy_musicbox_webclient/static/index.html b/mopidy_musicbox_webclient/static/index.html
index 9dfc006..38aedd7 100644
--- a/mopidy_musicbox_webclient/static/index.html
+++ b/mopidy_musicbox_webclient/static/index.html
@@ -151,7 +151,7 @@
- Show Track Info...
+ Show Track Info...
@@ -181,7 +181,7 @@
- Show Track Info...
+ Show Track Info...
diff --git a/mopidy_musicbox_webclient/static/js/controls.js b/mopidy_musicbox_webclient/static/js/controls.js
index d1114ab..75bb2a6 100644
--- a/mopidy_musicbox_webclient/static/js/controls.js
+++ b/mopidy_musicbox_webclient/static/js/controls.js
@@ -338,14 +338,19 @@
})
},
- showInfoPopup: function (popupId) {
+ showInfoPopup: function (popupId, mopidy) {
showLoading(true)
var uri = $(popupId).data('track')
$(popupId).popup('close')
mopidy.library.lookup({'uris': [uri]}).then(function (resultDict) {
var uri = Object.keys(resultDict)[0]
var track = resultDict[uri][0]
- $('#popupShowInfo #name-cell').text(track.name)
+ if (track.name) {
+ $('#popupShowInfo #name-cell').text(track.name)
+ } else {
+ $('#popupShowInfo #name-cell').text('(Not available)')
+ }
+
if (track.album && track.album.name) {
$('#popupShowInfo #album-cell').text(track.album.name)
} else {
@@ -383,8 +388,7 @@
$('#popupShowInfo #track-no-row').hide()
}
if (track.length) {
- var duration = new Date(track.length)
- $('#popupShowInfo #length-cell').text(duration.getUTCMinutes() + ':' + duration.getUTCSeconds())
+ $('#popupShowInfo #length-cell').text(timeFromSeconds(track.length / 1000))
$('#popupShowInfo #length-row').show()
} else {
$('#popupShowInfo #length-row').hide()
diff --git a/tests/js/test_controls.js b/tests/js/test_controls.js
index d8692e1..61a699f 100644
--- a/tests/js/test_controls.js
+++ b/tests/js/test_controls.js
@@ -360,4 +360,47 @@ describe('controls', function () {
})
})
})
+
+ describe('#showInfoPopup()', function () {
+ var track
+ var popup = $('')
+
+ before(function () {
+ track = {
+ 'uri': QUEUE_TRACKS[0].uri,
+ 'length': 61000
+ }
+ var library = {
+ lookup: sinon.stub()
+ }
+ mopidy.library = library
+ mopidy.library.lookup.returns($.when({'track:tlTrackMock1': [track]}))
+
+ $(document.body).append(popup)
+ $('#popupTracks').data(track, track.uri) // Simulate selection from context menu
+ $('#popupShowInfo').popup() // Initialize popup
+ })
+
+ afterEach(function () {
+ mopidy.library.lookup.reset()
+ })
+
+ it('should default track name', function () {
+ popup.append('')
+ controls.showInfoPopup('#popupTracks', mopidy)
+ assert.equal($('#name-cell').text(), '(Not available)')
+ })
+
+ it('should default album name', function () {
+ popup.append('')
+ controls.showInfoPopup('#popupTracks', mopidy)
+ assert.equal($('#album-cell').text(), '(Not available)')
+ })
+
+ it('should add leading zero if seconds length < 10', function () {
+ popup.append('')
+ controls.showInfoPopup('#popupTracks', mopidy)
+ assert.equal($('#length-cell').text(), '1:01')
+ })
+ })
})