Skip to content

Commit

Permalink
fix(material/tooltip): handle touch devices in test harness
Browse files Browse the repository at this point in the history
  • Loading branch information
crisbeto committed Dec 4, 2020
1 parent e8ae494 commit f050fab
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 29 deletions.
1 change: 0 additions & 1 deletion src/material/tooltip/testing/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ ng_test_library(
srcs = ["shared.spec.ts"],
deps = [
":testing",
"//src/cdk/platform",
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material/tooltip",
Expand Down
28 changes: 0 additions & 28 deletions src/material/tooltip/testing/shared.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@ import {ComponentFixture, TestBed} from '@angular/core/testing';
import {MatTooltipModule} from '@angular/material/tooltip';
import {MatTooltipHarness} from '@angular/material/tooltip/testing/tooltip-harness';
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
import {Platform} from '@angular/cdk/platform';

/** Shared tests to run on both the original and MDC-based tooltips. */
export function runHarnessTests(
tooltipModule: typeof MatTooltipModule, tooltipHarness: typeof MatTooltipHarness) {
// TODO(COMP-322): whether the current test device is supported by the harness. At the time of
// writing, we have to skip these tests on touch devices, because we don't have a way of
// simulating touch events. This variable should be removed once the issue is resolved.
let isSupported: boolean;
let fixture: ComponentFixture<TooltipHarnessTest>;
let loader: HarnessLoader;

Expand All @@ -26,36 +21,21 @@ export function runHarnessTests(
fixture = TestBed.createComponent(TooltipHarnessTest);
fixture.detectChanges();
loader = TestbedHarnessEnvironment.loader(fixture);

const platform = TestBed.inject(Platform);
isSupported = !platform.IOS && !platform.ANDROID;
});

it('should load all tooltip harnesses', async () => {
if (!isSupported) {
return;
}

const tooltips = await loader.getAllHarnesses(tooltipHarness);
expect(tooltips.length).toBe(2);
});

it('should be able to show a tooltip', async () => {
if (!isSupported) {
return;
}

const tooltip = await loader.getHarness(tooltipHarness.with({selector: '#one'}));
expect(await tooltip.isOpen()).toBe(false);
await tooltip.show();
expect(await tooltip.isOpen()).toBe(true);
});

it('should be able to hide a tooltip', async () => {
if (!isSupported) {
return;
}

const tooltip = await loader.getHarness(tooltipHarness.with({selector: '#one'}));
expect(await tooltip.isOpen()).toBe(false);
await tooltip.show();
Expand All @@ -65,20 +45,12 @@ export function runHarnessTests(
});

it('should be able to get the text of a tooltip', async () => {
if (!isSupported) {
return;
}

const tooltip = await loader.getHarness(tooltipHarness.with({selector: '#one'}));
await tooltip.show();
expect(await tooltip.getTooltipText()).toBe('Tooltip message');
});

it('should return empty when getting the tooltip text while closed', async () => {
if (!isSupported) {
return;
}

const tooltip = await loader.getHarness(tooltipHarness.with({selector: '#one'}));
expect(await tooltip.getTooltipText()).toBe('');
});
Expand Down

0 comments on commit f050fab

Please sign in to comment.