Unit testing angular-bootstrap $modal

后端 未结 4 1452
感动是毒
感动是毒 2020-12-29 00:35

I\'m having problems trying to write a jasmine unit test for an Angular-Bootstrap $modal. The exact error is Expected spy open to have been called with [

4条回答
  •  梦谈多话
    2020-12-29 01:06

    I am not sure if this will help you now, but when you spy on something you can get the argument that is passed to the $uibModal.open spy, you can then call that function to test that it returns what is in the resolve method.

    it('expect resolve to be have metadataid that will return 9999', () => {
                spyOn($uibModal, 'open');
                //add test code here that will call the $uibModal.open
                var spy = $uibModal.open;
                var args = spy.calls.argsFor(0);
                expect(args[0].resolve.metadataId()).toEqual(9999);
    });
    

    ***** my code is using typescript, but this works for me.**

提交回复
热议问题