1
- import { module , test } from ' qunit' ;
2
- import { setupRenderingTest } from ' ember-qunit' ;
3
- import { render } from ' @ember/test-helpers' ;
4
1
import AuLoader from ' @appuniversum/ember-appuniversum/components/au-loader' ;
2
+ import { getRootElement , render } from ' @ember/test-helpers' ;
3
+ import { queryByText } from ' @testing-library/dom' ;
4
+ import { hasDeprecationStartingWith } from ' dummy/tests/helpers/deprecations' ;
5
+ import { setupRenderingTest } from ' ember-qunit' ;
6
+ import { module , test } from ' qunit' ;
5
7
6
8
module (' Integration | Component | au-loader' , function (hooks ) {
7
9
setupRenderingTest (hooks );
8
10
11
+ test (' it uses the block contents as the loading message' , async function (assert ) {
12
+ await render (
13
+ <template >
14
+ <AuLoader >
15
+ Pagina is aan het laden
16
+ </AuLoader >
17
+ </template >,
18
+ );
19
+
20
+ assert .dom ().hasText (' Pagina is aan het laden' );
21
+ });
22
+
23
+ test (' it supports visually hiding the loading text' , async function (assert ) {
24
+ await render (
25
+ <template >
26
+ <AuLoader @ hiddenMessage ={{ true }} >
27
+ Pagina is aan het laden
28
+ </AuLoader >
29
+ </template >,
30
+ );
31
+
32
+ const root = getRootElement () as HTMLElement ;
33
+ const text = queryByText (root , ' Pagina is aan het laden' ) as HTMLElement ;
34
+
35
+ // Hacky way to test if the text is visible.
36
+ // `assert.dom(text).isNotVisible()` doesn't work here because of the styles we use for the au-u-hidden-visually class.
37
+ assert .true (text .offsetHeight <= 1 );
38
+ assert .true (text .offsetWidth <= 1 );
39
+ });
40
+
9
41
test (' it renders a hidden loading text for screen readers' , async function (assert ) {
10
42
await render (<template ><AuLoader /></template >);
11
43
@@ -16,11 +48,25 @@ module('Integration | Component | au-loader', function (hooks) {
16
48
await render (<template ><AuLoader @ message =" Loading" /></template >);
17
49
18
50
assert .dom ().hasText (' Loading' );
51
+ assert .true (
52
+ hasDeprecationStartingWith (' [AuLoader] `@message` is deprecated.' ),
53
+ );
19
54
});
20
55
21
56
test (' it supports disabling the hidden message' , async function (assert ) {
22
57
await render (<template ><AuLoader @ disableMessage ={{ true }} /></template >);
23
58
24
59
assert .dom ().hasNoText ();
60
+ assert .true (
61
+ hasDeprecationStartingWith (' [AuLoader] `@disableMessage` is deprecated.' ),
62
+ );
63
+ });
64
+
65
+ test (' @padding shows a deprecation' , async function (assert ) {
66
+ await render (<template ><AuLoader @ padding =" small" /></template >);
67
+
68
+ assert .true (
69
+ hasDeprecationStartingWith (' [AuLoader] `@padding` is deprecated.' ),
70
+ );
25
71
});
26
72
});
0 commit comments