У меня странная проблема, и я застрял.директива компиляции с кармой для углового
Моя задача - проверить список директив в проекте.
Директивы выглядеть следующим образом:
angular.module('lessons', []).directive('uwTextarea', ['usUmpire', 'usConfig', function (usUmpire, usConfig) {
return {
scope: {
settings: "="
},
restrict: 'E',
replace: true,
transclude : true,
templateUrl: 'rki/directive/uw-textarea/uw-textarea.html',
controller: function ($scope, $element) {
// blah blah
}
};
}]);
Тестовые выглядеть следующим образом:
describe('uwTextarea', function() {
var scope, rscope, elem, compile;
beforeEach(module('lessons'));
beforeEach(module('directive/uw-textarea/uw-textarea.html'));
beforeEach(inject(function($rootScope, $compile) {
rscope = $rootScope;
compile = $compile;
}))
it('Directive Compiles', function() {
elem = compile('<uw-textarea></uw-textarea>')(rscope);
console.log(elem);
rscope.$digest();
});
});
console.log(elem)
дает мне эту
LOG: {0: <uw-textarea class="ng-scope"></uw-textarea>, length: 1}
путь, как я ча n получить мой шаблон от
beforeEach(inject(function($rootScope, $compile, $templateCache) {
rscope = $rootScope;
compile = $compile;
tmpl = $templateCache.get('directive/uw-textarea/uw-textarea.html');
}))
но я думаю, что это не правильно.
karma.conf.js
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['jasmine'],
files: [
'bower_components/jquery/dist/jquery.min.js',
'bower_components/angular/angular.min.js',
'bower_components/angular-mocks/angular-mocks.js',
'app.js',
'service/*.js',
'directive/uw-textarea/uw-textarea.js',
'directive/uw-textarea/uw-textarea-spec.js',
'directive/uw-textarea/uw-textarea.html'
],
preprocessors: {
'directive/uw-textarea/uw-textarea.html' : 'ng-html2js'
},
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
};
Я пытался использовать ng-directive-testing пример для моих тестов, и делать то же мою директиву не компилируется.
Что не так с моим кодом?