@@ -10,61 +10,99 @@ import setupIntlRenderingTest from '../../../helpers/setup-intl-rendering';
10
10
module (' Integration | Component | Attestations | Sixth-grade' , function (hooks ) {
11
11
setupIntlRenderingTest (hooks);
12
12
13
- test (' it should display all basics informations' , async function (assert ) {
14
- // given
15
- const onSubmit = sinon .stub ();
16
- const divisions = [];
17
-
18
- // when
19
- const screen = await render (<template ><SixthGrade @ divisions ={{divisions }} @ onSubmit ={{onSubmit }} /></template >);
20
- // then
21
- assert .ok (screen .getByRole (' heading' , { name: t (' pages.attestations.title' ) }));
22
- assert .ok (screen .getByText (t (' pages.attestations.description' )));
23
- assert .ok (screen .getByRole (' textbox' , { name: t (' pages.attestations.select-label' ) }));
24
- assert .ok (screen .getByPlaceholderText (t (' common.filters.placeholder' )));
25
- assert .ok (screen .getByRole (' button' , { name: t (' pages.attestations.download-attestations-button' ) }));
26
- });
13
+ module (' when organization has divisions' , function () {
14
+ test (' it should display all specifics informations for divisions' , async function (assert ) {
15
+ // given
16
+ const onSubmit = sinon .stub ();
17
+ const divisions = [];
18
+
19
+ // when
20
+ const screen = await render (<template ><SixthGrade @ divisions ={{divisions }} @ onSubmit ={{onSubmit }} /></template >);
21
+ // then
22
+ assert .ok (screen .getByRole (' heading' , { name: t (' pages.attestations.title' ) }));
23
+ assert .ok (screen .getByText (t (' pages.attestations.divisions-description' )));
24
+ assert .ok (screen .getByRole (' textbox' , { name: t (' pages.attestations.select-label' ) }));
25
+ assert .ok (screen .getByPlaceholderText (t (' common.filters.placeholder' )));
26
+ assert .ok (screen .getByRole (' button' , { name: t (' pages.attestations.download-attestations-button' ) }));
27
+ });
27
28
28
- test (' download button is disabled if there is no selected divisions' , async function (assert ) {
29
- // given
30
- const onSubmit = sinon .stub ();
31
- const divisions = [];
29
+ test (' download button is disabled if there is no selected divisions' , async function (assert ) {
30
+ // given
31
+ const onSubmit = sinon .stub ();
32
+ const divisions = [];
32
33
33
- // when
34
- const screen = await render (<template ><SixthGrade @ divisions ={{divisions }} @ onSubmit ={{onSubmit }} /></template >);
34
+ // when
35
+ const screen = await render (<template ><SixthGrade @ divisions ={{divisions }} @ onSubmit ={{onSubmit }} /></template >);
35
36
36
- // then
37
- const downloadButton = await screen .getByRole (' button' , {
38
- name: t (' pages.attestations.download-attestations-button' ),
37
+ // then
38
+ const downloadButton = await screen .getByRole (' button' , {
39
+ name: t (' pages.attestations.download-attestations-button' ),
40
+ });
41
+ assert .dom (downloadButton).isDisabled ();
39
42
});
40
- assert .dom (downloadButton).isDisabled ();
41
- });
42
43
43
- test (' it should call onSubmit action with selected divisions' , async function (assert ) {
44
- // given
45
- const onSubmit = sinon .stub ();
44
+ test (' it should call onSubmit action with selected divisions' , async function (assert ) {
45
+ // given
46
+ const onSubmit = sinon .stub ();
46
47
47
- const divisions = [{ label: ' division1' , value: ' division1' }];
48
+ const divisions = [{ label: ' division1' , value: ' division1' }];
48
49
49
- // when
50
- const screen = await render (<template ><SixthGrade @ divisions ={{divisions }} @ onSubmit ={{onSubmit }} /></template >);
50
+ // when
51
+ const screen = await render (<template ><SixthGrade @ divisions ={{divisions }} @ onSubmit ={{onSubmit }} /></template >);
51
52
52
- const multiSelect = await screen .getByRole (' textbox' , { name: t (' pages.attestations.select-label' ) });
53
- await click (multiSelect);
53
+ const multiSelect = await screen .getByRole (' textbox' , { name: t (' pages.attestations.select-label' ) });
54
+ await click (multiSelect);
54
55
55
- const firstDivisionOption = await screen .findByRole (' checkbox' , { name: ' division1' });
56
- await click (firstDivisionOption);
56
+ const firstDivisionOption = await screen .findByRole (' checkbox' , { name: ' division1' });
57
+ await click (firstDivisionOption);
57
58
58
- const downloadButton = await screen .getByRole (' button' , {
59
- name: t (' pages.attestations.download-attestations-button' ),
59
+ const downloadButton = await screen .getByRole (' button' , {
60
+ name: t (' pages.attestations.download-attestations-button' ),
61
+ });
62
+
63
+ // we need to get out of input choice to click on download button, so we have to click again on the multiselect to close it
64
+ await click (multiSelect);
65
+ await click (downloadButton);
66
+
67
+ // then
68
+ sinon .assert .calledWithExactly (onSubmit, [' division1' ]);
69
+ assert .ok (true );
60
70
});
71
+ });
61
72
62
- // we need to get out of input choice to click on download button, so we have to click again on the multiselect to close it
63
- await click (multiSelect);
64
- await click (downloadButton);
73
+ module (' when organization does not have divisions' , function () {
74
+ test (' it should display all basics informations' , async function (assert ) {
75
+ // given
76
+ const onSubmit = sinon .stub ();
77
+ const divisions = undefined ;
65
78
66
- // then
67
- sinon .assert .calledWithExactly (onSubmit, [' division1' ]);
68
- assert .ok (true );
79
+ // when
80
+ const screen = await render (<template ><SixthGrade @ divisions ={{divisions }} @ onSubmit ={{onSubmit }} /></template >);
81
+ // then
82
+ assert .notOk (screen .queryByRole (' textbox' , { name: t (' pages.attestations.select-label' ) }));
83
+ assert .ok (screen .getByRole (' heading' , { name: t (' pages.attestations.title' ) }));
84
+ assert .ok (screen .getByText (t (' pages.attestations.basic-description' )));
85
+ assert .ok (screen .getByRole (' button' , { name: t (' pages.attestations.download-attestations-button' ) }));
86
+ });
87
+
88
+ test (' it should call onSubmit action with empty divisions' , async function (assert ) {
89
+ // given
90
+ const onSubmit = sinon .stub ();
91
+
92
+ const divisions = undefined ;
93
+
94
+ // when
95
+ const screen = await render (<template ><SixthGrade @ divisions ={{divisions }} @ onSubmit ={{onSubmit }} /></template >);
96
+
97
+ const downloadButton = await screen .getByRole (' button' , {
98
+ name: t (' pages.attestations.download-attestations-button' ),
99
+ });
100
+
101
+ await click (downloadButton);
102
+
103
+ // then
104
+ sinon .assert .calledWithExactly (onSubmit, []);
105
+ assert .ok (true );
106
+ });
69
107
});
70
108
});
0 commit comments