scale icon indicating copy to clipboard operation
scale copied to clipboard

How do I get the value of content in scale-tooltip?

Open verdody opened this issue 1 year ago • 1 comments

Scale Version 3.0.0-beta.126

Hi. I have a question regarding scale-tooltip component. This is the structure of code that I am referring to:

@Component({
  selector: 'app-test',
  template: `
    <scale-tooltip content="test">
      <scale-button
        id="test-id"
        variant="secondary"
      >CLICK ME
      </scale-button>
    </scale-tooltip>
  `,
})

I am writing jasmine karma test to confirm that the scale-button tooltip is equal to "test".

This is the test:

beforeEach(() => {
    fixture = TestBed.createComponent(TestComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

it('should have title "test"', () => {
    const tooltip = fixture.nativeElement.querySelector('scale-tooltip') as HTMLElement;
    const tooltipContent = tooltip.getAttribute('content');
    expect(tooltipContent).toEqual('test');
  });

I also tried with this version:

it('should have title "test"', () => {
    const tooltip = fixture.nativeElement.querySelector('scale-tooltip ::slotted(*)');
    expect(tooltip.textContent.trim()).toEqual('test');
  });

Both test versions return error at the "expect" line = Expected null to equal "test" Can you suggest how do I get the value of the tooltip?

Thank you in advance for any support here.

verdody avatar Mar 10 '23 12:03 verdody

@verdody Can you please simulate this in sandbox or somewhere? Thanks.

ayeshaa-m avatar Jun 06 '23 08:06 ayeshaa-m