Skip to content

Commit

Permalink
🧪 Test la méthosde la récupérer des questions dans le dépot ressource
Browse files Browse the repository at this point in the history
  • Loading branch information
marouria authored and cprodhomme committed Nov 12, 2024
1 parent 244a4c4 commit eb27a49
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/situations/commun/infra/depot_ressources_communes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import RegistreCampagne from 'commun/infra/registre_campagne';
import { extraitQuestionsReponsesAudios } from 'commun/infra/depot_ressources';

export default class DepotRessourcesCommunes extends DepotRessources {
constructor (chargeurs, messagesVideos, messagesAudios, fondConsigne, sonConsigneDemarrage, sonConsigneTransition = sonConsigneBlanche, registreCampagne = new RegistreCampagne()) {
const questionsServeur = registreCampagne.questions(['cafe_de_la_place', 'place_du_marche']);
constructor (chargeurs, messagesVideos, messagesAudios, fondConsigne, sonConsigneDemarrage, sonConsigneTransition = sonConsigneBlanche) {
const questionsServeur = new RegistreCampagne().questions(['cafe_de_la_place', 'place_du_marche']);
const messagesAudiosServeur = extraitQuestionsReponsesAudios(questionsServeur);
super(chargeurs);
this.charge([casque, son, calculatrice, sonConsigneDemarrage, sonConsigneTransition, iconeDeconnexion]);
Expand Down
43 changes: 38 additions & 5 deletions tests/situations/commun/infra/depot_ressources_communes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@ import chargeurs from '../aides/mock_chargeurs';
import DepotRessources from 'commun/infra/depot_ressources';
import DepotRessourcesCommunes from 'commun/infra/depot_ressources_communes';

const questionsServeur = [
{ id: 1, nom_technique: 'N1Prn1', choix: [{ type_choix: 'bon' }] },
{ id: 1, nom_technique: 'N1Prn2', type: 'clic-dans-image' },
{ id: 1, nom_technique: 'N1Prn1', type: 'glisser-deposer' }
];

jest.mock('commun/infra/registre_campagne', () => {
return jest.fn().mockImplementation(() => {
return {
questions: jest.fn().mockReturnValue(questionsServeur)
};
});
});

describe('Le dépot de ressources communes', function () {
const imgFondConsigne = 'fondConsigne.png';
const sonConsigneDemarrage = 'consigneDemarrage.mp3';
Expand All @@ -12,15 +26,11 @@ describe('Le dépot de ressources communes', function () {
let sonsCharges;
let imgCharges;
let videosCharges;
let registreCampagne;

beforeEach(function () {
sonsCharges = [];
imgCharges = [];
videosCharges = [];
registreCampagne = {
questions: () => { return []; }
};
const _chargeurs = chargeurs({
mp3: (_son) => {
sonsCharges.push(_son);
Expand All @@ -35,7 +45,7 @@ describe('Le dépot de ressources communes', function () {
return Promise.resolve(() => _video);
}
});
depot = new DepotRessourcesCommunes(_chargeurs, { videoQuestion1: videoQuestion1 }, { audioQuestion1: sonAudioQuestion1 }, imgFondConsigne, sonConsigneDemarrage, sonConsigneTransition, registreCampagne);
depot = new DepotRessourcesCommunes(_chargeurs, { videoQuestion1: videoQuestion1 }, { audioQuestion1: sonAudioQuestion1 }, imgFondConsigne, sonConsigneDemarrage, sonConsigneTransition);
});

it('étend DépotRessources', function () {
Expand Down Expand Up @@ -131,4 +141,27 @@ describe('Le dépot de ressources communes', function () {
});
});
});


describe('#questions', function() {
let result;

beforeEach(function() {
result = depot.questions();
});

it('retourne les questions du serveur', function() {
expect(result).toEqual(questionsServeur);
});

it("definie l'extension vue pour le type clic dans image", function() {
console.log('result:', result);
expect(result[1]['extensionVue']).toEqual('clic-dans-image' );
});


it("definie l'extension vue pour le type glisser déposer", function() {
expect(result[2].extensionVue).toEqual('glisser-deposer' );
});
});
});

0 comments on commit eb27a49

Please sign in to comment.