@@ -5,10 +5,15 @@ import {ComponentFixture, TestBed} from '@angular/core/testing';
5
5
import { MatTooltipModule } from '@angular/material/tooltip' ;
6
6
import { MatTooltipHarness } from '@angular/material/tooltip/testing/tooltip-harness' ;
7
7
import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
8
+ import { Platform } from '@angular/cdk/platform' ;
8
9
9
10
/** Shared tests to run on both the original and MDC-based tooltips. */
10
11
export function runHarnessTests (
11
12
tooltipModule : typeof MatTooltipModule , tooltipHarness : typeof MatTooltipHarness ) {
13
+ // TODO(COMP-322): whether the current test device is supported by the harness. At the time of
14
+ // writing, we have to skip these tests on touch devices, because we don't have a way of
15
+ // simulating touch events. This variable should be removed once the issue is resolved.
16
+ let isSupported : boolean ;
12
17
let fixture : ComponentFixture < TooltipHarnessTest > ;
13
18
let loader : HarnessLoader ;
14
19
@@ -21,21 +26,36 @@ export function runHarnessTests(
21
26
fixture = TestBed . createComponent ( TooltipHarnessTest ) ;
22
27
fixture . detectChanges ( ) ;
23
28
loader = TestbedHarnessEnvironment . loader ( fixture ) ;
29
+
30
+ const platform = TestBed . inject ( Platform ) ;
31
+ isSupported = ! platform . IOS && ! platform . ANDROID ;
24
32
} ) ;
25
33
26
34
it ( 'should load all tooltip harnesses' , async ( ) => {
35
+ if ( ! isSupported ) {
36
+ return ;
37
+ }
38
+
27
39
const tooltips = await loader . getAllHarnesses ( tooltipHarness ) ;
28
40
expect ( tooltips . length ) . toBe ( 2 ) ;
29
41
} ) ;
30
42
31
43
it ( 'should be able to show a tooltip' , async ( ) => {
44
+ if ( ! isSupported ) {
45
+ return ;
46
+ }
47
+
32
48
const tooltip = await loader . getHarness ( tooltipHarness . with ( { selector : '#one' } ) ) ;
33
49
expect ( await tooltip . isOpen ( ) ) . toBe ( false ) ;
34
50
await tooltip . show ( ) ;
35
51
expect ( await tooltip . isOpen ( ) ) . toBe ( true ) ;
36
52
} ) ;
37
53
38
54
it ( 'should be able to hide a tooltip' , async ( ) => {
55
+ if ( ! isSupported ) {
56
+ return ;
57
+ }
58
+
39
59
const tooltip = await loader . getHarness ( tooltipHarness . with ( { selector : '#one' } ) ) ;
40
60
expect ( await tooltip . isOpen ( ) ) . toBe ( false ) ;
41
61
await tooltip . show ( ) ;
@@ -45,12 +65,20 @@ export function runHarnessTests(
45
65
} ) ;
46
66
47
67
it ( 'should be able to get the text of a tooltip' , async ( ) => {
68
+ if ( ! isSupported ) {
69
+ return ;
70
+ }
71
+
48
72
const tooltip = await loader . getHarness ( tooltipHarness . with ( { selector : '#one' } ) ) ;
49
73
await tooltip . show ( ) ;
50
74
expect ( await tooltip . getTooltipText ( ) ) . toBe ( 'Tooltip message' ) ;
51
75
} ) ;
52
76
53
77
it ( 'should return empty when getting the tooltip text while closed' , async ( ) => {
78
+ if ( ! isSupported ) {
79
+ return ;
80
+ }
81
+
54
82
const tooltip = await loader . getHarness ( tooltipHarness . with ( { selector : '#one' } ) ) ;
55
83
expect ( await tooltip . getTooltipText ( ) ) . toBe ( '' ) ;
56
84
} ) ;
0 commit comments