import { TestBed } from '@angular/core/testing';
import { SafeHtmlPipe } from './safe-html.pipe';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';

class MockDomSanitizer {
  bypassSecurityTrustHtml(value: string): SafeHtml {
    return value as SafeHtml;
  }
}

describe('SafeHtmlPipe', () => {
  let pipe: SafeHtmlPipe;

  beforeEach(() => {
    TestBed.configureTestingModule({
      providers: [
        SafeHtmlPipe,
        { provide: DomSanitizer, useClass: MockDomSanitizer }
      ]
    });

    pipe = TestBed.inject(SafeHtmlPipe);
  });

  it('create an instance', () => {
    expect(pipe).toBeTruthy();
  });

  it('should sanitize and trust HTML content', () => {
    const htmlContent = '<p>This is a <strong>test</strong> paragraph.</p>';
    const sanitizedContent = pipe.transform(htmlContent);

    expect(sanitizedContent.toString()).toContain('<p>This is a <strong>test</strong> paragraph.</p>');
  });
});



