@@ -3,23 +3,49 @@ import { module, test } from 'qunit';
3
3
import { setupRenderingTest } from 'ember-qunit' ;
4
4
import { render } from '@ember/test-helpers' ;
5
5
6
+ function createMockGlimmerComponentDefinition ( ) {
7
+ return {
8
+ [ Symbol ( 'INNER' ) ] : {
9
+ name : 'mock-component' ,
10
+ ComponentClass : { } ,
11
+ template : { } ,
12
+ manager : { } ,
13
+ state : { } ,
14
+ } ,
15
+ } ;
16
+ }
17
+
6
18
module ( 'Integration | Helper | is-component-definition' , function ( hooks ) {
7
19
setupRenderingTest ( hooks ) ;
8
20
9
- // Replace this with your real tests.
10
- test ( 'it renders' , async function ( assert ) {
11
- this . set ( 'inputValue' , '1234' ) ;
12
-
13
- await render ( hbs `{{if (is-component-definition inputValue) "yes" "no"}}` ) ;
21
+ test ( 'it detects component definitions correctly' , async function ( assert ) {
22
+ await render ( hbs `{{if (is-component-definition "1234") "yes" "no"}}` ) ;
14
23
assert
15
24
. dom ( this . element )
16
- . hasText ( 'no' , "returns false when it's not a component definition" ) ;
25
+ . hasText (
26
+ 'no' ,
27
+ 'returns false when passed something other than a component definition'
28
+ ) ;
17
29
18
30
await render (
19
31
hbs `{{if (is-component-definition (component "polaris-heading" text="Text")) "yes" "no"}}`
20
32
) ;
21
33
assert
22
34
. dom ( this . element )
23
- . hasText ( 'yes' , "returns true when it's a component definition" ) ;
35
+ . hasText ( 'yes' , 'returns true when passed a component definition' ) ;
36
+
37
+ this . set (
38
+ 'glimmerComponentDefinition' ,
39
+ createMockGlimmerComponentDefinition ( )
40
+ ) ;
41
+ await render (
42
+ hbs `{{if (is-component-definition this.glimmerComponentDefinition) "yes" "no"}}`
43
+ ) ;
44
+ assert
45
+ . dom ( this . element )
46
+ . hasText (
47
+ 'yes' ,
48
+ 'returns true when passed a Glimmer component definition'
49
+ ) ;
24
50
} ) ;
25
51
} ) ;
0 commit comments