mardi 24 février 2015

How to create Unit test using Angularjs?

i am creating Unit test for one of my factory and this is first time i am creating test using Angularjs.when i run grunt test in root of my directory i get an error cannot find plugin karma-phantomjs-launcher.


code tried so far...


Factory.spec.js



describe('lrrDetails', function () {
'use strict';

var httpBackend, serviceToTest, lrrSearchModalFactory;
beforeEach(module('thirdPartyManagementApp'));

beforeEach(inject(function ($httpBackend, lrrDetails) {
httpBackend = $httpBackend;
lrrSearchModalFactory = lrrDetails;

}));

it('should call the API to get Lrr Details for Dialog box', function (regInventoryId) {
httpBackend.expectGET('/third-party-management/rest/lrr/' + regInventoryId).respond(200, 'success');
var promise = lrrSearchModalFactory.findlrrDetail();
httpBackend.flush();
promise.then(function (data) {
expect(data.data).toBe('success');
});
});


});

Aucun commentaire:

Enregistrer un commentaire