Skip to content

How to test createDialog in jasmine? #28

@hemantmali21

Description

@hemantmali21

Hi,
I have used the createDialog service of fundoo solutions to show the pop up modal.I want to test the my delete functionality using jasmine.How to do that? please help.
Here is my code:
$scope.deleteProject = function (id) {

createDialog('/App/Modules/ReadAdmin/Projects/Templates/deleteproject.html', {

id: 'DeleteProjectDialog',

title: 'Delete Project',

backdrop: true,

controller: 'DetailCtrl',

success: { label: 'Proceed', fn: function () { projectService.delete({ id: id }); } },

cancel: { label: 'Cancel', fn: function () { console.log("Delete modal closed"); } }

},

{

id: id

});

};

//Details controller

projectApp.controller('DetailCtrl', function ($scope, projectService, id) {

$scope.project = projectService.get({ id: id });

});

//This is my test

it('should delete the project', function () {

$httpBackend.expectGET(api/projects).respond([{ id: 100, code: "B100", "name": "ABC"}]);

$httpBackend.expectDELETE(api/projects/100').respond({});

var ctrl = $controller('DetailCtrl', { $scope: $scope, projectService: mockprojectService,createDialog:dialogService });

$scope.deleteProject(100);
$httpBackend.flush();

expect(mockprojectService.delete).toHaveBeenCalled();

});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions