@@ -7,35 +7,43 @@ import LandingLayout from '~/layouts/landing/landing';
7
7
// @ts -expect-error does not exist on
8
8
const { routerFuture} = global ;
9
9
10
+ type Layout = Parameters < typeof LandingLayout > [ 0 ] [ 'data' ] [ 'layout' ] ;
10
11
11
12
describe ( 'layouts/landing' , ( ) => {
12
- const data : Parameters < typeof LandingLayout > [ 0 ] [ 'data' ] = {
13
- title : 'the-title' ,
14
- layout : [ ]
15
- } ;
13
+ function Component ( { layout} : { layout : Layout } ) {
14
+ const data : Parameters < typeof LandingLayout > [ 0 ] [ 'data' ] = {
15
+ title : 'the-title' ,
16
+ layout
17
+ } ;
16
18
17
- function Component ( { showGive} : { showGive ?: boolean } ) {
18
19
return (
19
20
< MemoryRouter initialEntries = { [ '' ] } future = { routerFuture } >
20
- < LandingLayout data = { data } showGive = { showGive } >
21
+ < LandingLayout data = { data } >
21
22
< div > child contents</ div >
22
23
</ LandingLayout >
23
24
</ MemoryRouter >
24
25
) ;
25
26
}
26
27
27
28
it ( 'renders without layout values' , ( ) => {
28
- render ( < Component /> ) ;
29
+ render ( < Component layout = { [ ] } /> ) ;
29
30
expect ( screen . getAllByRole ( 'img' ) ) . toHaveLength ( 2 ) ;
30
31
expect ( screen . getAllByRole ( 'link' ) ) . toHaveLength ( 1 ) ;
31
32
} ) ;
32
33
it ( 'suppresses the Give link when specified' , ( ) => {
33
- render ( < Component showGive = { false } /> ) ;
34
+ const layout = [ {
35
+ value : {
36
+ navLinks : [ ] ,
37
+ showGive : false
38
+ }
39
+ } ] ;
40
+
41
+ render ( < Component layout = { layout } /> ) ;
34
42
expect ( screen . getAllByRole ( 'img' ) ) . toHaveLength ( 2 ) ;
35
43
expect ( screen . queryAllByRole ( 'link' ) ) . toHaveLength ( 0 ) ;
36
44
} ) ;
37
45
it ( 'renders with layout values' , ( ) => {
38
- data . layout . push ( {
46
+ const layout = [ {
39
47
value : {
40
48
navLinks : [
41
49
{
@@ -47,8 +55,9 @@ describe('layouts/landing', () => {
47
55
}
48
56
]
49
57
}
50
- } ) ;
51
- render ( < Component /> ) ;
58
+ } ] ;
59
+
60
+ render ( < Component layout = { layout } /> ) ;
52
61
expect ( screen . getAllByRole ( 'link' ) ) . toHaveLength ( 2 ) ;
53
62
} ) ;
54
63
} ) ;
0 commit comments