Bonjour,
Pourriez-vous m'aider a faire le test unitaire de ma directive?
début de mon test unitaire.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 /// <reference path='../../_all.d.ts' /> module yql.directives { 'use strict'; export class Accueil { static $inject = ['Restangular', Accueil.directiveFactory]; static APIManager: string = '2015-07-01/Manager/'; static directiveFactory(Restangular: restangular.IService): ng.IDirective { return { templateUrl: 'app/directives/accueil/Accueil.html', replace: true, scope: { firm: '=firm' }, link: function(scope: any) { scope.loader = true; Restangular.one(Accueil.APIManager + 'firms/Thresholds').get({firm: scope.firm}).then((result: models.ODataResult<models.Threshold>) => { scope.Thresholds = result.Items; scope.loader = false; }); } }; } } }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 'use strict'; describe('Test de la directive d\'accueil', function () { var httpBackend; var compile; var scope; var URL_API = "http://cqlweb/Cegid.QuickLaunch/api/2015-07-01/Manager/firms/Thresholds?firm=Web@cad%C3%A9mie"; beforeEach(module('yql')); inject(function($httpBackend, $compile, $rootScope) { httpBackend = $httpBackend; compile = $compile; scope = $rootScope.$new(); }); afterEach(function() { httpBackend.verifyNoOutstandingExpectation(); httpBackend.verifyNoOutstandingRequest(); }); it('Get Thresholds', function() { httpBackend.expectGET(URL_API).respond(200, {}); httpBackend.flush(); expect(result).toEqual(''); }); });







Répondre avec citation
Partager