javascript - Unit Testing angularjs directive with angular-material-design with requirejs throws a "GET" error -
my app uses requirejs angularjs. i'm using text! in order load templates (so not use templateurl in directives). works fine - unless 1 of directives contains image in template.
i'm trying setup tests new directives icons in templates, no success. instance, have following directive template:
<buttondirective> <md-icon md-svg-src="/android.svg" alt="android "></md-icon> </buttondirective>
karma yells @ me "/android.svg" being called (the known "get" error: unexpected request: imagefilepath).
i've tried add image files karma config, did not solve issue.
any way around besides not using md-icon? (it works when change m d-icon simple image, guess issue md-icon directive using async call svg file , karma hates that...).
i got around issue using $httpbackend
mock request:
beforeeach(inject(function(_$compile_, _$rootscope_, _$httpbackend_) { $compile = _$compile_; $rootscope = _$rootscope_; $httpbackend = _$httpbackend_; $httpbackend .whenget('images/ic_forward_24px.svg') .respond(''); $httpbackend .whenget('images/ic_backward_24px.svg') .respond(''); $rootscope.$digest(); }));
Comments
Post a Comment