Browse Source

Refactor core testing module to inject INCUDE_LOCALIZATION_RESOURCES_TOKEN and set its value to false

pull/16018/head
Mahmut Gundogdu 3 years ago
parent
commit
d6b926f153
  1. 15
      npm/ng-packs/packages/core/src/lib/services/config-state.service.ts
  2. 5
      npm/ng-packs/packages/core/testing/src/lib/core-testing.module.ts

15
npm/ng-packs/packages/core/src/lib/services/config-state.service.ts

@ -1,4 +1,4 @@
import { Inject, Injectable } from '@angular/core';
import { inject, Injectable } from '@angular/core';
import { Observable, Subject } from 'rxjs';
import { map, switchMap, take, tap } from 'rxjs/operators';
import { AbpApplicationConfigurationService } from '../proxy/volo/abp/asp-net-core/mvc/application-configurations/abp-application-configuration.service';
@ -15,6 +15,9 @@ import { InternalStore } from '../utils/internal-store-utils';
})
export class ConfigStateService {
private readonly store = new InternalStore({} as ApplicationConfigurationDto);
private readonly includeLocalizationResources = inject(INCUDE_LOCALIZATION_RESOURCES_TOKEN);
private abpConfigService = inject(AbpApplicationConfigurationService);
private abpApplicationLocalizationService = inject(AbpApplicationLocalizationService);
get createOnUpdateStream() {
return this.store.sliceUpdate;
@ -22,12 +25,7 @@ export class ConfigStateService {
private updateSubject = new Subject<void>();
constructor(
private abpConfigService: AbpApplicationConfigurationService,
private abpApplicationLocalizationService: AbpApplicationLocalizationService,
@Inject(INCUDE_LOCALIZATION_RESOURCES_TOKEN)
private readonly includeLocalizationResources: boolean,
) {
constructor() {
this.initUpdateStream();
}
@ -61,6 +59,7 @@ export class ConfigStateService {
onlyDynamics: false,
});
}
refreshAppState() {
this.updateSubject.next();
return this.createOnUpdateStream(state => state).pipe(take(1));
@ -141,7 +140,7 @@ export class ConfigStateService {
return keys.reduce((acc, key) => ({ ...acc, [key]: features.values[key] }), {});
}
getFeatures$(keys: string[]): Observable<{[key: string]: string} | undefined> {
getFeatures$(keys: string[]): Observable<{ [key: string]: string } | undefined> {
return this.store.sliceState(({ features }) => {
if (!features?.values) return;

5
npm/ng-packs/packages/core/testing/src/lib/core-testing.module.ts

@ -7,6 +7,7 @@ import {
LOADER_DELAY,
PermissionService,
RestService,
INCUDE_LOCALIZATION_RESOURCES_TOKEN,
} from '@abp/ng.core';
import { APP_BASE_HREF } from '@angular/common';
import { ModuleWithProviders, NgModule } from '@angular/core';
@ -60,6 +61,10 @@ export class CoreTestingModule {
provide: LOADER_DELAY,
useValue: 0,
},
{
provide: INCUDE_LOCALIZATION_RESOURCES_TOKEN,
useValue: false,
},
provideRoutes(routes),
],
};

Loading…
Cancel
Save