angularjs - Jasmine Test - Unknown provider $sceProvider -


i trying write jasmine test filter. here filter:

angular.module('cpscore.filters').filter('texttohtmlsafe', ['$sce', function     ($sce) { return function (text) {         if (!text)             return text;          var htmltext = text.replace(/\<br \/\>/g, '\n');         htmltext = htmltext.replace(/\<br\/\>/g, '\n');         htmltext = htmltext.replace(/\<br\>/g, '\n');         htmltext = htmltext.replace(/\</g, '< ');         htmltext = htmltext.replace(/\&/g, '& ');         htmltext = htmltext.replace(/\n/g, '<br />');         return $sce.trustashtml(htmltext);     };  }]); 

here jasmine test:

describe('cpscore.filters', function() {  var texttohtmlsafefilter, $sce;  beforeeach(module('cpscore.filters')); beforeeach(inject(function (_$sce_, $filter) {     $sce = _$sce_;     texttohtmlsafefilter = $filter('texttohtmlsafe'); }));    it('should replace \n <br />', function () {     expect($sce.gettrustedhtml(texttohtmlsafefilter('testing\n'))).toequal('testing<br />');         });    }); 

i receiving error in karma when running test:

error: unknown provider: $sceprovider <- $sce

can tell me i'm doing wrong?

obviously module doesn't work fine. have create module empty dependency list!

var app = angular.module('cpscore.filters', []); 

plunker


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -