add tests

This commit is contained in:
Tim Bentley 2016-01-05 19:32:12 +00:00
parent 2bbdf51aca
commit 8df7c3a9ea
2 changed files with 20 additions and 1 deletions

View File

@ -272,7 +272,7 @@ window.OpenLP = {
value[0] = OpenLP.escapeString(value[0])
}
var txt = "";
if (value.length > 2 && value[2].length > 0) {
if (value.length > 2) {
txt = value[1] + " ( " + value[2] + " )";
} else {
txt = value[1];

View File

@ -257,3 +257,22 @@ class TestMediaItem(TestCase, TestMixin):
# THEN: They should not match
self.assertFalse(result, "Authors should not match")
def build_remote_search_test(self):
"""
Test results for the remote search api
"""
# GIVEN: A Song and a search a JSON array should be returned.
mock_song = MagicMock()
mock_song.id = 123
mock_song.title = 'My Song'
mock_song.search_title = 'My Song'
mock_song.alternate_title = 'My alternative'
self.media_item.search_entire = MagicMock()
self.media_item.search_entire.return_value = [mock_song]
# WHEN: I process a search
search_results = self.media_item.search('My Song', False)
# THEN: The correct formatted results are returned
self.assertEqual(search_results, [[123, 'My Song', 'My alternative']])