title: How do I test if a matTooltip is properly disabled in Angular Material?
body: <p>I've got a loop creating several <code>matCard</code> elements. These represent events. Some of them are in the past. I give these a class to grey them out, and add a <code>matTooltip</code> to explain what that means.</p>
  <pre><code>&lt;mat-card
    class=&quot;event-card&quot;
    *ngFor=&quot;let event of events&quot;
    [class.past-event]=&quot;event.alreadyHappened()&quot;
    matTooltip=&quot;This event has already happened&quot;
    [matTooltipDisabled]=&quot;event.alreadyHappened() === false&quot;
  &gt;
    &lt;mat-card-header&gt;...&lt;/mat-card-header&gt;
    &lt;mat-card-content&gt;&lt;/mat-card-content&gt;
  &lt;/mat-card&gt;
  </code></pre>
  <p>The <code>alreadyHappened()</code> method returns a boolean.</p>
  <p>I would like to test that the disabled property is set correctly, but I can't find how to check that in <a href="https://material.angular.io/components/tooltip/api" rel="noreferrer">the <code>matTooltip</code> documentation</a>.</p>
  <p>I've got two tooltip harnesses for two cards. I can confirm that they're attached to the right card.</p>
  <pre class="lang-js prettyprint-override"><code>it('should display tootltip on past events', async () =&gt; {
    const tooltips = await loader.getAllHarnesses(MatTooltipHarness);
    expect(tooltips.length).toBe(2);
  
    expect(
      await (await tooltips[0].host()).hasClass('past-event')
    ).toBeTrue();
    expect(
      await (await tooltips[1].host()).hasClass('past-event')
    ).toBeFalse();
  
    await tooltips[0].show();
    expect(await tooltips[0].getTooltipText()).toEqual(
      'This event has already happened'
    );
  );
  </code></pre>
  <p>What I don't understand is how to get the <code>disabled</code> property. I found <a href="https://github.com/angular/components/blob/master/src/material/tooltip/tooltip.spec.ts#L249" rel="noreferrer">the tests for the actual <code>matTooltip</code> class</a>, but I think I shouldn't be messing with internals.</p>
  <p>I've figured out that I can get component instances for children <a href="https://stackoverflow.com/a/47799005/1331451">with this answer</a>.</p>
  <pre class="lang-js prettyprint-override"><code>const ttFixture = fixture.debugElement.queryAll(By.directive(MatTooltip));
  console.log(ttFixture);
  </code></pre>
  <p>But this gives me two <code>mat-card</code> elements, not the tooltips.</p>
  <p>Do I need to create a fixture for the tooltip, or is there something else I am missing?</p>