diff --git a/test/specs/album-service_test.js b/test/specs/album-service_test.js index b8f7ea1..75aa4a1 100644 --- a/test/specs/album-service_test.js +++ b/test/specs/album-service_test.js @@ -56,8 +56,79 @@ describe('Service: albumService', function() { $httpBackend.flush(); expect(album.serie).toBe(albums[i].série); expect(album.série).toBe(undefined); + expect(album.editeur).toBe(albums[i].éditeur); + expect(album.éditeur).toBe(undefined); + } }); + it('gives display names', function() { + var expectedData = { + "8179": { + "serieDisplay": "Mortes saisons", + "titleDisplay": "Mortes saisons", + "titleWithSerie": "Mortes saisons" + }, + "44989": { + "serieDisplay": "Abel Dopeulapeul", + "titleDisplay" : "Sale temps pour mourir", + "titleWithSerie": "Abel Dopeulapeul 2: Sale temps pour mourir" + }, + "58595": { + "serieDisplay": "", + "titleDisplay": "Des fourmis dans les jambes", + "titleWithSerie": "Des fourmis dans les jambes" + }, + "9935": { + "serieDisplay": "Bizu", + "titleDisplay": "La croisière fantôme", + "titleWithSerie": "Bizu 5: La croisière fantôme" + }, + "164": { + "serieDisplay": "Les Eaux de Mortelune", + "titleDisplay": "Vague à lames", + "titleWithSerie": "Les Eaux de Mortelune 5: Vague à lames" + }, + "32043": { + "serieDisplay": "Accros de ...", + "titleDisplay": "Rap", + "titleWithSerie": "Accros de ... 2: Rap" + }, + "46005": { + "serieDisplay": "Chick Bill", + "titleDisplay": "Le témoin du Rio Grande", + "titleWithSerie": "Chick Bill 23: Rap: Le témoin du Rio Grande" + }, + "15875": { + "serieDisplay": "Donc, Jean", + "titleDisplay": "...donc, Jean.", + "titleWithSerie": "...donc, Jean." + }, + "84448": { + "serieDisplay": "Black Crow", + "titleDisplay": "Black Crow raconte L'Hermione - La Conspiration pour la liberté", + "titleWithSerie" : "Black Crow raconte L'Hermione - La Conspiration pour la liberté" + }, + }; + for ( var key in expectedData) { + var album, err; + albumService.get(key) + .then(function (data) { + album = data; + }) + .catch(function() { + err = 'Could not fetch data'; + }); + $httpBackend.flush(); + + expect(album).not.toBe(undefined); + expect(err).toBe(undefined); + expect(album.serieDisplay).toBe(expectedData[key].serieDisplay); + expect(album.titleDisplay).toBe(expectedData[key].titleDisplay); + expect(album.titleWithSerie).toBe(expectedData[key].titleWithSerie); + + } + + }) }); diff --git a/webapp/js/services.js b/webapp/js/services.js index 88205c7..5affabc 100644 --- a/webapp/js/services.js +++ b/webapp/js/services.js @@ -4,6 +4,8 @@ services.factory('albumService',['$http','$log','$q', function($http,$log,$q) { function cleanupFields(album) { album.serie = album.série; album.série = undefined; + album.editeur = album.éditeur; + album.éditeur = undefined; return album; } function get(id) {