I'm currently doing a project with a group of people and I am trying to construct unit tests for the code. I'm not too adept with javascript as with other languages so I'm not entirely sure how to unit test this code. I'm using a Jasmine test runner which is working properly. This is a sample of the code being used:
app.controller('cmsAboutController', ['$scope', 'cmsService', function($scope, cmsService){
// assings selected element to active, which populates form fields
$scope.editSection = function(section){
$scope.active = {
about_id: section.about_id,
about_title: section.about_title,
about_description: section.about_description,
about_img: section.about_img
};
};
And this is the current Spec (I've set the "toEqual:" to be true to ensure that the runner works properly:
describe('cmsAboutController', function () {
beforeEach(module('Robotix'));
var subject
, $scope
, cmsService = { // mock the Service service
set: function () {},
}
;
beforeEach(inject(function ($controller, $rootScope) {
$scope = $rootScope.$new(); // create a new clean scope
subject = $controller('cmsAboutController', {
cmsService: cmsService,
$scope: $scope,
});
}));
it('should edit section', function () {
expect($scope.editSection).toEqual(true);
});
});
Any advice would be greatly appreciated, thanks to all in advance
Aucun commentaire:
Enregistrer un commentaire