How do unit test with angular-translate

后端 未结 11 2003
死守一世寂寞
死守一世寂寞 2020-12-08 09:38

I have uses angular translate from here (http://pascalprecht.github.io/angular-translate/) and it\'s just work fine, but it break my controller\'s unit test whith Error:

11条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-08 10:16

    Try putting to test method:

    it('should ...', function() {
        httpMock.when('GET', 'scripts/i18n/locale-en.json').respond({});
        httpMock.expectGET('scripts/i18n/locale-en.json');
        scope.resetForm(); // Action which fires a http request
        httpMock.flush(); // Flush must be called after the http request
    }
    

    See examples from Angular docs

提交回复
热议问题