diff --git a/src/testing/utils.ts b/src/testing/utils.ts index 0bb4e7fff..f2b16afec 100644 --- a/src/testing/utils.ts +++ b/src/testing/utils.ts @@ -16,6 +16,7 @@ import { Component, CUSTOM_ELEMENTS_SCHEMA, Type, ViewChild } from '@angular/cor import { ComponentFixture, TestBed } from '@angular/core/testing'; import { CoreSingletonProxy } from '@singletons'; +import { CoreTextUtilsProvider } from '@services/utils/text'; abstract class WrapperComponent { @@ -30,6 +31,8 @@ export interface RenderConfig { export type WrapperComponentFixture = ComponentFixture>; +const textUtils = new CoreTextUtilsProvider(); + export function mock(instance?: Record): T; export function mock(methods: string[], instance?: Record): T; export function mock( @@ -108,12 +111,12 @@ export async function renderTemplate( export async function renderWrapperComponent( component: Type, tag: string, - inputs: Record = {}, + inputs: Record = {}, config: Partial = {}, ): Promise> { const inputAttributes = Object .entries(inputs) - .map(([name, value]) => `${name}="${value.toString().replace(/"/g, '"')}"`) + .map(([name, value]) => `[${name}]="${textUtils.escapeHTML(JSON.stringify(value)).replace(/\//g, '\\/')}"`) .join(' '); return renderTemplate(component, `<${tag} ${inputAttributes}>`, config);