Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion renderers/angular/src/v0_9/core/a2ui-renderer.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import {TestBed} from '@angular/core/testing';
import {A2uiRendererService, A2UI_RENDERER_CONFIG} from './a2ui-renderer.service';
import {A2uiRendererService, A2UI_RENDERER_CONFIG, provideA2Ui} from './a2ui-renderer.service';

describe('A2uiRendererService', () => {
let service: A2uiRendererService;
Expand Down Expand Up @@ -84,3 +84,19 @@ describe('A2uiRendererService', () => {
});
});
});

describe('provideA2Ui', () => {
it('should provide the configuration', () => {
const mockCatalog = {
components: new Map(),
functions: new Map(),
};
TestBed.configureTestingModule({
providers: [
provideA2Ui({catalogs: [mockCatalog as any]}),
],
});
const config = TestBed.inject(A2UI_RENDERER_CONFIG);
expect(config).toEqual({catalogs: [mockCatalog as any]});
});
Comment thread
josemontespg marked this conversation as resolved.
Outdated
});
25 changes: 24 additions & 1 deletion renderers/angular/src/v0_9/core/a2ui-renderer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@
* limitations under the License.
*/

import {Injectable, OnDestroy, InjectionToken, inject, EnvironmentInjector} from '@angular/core';
import {
Injectable,
OnDestroy,
InjectionToken,
inject,
EnvironmentInjector,
EnvironmentProviders,
makeEnvironmentProviders,
} from '@angular/core';
import {
MessageProcessor,
SurfaceGroupModel,
Expand Down Expand Up @@ -47,6 +55,21 @@ export const A2UI_RENDERER_CONFIG = new InjectionToken<RendererConfiguration>(
'A2UI_RENDERER_CONFIG',
);

/**
* Provides the A2UI renderer configuration.
*
* @param config The configuration for the A2UI renderer.
* @returns The providers for the A2UI renderer.
*/
export function provideA2Ui(config: RendererConfiguration): EnvironmentProviders {
return makeEnvironmentProviders([
{
provide: A2UI_RENDERER_CONFIG,
useValue: config,
},
]);
}

/**
* Manages A2UI v0.9 rendering sessions by bridging the MessageProcessor to Angular.
*
Expand Down
Loading