2
권한이 KO 인 경우 일부 사용 권한을 검사하고 DOM에서 요소를 삭제하는 지시문을 작성했습니다.
나는 단위 테스트를 좋아하지만, ... 헴,이 간단한 테스트 작업을하기 위해 내 머리 벽을 두드리고 있습니다.
$ rootScope.digest()를 사용하여 HTML을 컴파일합니다. 이 함수를 호출 할 때 각도가 내 응용 프로그램 기본 페이지를로드하려고하면 "더 이상의 요청이 예상되지 않습니다."오류가 표시됩니다. 그래서 여기
테스트입니다 :
describe('Unit testing permission-needed', function() {
var $compile;
var $rootScope;
var $httpBackend;
// Load the myApp module, which contains the directive
beforeEach(module('app'));
beforeEach(angular.mock.module('ngMockE2E'));
beforeEach(inject(function(_$compile_, _$rootScope_, $injector) {
$compile = _$compile_;
$rootScope = _$rootScope_;
$httpBackend = $injector.get('$httpBackend'); // not sur if I can inject it like others services ?
$httpBackend.whenGET('app/login/login.tpl.html').passThrough(); // this doesn't seem to work
}));
it('should replace the element with the appropriate content', function() {
// Compile a piece of HTML containing the directive
var element = $compile("<div permission-needed><span>Some content goes here</span></div>")($rootScope);
$rootScope.$digest(); // BAM => "no more request expected"
// Do the test here
// expect(....);
});
});
참고 내가 ('여기에 몇 가지 html로') .respond를 사용하는 경우; .passThrough() 대신 대신 이 작동합니다.
감사합니다. 자신을 응답
음, 고맙습니다. :) –