每当调用服务中的方法时,我就有一个更新Rxjs Subject的服务:
@Injectable()
export class AppAlertService implements IAppAlertService {
private readonly _alertBehaviourSubject: Subject<IAlertConfiguration> = new Subject<IAlertConfiguration>();
public get alertConfiguration(): Observable<IAlertConfigur
我有这样的代码:
// imports
describe('AdminGetRightsComponent', () => {
// Declare variables to be re-initialized before each test suite
let fixture: ComponentFixture<AdminGetRightsComponent>;
let component: AdminGetRightsComponent;
let router: Router;
let location: Loca
我对茉莉花很陌生。我正在努力使我的工厂承诺得到解决,但它似乎从来没有。
这是我的工厂,它将重新列出公司名单。
angular.module('commercial.factories').factory('companyFactory', companyFactory);
function companyFactory($http, $location, sessionStorage, config) {
function getCompanies() {
//call service and include company ident
我仍然在为Angular.io英雄教程的一个版本进行编程测试。在为组件编写测试时,我遇到了一些特殊的东西。我不能让这次考试失败。
例如:
describe('OrgDetailComponent', () => {
let comp: OrgDetailComponent;
let fixture: ComponentFixture<OrgDetailComponent>;
let de: DebugElement;
let el: HTMLElement;
let org1: Org = new Org({ ... fills Org
我试图为从服务调用异步函数的函数编写测试,而在我的一生中,我无法弄清楚如何让Jasmine在执行expect函数之前等待我的异步操作完成。
describe('vm.submitLogin', function () {
var $scope;
var $q;
var deferred;
var $controller;
beforeEach(module('myModule'));
beforeEach(inject(function (_$controller_, _$rootScope_, _$q_,
我在模拟属于我的一个模块的工厂时遇到了一些麻烦。我想要模拟的工厂有两个依赖项:
工厂类:
angular.module('serviceapp')
.factory('claims.service', ['applicationSettings', 'localStorageService', function (applicationSettings, localStorageService) {
//Factory code here
}]);
测试类:
//Instantiate some values
var mo
我正在尝试测试我的Angular服务,该服务所做的部分工作是加载一个JSON文件,该文件用作该服务的配置。我已经在测试中(通过console.log)确认了我模拟HTTP.get调用以获取配置的方法正在工作,并返回模拟的配置对象: // mocking the loading of the configuration in the beforeEach
authenticationService.loadInternalAuthModuleConfiguration();
const req = httpTestingController.expectOne('./internal-